IoT Lithium Battery Monitoring system using ESP8266 & Arduino IoT Cloud

(Last Updated On: October 14, 2021)

IoT Lithium Battery monitoring system, Overview:

IoT Lithium Battery Monitoring System using Nodemcu ESP8266 and Arduino IoT Cloud– In this tutorial we are going to make an IoT battery monitoring system for the Lithium ion battery using Arduino IoT Cloud and Nodemcu ESP8266 WiFi module. We will display the battery voltage and battery percentage on gauges and charts. Previously, I designed a battery monitoring system for a 12V Lead Acid battery and I used Blynk application for the remote monitoring over WiFi.

In this tutorial, I will be using the Arduino IoT Cloud which is becoming very popular and I have already used in a couple of projects. If you are a beginner then I highly recommend read my getting started tutorial on the Arduino IoT Cloud.


Amazon Links:

Nodemcu ESP8266

Lithium Ion Battery

TP4056 Battery Module

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Lithium Ion Battery Monitoring Circuit diagram:

IoT Lithium Battery Monitoring

First of all, we will design circuit diagram for which we will require the following components:

  • NodeMCU ESP8266
  • TP4056 battery module
  • Lithium ion battery
  • Two 100 KΩ resistor

First of all, we will make a voltage divider circuit by connecting the 100k resistors in series and connect the A0 pin of the Nodemcu ESP8266 between the two resistors. Then connect one end of the resistor with the OUT+ of the TP4056 battery module and connect the other end of the resistor with the OUT- of the TP4056 module. Then connect the B+ of the TP4056 module with the positive terminal of the battery and B- of the TP4056 module with the negative terminal of the battery.



Designing IOT application for battery monitoring system:

Now, in order to create battery monitoring system, we will go to the Arduino official website.

https://create.arduino.cc/

Now, if you do not have an account first of all create account on the Arduino cc which we have already discussed in the getting started tutorial on the Arduino IoT Cloud.

If you already have an account then you are all set and if not then follow the steps given below.

Click on the IOT cloud.

IoT Lithium Battery Monitoring

Now click on the CREATE THING

IoT Lithium Battery Monitoring

Now, we will create variables, in our case we are using two variables; one for the battery percentage and the other one for the battery voltage. So to add the variables click on the ADD VARIABLE button.

IoT Lithium Battery Monitoring


When we click on the ADD VARIABLE button, a dialog box will open in which we will define the type, name, and variable permission. In the first variable, we will store the percentage of the battery for which we declare the integer variable and as we are going to only read the data, so we will select the read only.

IoT Lithium Battery Monitoring

In the variable update policy, we will select the on change and click on the add variable.

IoT Lithium Battery Monitoring

Now, we will create another variable for the battery voltage; so, now we will click on the add button to add another variable.

IoT Lithium Battery Monitoring

Now, we will give the name voltage to the variable and declare it as the float type and in this case again we are only reading the data so we will select the read only.

IoT Lithium Battery Monitoring


In the variable update policy we will select the on change and then click on the add variable.

IoT Lithium Battery Monitoring

Now both the variables are created and we will add the device with the help of which we are going to monitor the system. Click on the device

IoT Lithium Battery Monitoring

Now a dialog box will open and select a third party device

IoT Lithium Battery Monitoring

Now we will choose which type of the microcontroller board we are going to use, in our case we are using Nodemcu ESP8266 so, we will select the ESP8266 and also select its model and click on the continue button.

IoT Lithium Battery Monitoring

Then give the name to the device in our case we are using the name electronic clinic and click on the next button.

IoT Lithium Battery Monitoring


Now download the pdf file which consists of the security key and device id which will be used in configuring the network.

IoT Lithium Battery Monitoring

After downloading the id click on the I save my device id and security key and click on the continue button.

IoT Lithium Battery Monitoring

After clicking on the continue , the device is successfully added. Now after that we will click on the configure the network

IoT Lithium Battery Monitoring

After clicking the configure button  a dialog box will appear in which we will enter the SSID means the router name, password, and the security key which we have copied during adding the device.

IoT Lithium Battery Monitoring

Now after entering the required values we will click on the save button.

Then we will click on the dashboard to design the application.

IoT Lithium Battery Monitoring



When we click on the dashboard a new window will open in which we will click on the edit button and now give a name to the project.

IoT Lithium Battery Monitoring

Then we will add the widget for the application by clicking on the add and we will select the percentage

IoT Lithium Battery Monitoring

Then we will select the variable for it in our case we are using variable battery percentage which is int type select the battery percentage and click on the link variable.

IoT Lithium Battery Monitoring

Now we will add gauge for the battery voltage by clicking on the add button

IoT Lithium Battery Monitoring

Then give a name to the gauge which is battery voltage and click on the link variable

IoT Lithium Battery Monitoring

When we click on the link variable we will select the variable which is voltage and click on the link variable.

IoT Lithium Battery Monitoring


Then we will add the live chart for both the voltage and percentage now again click on the add button and select the chart. Now give a name battery percentage and linked it with the battery percentage variable and click on the done button.

IoT Lithium Battery Monitoring

Similarly, we will again insert chart for the battery voltage and linked it with the variable voltage and click on the done button.

IoT Lithium Battery Monitoring

Now the application design is completed and it will look like

IoT Lithium Battery Monitoring

After that we will write the code by clicking on the sketch button

IoT Lithium Battery Monitoring

When we will click on the sketch button the code will appear, we will write the following code


Complete code:

Now in order to upload the code we will first install the ArduinoCreateAgent which is necessary for uploading the code and then we will select the port and board.

IoT Lithium Battery Monitoring


After selecting the board and port we will upload the code

IoT Lithium Battery Monitoring

After uploading the code successfully

IoT Lithium Battery Monitoring



Then we will click on the serial monitor on which the battery voltage and percentage will be displayed.

IoT Lithium Battery Monitoring

 

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

%d bloggers like this: