In this Tutorial, you will learn how to monitor the Battery voltage from anywhere around the world and control DC light bulbs and other dc loads using 12v SPDT type relays. This is an iot “internet of things” based project and is entirely based on the Nodemcu esp8266 wifi module and Blynk application. The battery voltage is displayed on the Gauge while the loads are controlled using the Numeric input buttons which I will explain in a minute. This tutorial covers
- Voltage sensor pinout and calculations
- Complete circuit diagram
- Blynk application designing and finally
Arduino Uno: https://amzn.to/2YxCle6
Mega 2560: https://amzn.to/2ze1kdu
Voltage sensor 0-25v: best offer https://amzn.to/2PcMGXY
Nodemcu esp8266 wifi module: Best price https://amzn.to/2NAvmiB
lm7805 Voltage Regulator: https://amzn.to/2IZEl5x
330 ohm resistors pack: https://amzn.to/2NtlAeh
5v 2A adaptor: https://amzn.to/2GsNfcw
2n2222 npn transistors: https://amzn.to/2EmXsIb
10k Resistor: https://amzn.to/2KTd6OW
lm7805 Voltage Regulator: https://amzn.to/2IZEl5x
330-ohm resistors pack: https://amzn.to/2NtlAeh
female DC power jack socket: https://amzn.to/2KEo1gt
470 uf capacitors: https://amzn.to/2xDCOzf
5×7 cm vero board: https://amzn.to/2OHGbvn
female headers: https://amzn.to/2zqmtiJ
connection wires: https://amzn.to/2DpBuW7
Super Starter kit for Beginners: https://amzn.to/2KJvmKG
Jumper Wires: https://amzn.to/2KMoVXs
Bread Board: https://amzn.to/2MS4q8X
12v Adaptor: https://amzn.to/2Ntr6h1
PCB plate: https://amzn.to/2IUwpCt
Variable Supply: https://amzn.to/2MT4Qfj
Digital Multimeter: https://amzn.to/2Nvft9i
Vero Board / strip board: https://amzn.to/2MTf9jD
Soldering iron kit: “best” You guys should definitely purchase this: https://amzn.to/2zfoNuJ
Solder wire: https://amzn.to/2ufUMWf
Wire Stripper: https://amzn.to/2KOqxfU
wire cutter: https://amzn.to/2ucIq14
PCB small portable drill machine: https://amzn.to/2Nu62XF
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!
0-25v Voltage sensor:
This is the Voltage sensor Module that we will be using today, This Module is capable of measuring the voltages ranging from 0.02445v to 25volts dc. But if you want to measure voltages higher than 25volts then you can watch my tutorial on how to modify this voltage sensor for monitoring higher voltages, in this tutorial I performed all the calculations.
As you can see on one side we have a block terminal, this is where we connect the voltage and ground wires coming from The battery , solar panel or any other source. The Voltage wire is connected with the vcc terminal and the ground is connected with the gnd terminal.
On the other side we have three male headers labeled as +…. , s…. and -. ……
the s pin of the sensor module is connected with the analog pin of the Nodemcu esp8266 wifi module and the – pin is connected with ground of the nodemcu module. while the + pin is not connected.
Let’s have a look at the circuit diagram of the voltage sensor,
It’s simply consists of two resistors connected in series, Which makes a voltage divider circuit. As you can see the resistors values used in this module are 30k and 7.5k. Lets perform calculations for this circuit.
maximum Input voltage of this module is 25 volts dc, but this applies when this voltage sensor is used with the Arduino, as the Arduino’s i/o pins are compatible with 5 volts. Let’s first of all calculate the output voltage of this sensor when the input voltage is 25 volts.
Vin = 25v
R1 = 30k ohm
r2 = 7.5k ohm
We can find out the Output voltage, by using the voltage divider
Vout = ( r2 x Vin ) / ( r1 + r2)
Vout = (7.5 x 1000 x 25) / (30k + 7.5k)
Vout = (7500 x 25) / 37500
Vout = 187500 / 37500
Vout = 5 Volt
so this sensor can be used with the Arduino without any problem. But it will damage the Nodemcu esp8266 module as the esp8266 is a 3.3v microcontroller, applying more than 3.6v on any pin can damage the chip.
So make sure the input voltage to this sensor never exceeds 18 volts. Always try to keep it below 18 volts. For 18 volts you will get 3.6 volts.
Enough with the voltage sensor, now let’s Discuss the complete circuit diagram.
iot battery monitor Circuit Diagram:
The 12v and ground wires of the battery are connected with the VCC and ground terminals of the voltage sensor. The minus pin of the voltage sensor is connected with the ground while the S pin of the voltage sensor is connected with the analog pin A0 of the Nodemcu module. The plus pin of the voltage sensor is not connected.
This is the 5v regulated power supply based on the LM7805 voltage regulator. J1 is the female power jack and this is where we connect the 12volts from a battery or 12v adopter or a Solar Panel. This power supply is used to power up the nodemcu esp8266 wifi module. two 470 uf capacitors are connected at the input and output of the voltage regulator. 330 ohm resistor is connected in series with the 2.5 volt led. This is a current limiting resistor.
A wire from the output of the voltage regulator is connected with the Vin pin of the nodemcu esp8266 wifi module and ground is connected with the ground.
A two channel relay module is connected with the D0 and D1 pins of the nodemcu module. These relays can be used to control the ac or dc loads. These relays are of the type SPDT “single pole and double throw”. 2n2222 npn transistors are used to control these relays. Now let’s make the cell phone application using Blynk.
iot battery monitor Blynk Application:
For the complete step by step designing watch video Tutorial “Click Here”, or you can follow the steps given below.
First of all open the Blynk application….
click on the new project and enter the project name….
click on the choose device and select nodemcu…
make sure the connection type is set to wifi…
then click on the create button, an authentication token will be send on your email id, simply copy and paste it in the programming…
Click anywhere on the screen and search for the gauge and add it…
click on the gauge…
set the name as battery voltage…
click on Pin and select virtual pin V2…
set the maximum value to 25…
change the font size then click on the push button and select 1 second…
Now again click on the screen and this time search for the numeric input and add it…
click on the numeric input…
set the title as load1…
click pin and select virtual pin V10…
set the minimum and maximum values…
10 will be used to turn off the load1 while 11 will be used to turn on the load1…
for numeric input2 set the title as load2,
select the virtual pin V11 and set the minimum and maximum values as 12 and 13…
iot battery monitor Programming:
#define BLYNK_PRINT Serial
int Vsensor = A0; // 0-25v voltage sensor is connected with the analog pin A0 of the arduino
int load1 = D0;
int load2 = D1;
//For 0-25v voltage sensor
float correctionfactor = 8;
float vout = 0.0;
float vin = 0.0;
// two resistors 30K and 7.5k ohm
float R1 = 30000; //
float R2 = 7500; //
int value = 0;
char auth = "74ba97f2a0b34bb083bbab2a635b7aa1";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid = "ZONG MBB-E8231-6E63";
char pass = "electroniclinic1";
String myString; // complete message from arduino, which consistors of snesors data
char rdata; // received charactors
int firstVal, secondVal,thirdVal; // sensors
// This function sends Arduino's up time every second to Virtual Pin (1).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V1, millis() / 1000);
// Debug console
Blynk.begin(auth, ssid, pass);
if (Serial.available() == 0 )
timer.run(); // Initiates BlynkTimer
int sdata = 0;
// read the value at analog input
value = analogRead(Vsensor);
vout = (value * 5.0) / 1023.0; // see text
vin = vout / (R2/(R1+R2));
vin = vin - correctionfactor;
Serial.print("INPUT V= ");
sdata = vin;
// in Blynk app writes values to the Virtual Pin 10
pinValue1 = param.asInt(); // assigning incoming value from pin V10 to a variable
if ( pinValue1 == 10 )
if ( pinValue1 == 11 )
// in Blynk app writes values to the Virtual Pin 11
pinValue2 = param.asInt(); // assigning incoming value from pin V10 to a variable
if ( pinValue2 == 12 )
if ( pinValue2 == 13 )