Wireless battery voltage monitor using Arduino and Bluetooth
Table of Contents
Wireless Battery Monitoring Project Description:
In this tutorial, you will learn how to make your own wireless battery voltage monitoring system using Arduino, a Bluetooth module, and an Android cell phone. This wireless battery voltage monitoring system can also be used for monitoring the Solar Panels, in fact, you can monitor anything so far the voltage that is to be monitored is less than or equal to 25volts. Recently I uploaded another article on the battery voltage monitoring system “Long Range Wireless Battery Voltage Monitoring System using NRF24L01 and HC05 Bluetooth“. This time I made a few changes, I added the long-range NRF24L01 Transceiver modules to increase the range.
Download the Bluetooth App: BlueserialApp battery
Amazon Purchase Links:
Arduino Nano USB-C Type (Recommended)
*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.
0-25v Voltage Sensor:
This is the Voltage sensor Module that we will be using for monitoring the battery voltage, 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. You can find that video on my YouTube channel.
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 will be connected with the analog Pin of the Arduino Uno or Mega and the – Pin will be connected with the ground of the Arduino. while the + Pin is not connected.
as in the beginning, I said that we can measure dc voltages ranging from .02445volt to 25volts. Now the question is how we know that the input voltage should be greater than .02445volts.
As you know my friends,
The maximum Arduino analog input voltage is 5 V
and we know that
Arduino AVR chip has 10 bit AD “Analog to digital converter” So
5 / 1023 = .00489 resolution
So
.00489 x 5 = .02445 volts. So
the input voltage of this module should be more than .02445 Volts.
Let’s have a look at the circuit diagram of the voltage sensor,
It simply consists of two resistors connected in series, which makes a voltage divider circuit. A few days back I uploaded a tutorial on Electronics Voltage Divider Circuit Basics, Practical use of Voltage divider, Datasheet & calculation. I recommend you should watch this tutorial for the best understanding.
As you can see the values of the resistors used in this module are 30k and 7.5k. Let’s perform calculations for this circuit.
the maximum input voltage of this module is = 25 volts dc. so
Vin = 25v
R1 = 30k ohm
r2 = 7.5k ohm
we can find out the Output voltage, by using the voltage divider formula which is
Vout = ( r2 x vin ) / ( r1 + r2)
vout = (7.5 x 1000 x 25) / (30k + 7.5k)
vout = 187500 / 37500
vout = 5 Volt
if we increase the voltage above 25v the output voltage will increase and so will damage the analog Pin of the controller. So with these resistor values, we can monitor voltages up to 25v maximum.
Let’s find out the Current.
using ohm’s law
v = IR we can find the current
I = V / R
I = 25 / ( 30k + 7.5K)
I = 25 / 37.5K
I = .000666 amps
which is equal to
I = 666 micro amps.
So as the resistors are connected in series so the same current will flow through both the resistors. as the current is in microamps it won’t heat up the resistor. Enough with the voltage sensor, now let’s talk about the Bluetooth module.
Bluetooth Module used in the wireless battery monitoring system:
This is the Hc-05 Bluetooth module, it doesn’t matter if you use Hc-05 or Hc-06. I have a very detailed tutorial on how to change Pin code or password and how to change the name of a Bluetooth module using At commands. So if you want to change its default name and password then you should definitely watch this tutorial.
As you can see I have already soldered some jumper wires for the easy interfacing with Arduino or mega. This module has a total of 6 Pins labeled as state…..RXD…..TXD…..GND….VCC …… and wakeup.
The wakeup Pin is used for entering the Bluetooth module into the AT command mode. the use of wakeup Pin is already explained in that tutorial. So out of these 6 Pins, we will be using only 4 Pins. RXD….TXD….GND… ANd VCC.
Circuit Diagram of the wireless battery monitoring system:
This is the complete connection diagram of the wireless battery voltage monitoring system using the Arduino and Bluetooth module. As you can see on the left side, the voltage sensor VCC is connected with the Battery 12v input and the ground of the voltage sensor is connected with the ground of battery. The s Pin of the voltage sensor is connected with the analog Pin A1 of the Arduino and the “ – “ Pin is connected with the Arduino’s ground. While the + Pin is not connected.
The HC-05 or HC-06 Bluetooth module VCC Pin is connected with Arduino’s 5 volts, the Ground Pin of the Bluetooth module is connected with the ground of the Arduino. The Txd Pin of the module is connected with Pin2 of the Arduino and rxd Pin of the Bluetooth module is connected with Pin3 of the Arduino. The Bluetooth module communicates with the Arduino through serial communication, as you know in Arduino we have only one serial port available on Pin0 and Pin1. We will use the Arduino’s default serial port for the debugging purpose and make another serial port using Pin2 and Pin3. I will explain this in programming how to make a serial port.
Wireless Battery Monitoring Arduino Programming:
The Programming of the wireless battery voltage monitoring system is very easy. This program will also Run on Arduino Mega. For the detailed step by step explanation, you can watch video Tutorial given at the end of this Program.
1 |
#include <SoftwareSerial.h> |
as you know my friends that the Bluetooth module communicates with the Arduino through serial communication, and you know that in Arduino we have only one serial port which is on pin number0 and pin number1. as I always say that use the Arduino default serial port for debugging purposes. So if we are using Arduino’s default serial port for debugging purposes then it means we will be needing one more serial port for the Bluetooth module. So for this purpose, we are using the SoftwareSerial library. if you want to learn in detail how to use SoftwareSerial library for making multiple ports then watch my tutorial on SoftwareSerial.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
SoftwareSerial blue(2,3); // Bluetooth module connected here float correctionfactor = 0; int analogInput = A1; float vout = 0.0; float vin = 0.0; // two resistors 30K and 7.5k ohm float R1 = 30000; // float R2 = 7500; // int value = 0; void setup(){ PinMode(analogInput, INPUT); Serial.begin(9600); blue.begin(9600); } void loop(){ // read the value at analog input value = analogRead(analogInput); vout = (value * 5.0) / 1023.0; // see text vin = vout / (R2/(R1+R2)); vin = vin - correctionfactor; Serial.print("INPUT V= "); Serial.println(vin,4); blue.print("Battery Voltage: "); blue.println(vin,4); delay(1000); } |
Watch Video Tutorial:
Another related Project:
Esp8266 Iot battery monitor, battery voltage monitoring using nodemcu esp8266 wifi module
It’s not my first time to go to see this web page, i am visiting this web page dailly and obtain nice data from here all the time.|
softwear serial dose not name a type that’s what I get when trying to upload code.
You have to Include Line 1 such as #include <SoftwareSerial.h> also change Pinmode to pinmode.