Arduino Projects

Wireless Battery Voltage Monitoring using Arduino, NRF24L01, & Bluetooth

Long Range Wireless Battery Voltage Monitoring, Description:

 

Long Range Wireless Battery Voltage Monitoring– In this tutorial, you will learn how to make a Long Range Wireless Battery Voltage Monitoring system using Arduino, HC05/HC06 Bluetooth Module, NRF24L01 Transceiver Modules, 0-25v Voltage Sensor, and Android Cell Phone Application.

Wireless Battery Voltage Monitoring

 I have been using these short range and Long Range transceiver modules in different Arduino and IoT related projects. Today we will be using together this short range HC05 Bluetooth Module with these long range NRF24L01 wireless transceiver modules, these modules give you 100 meters communication range, and if you need even more range then you can switch to the PA+LNA versions of the NRF24L01 Transceiver modules, which has the maximum communication range up to 1000 meters. You can either use a pair of the long range NRF24L01 PA + LNA transceiver modules, or you can use a pair of the short range NRF24L01 Transceiver modules. You can also make a pair by using the NRF24L01 PA+LNA with the regular small size NRF24L01 transceiver module. For more details you can read my article on the Long range wireless industrial temperature monitoring system.

Recently, I got an email from Stephan who is into the Film industry. I am going to share with you his email “I am planning on making an App that can monitor the voltage on film sets. We have a dozen or so batteries doing various jobs and I am curious if one assistant can monitor them all from an App. I am hoping that they can also be used to discover problematic batteries using the clock monitoring tool”.

We had a lot of discussion to find a proper solution. I also suggested him to use an Iot based battery voltage monitoring system, but he rejected this idea, because mostly they do the film shooting in areas where they have no access to the internet.

 Then I offered him the easiest solution which is to use a Bluetooth module with the Arduino and monitor the battery voltage on your cell phone application”Wireless Battery Voltage Monitoring using Bluetooth and Android Cell Phone Application”. This project is good if the battery is in the working range of the Bluetooth module. But we had to reject this idea due to the Bluetooth’s module short communication range.

Finally, I suggested him to bring in the NRF24L01 Transceiver modules to increase the communication range, and this way we can also use multiple transmitters to communicate with the single receiver, and this way we can monitor multiple batteries installed at different locations. As usual to keep things simpler I will start with a single transmitter and receiver so that you guys can easily understand. So, before I am going to explain the working, making, and programming, first a few words about the sponsor of this video for sending me these quality PCBs.



About the Sponsor, ALLPCB:

Wireless Battery Voltage Monitoring

24-Hours Lead Time

ALLPCB is the World’s Fastest PCB Manufacturing Company. Feel free to visit their website allpcb.com to not only find out what awesome PCB and assembly services they offer but also to easily upload your Gerber files and thus order affordable and High-quality PCBs quickly. Besides this, you will also get a 30 Dollars Coupon balance, which you can use to get your first prototype order for free.

Xmas Surprise‘s Back

Random Secret Coupon for Any Order Over $500 Before 24th December, 2020. $10, $20, $50 or $500 Coupon Immediate Use, for more information visit:

Wireless Battery Voltage Monitoring

In this tutorial, you will learn how to make a long range wireless battery Voltage monitoring system using Arduino Nano, 0 to 25V Voltage Sensor, HC05 Bluetooth Module, and the Long Range NRF24L01 Transceiver modules.




Wireless Battery Voltage Monitoring

For the demonstration purposes I will measure the voltage of these 12V and 5V adaptors, the project we are designing is capable of measuring the voltages upto 25 volts. I started off by measuring the voltage using a digital multimeter, to make sure If I can read the same voltage on my cell phone App designed in Android Studio. Next, I connected the 12V power supply with the 0 to 25V voltage Sensor. Next, I powered up the receiver side circuit using a 5V regulated Power supply.

When the receiver circuit is initially powered up the small LED on the Bluetooth module blinks at a faster rate, which means that the Bluetooth module is not connected with the android cell phone application. I have already paired this Bluetooth Module with the cell phone and its ready to be used with the android cell phone Application.

You will need the Android cell phone application, which is available for the download.

Download APK file:

Download and install the cell phone application. Before you open the cell phone app, first of all, make sure your Bluetooth module is paired with the cell phone, otherwise you won’t see your Bluetooth module in the paired devices list in App.

  • Open the android cell phone Application.
  • Click on the search for paired devices.
  • In the list select your Bluetooth Module and finally click on the connect button.

When the App is connected with the Bluetooth, the LED will start blinking at a slower rate, and you will also see battery voltage in the App.

Wireless Battery Voltage Monitoring

The value is approximately the same, you can adjust this value by changing the correctionfactor value, which I will explain in the programming. There is no physical connection between the receiver side and the transmitter side. If the transmitter is turned OFF or you are not the in range the Connection Last message will be printed.




Wireless Battery Voltage Monitoring

At this point you can go and check your transmitter Module if it’s working properly and you can also check the range. Anyhow when you turn ON the transmitter and the other transceiver module is in the range, you will again start receiving the data. The receiver side is completely portable and wirelessly communicates with the android cell phone Application through the Bluetooth Module. So how exactly this works?

The Arduino reads the voltage sensor which is connected with the Battery and the Arduino then sends this data with the help of NRF24L01 to the receiver NRF24L01 Module, and then the Arduino takes the data and then the Arduino through Bluetooth Module sends this data wirelessly to the Android cell phone application. I kept performing the experiments, with this project you can monitor voltages between 0 and 25 volts, this time I am going to measure the voltage of a 5v adaptor. This is not exactly 5 volts adaptor, the output of this adaptor fluctuates between 5.1 and 5.3 volts.

Wireless Battery Voltage Monitoring

Perfect I am getting the same exact voltage.

Now to test the range, I kept the receiver away from the transmitter circuit, and I am still receiving the data without any problem. Now, again I am going to connect the 12V adaptor.

Wireless Battery Voltage Monitoring

This time you can see the 12 Volts. I kept performing the tests, the receiver circuit I placed at a different location away from the transmitter and then I was away from the receiver circuit, and still I was able to monitor the voltage without any problems. I am sure you have got the idea of what you are going to learn after reading this article.

Without any further delay, let’s get started!!!



Amazon Purchase Links:

NRF24L01

Bluetooth Module: Hc-05:

Voltage sensor 0-25v:

12v Adaptor:

Arduino Uno

Arduino Nano

Other Tools and Components:

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!

Wireless Battery Monitoring, Transmitter Circuit Diagram:

Wireless Battery Voltage Monitoring

This is the transmitter side circuit diagram. The VCC and GND pins of the NRF24L01 module are connected with the Arduino’s 3.3V and GND pins. A decoupling capacitor of 10uF is also connected between the VCC and GND pins. CE pin is connected with Pin9, CSN is connected with the Pin10, SCK is connected with pin13, MOSI pin is connected with Pin11, and the MISO pin of the NRF24L01 Transceiver module is connected with the Arduino’s Pin12.

The S pin of the 0-25v Voltage sensor is connected with the Arduino’s Analog pin A0, the + Pin is not connected, while the – pin is connected with the Arduino’s ground. The VCC and GND contacts of the voltage sensor are connected with the Voltage source you want to monitor. Make sure the voltage you are monitoring does not exceed 25 volts.



Wireless Battery Monitoring, Receiver Circuit Diagram:

Wireless Battery Voltage Monitoring

This is the Receiver side circuit diagram. The NRF24L01 Transceiver module connection with the Arduino remains exactly the same. The +5V and GND pins of the Bluetooth module are connected with the Arduino’s 5V and GND pins. The TX pin is connected with the Arduino’s RX pin while the RX pin of the Bluetooth Module is connected with the TX pin of the Arduino.

NRF24L01 Development Board PCB Design:

Wireless Battery Voltage Monitoring

I designed a development board for the NRF24L01, which I can use with both the transmitter and receiver sides. I added these extra holes on the left and right sides for soldering other electronic components. I also added female headers for the 5V, GND, Analog and other I/O pins. This way I can easily interface other input and output devices. I double-checked all the connections and once satisfied; I generated the Gerber files and placed an online order on the ALLPCB official website.

Download Gerber Files

Wireless Battery Voltage Monitoring

These are the PCBs I received from the ALLPCB Company. As you can see the Quality is really great, the silkscreen is quite clear, and the black color soldermask looks amazing. Next I started off by placing the components and completed the soldering job.




Wireless Battery Voltage Monitoring

Both the circuits are exactly the same, at this point you have to decide which one you want to use as the transmitter and which one you want to use as the receiver. I randomly selected one of these circuits and decided to use it as the receiver. So, I soldered female headers for the Bluetooth Module and soldered some wires are per the circuit diagram already explained. Next I added the Bluetooth Module and with this our receiver circuit is completed.

Wireless Battery Voltage Monitoring

Next we are going to connect the Voltage Sensor with the Transmitter circuit, for this I will need to solder female headers for the 5V and GND connections, so that I can easily interface the Voltage sensor. Finally, Connect the S pin of the voltage sensor with the A0 pin and connect the – pin with the GND of the Arduino. Now you can connect the VCC and GND contacts with the voltage source you want to monitor.  I connected the female dc power jack with the VCC and GND contacts of the Voltage Sensor, this way I can easily connect the Voltage adaptors for the testing purposes.

Wireless Battery Voltage Monitoring

Our transmitter side is also ready, make sure the voltage you want to monitor does not exceed 25 volts. So, finally the transmitter and receiver circuits are ready for the programming.



Long Range Wireless Battery Voltage Monitoring Arduino Code:

Wireless Battery Voltage Monitoring

This long range wireless battery voltage monitoring system is based on two programs. One program is written for the Transmitter side while the other program is written for the Receiver side. Before you start the programming first of all, make sure you download all the necessary libraries from my website electroniclinic.com I will provide a link in the description. First let’s start with the Transmitter side programming.

Battery Voltage Monitoring Transmitter Code:

//Transmitter coding for the nrf24L01 radio transceiver.
//NRF24L01, Bluetooth and Arduino based Battery voltage monitoring System
//https://www.electroniclinic.com/
/*
pins connections

vcc 3.3
gnd gnd
ce pin9
scn pin10
sck pin13
mosi pin11
moso pin12

*/
#include <SPI.h>
 #include <nRF24L01.h>
 #include <RF24.h>
 #define CE_PIN 9
 #define CSN_PIN 10
 #define v_sensor A0 // voltage sensor connected with A0, connect S pin of the Sensor with A0 pin of the Arduino
 
const uint64_t pipe = 0xE8E8F0F0E1LL;

RF24 radio(CE_PIN, CSN_PIN);
float data[6]; // depending on the number of sensors used, if you are sure your sensor values are integer then you can define it as the byte.

// for the voltage sensor 0-25V
float correctionfactor = 0.30;
float vout = 0.0; 
float vin = 0.0; 

// two resistors 30K and 7.5k ohm used in the voltage sensor
float R1 = 30000;  //   
float R2 = 7500; //  
float value1 = 0.0;

void setup()
 {
 Serial.begin(9600);
 radio.begin();
 radio.openWritingPipe(pipe);
 pinMode(v_sensor,INPUT);

 }

void loop()
 {


 // read the value at analog input 
   value1 = analogRead(v_sensor); 
   vout = (value1 * 5.0) / 1023.0; 
   vin = vout / (R2/(R1+R2));
   vin = vin - correctionfactor; 
   
data[0] = vin; 
radio.write( data, sizeof(data) );
 }

This is just a basic program, that reads the voltage sensor and then send the voltage value to the Receiver circuit. Maximum of the code I have already explained in my getting started tutorials on the Voltage Sensor and the NRF24LO1.

If you take a look at this line of code

float data[6];

data is an array. Let’s say if you have multiple sensor then you can store the sensor1 value at location data[0], sensor2 value can be stored at the location data[1], and so on.

If in case you are using multiple transmitter than what you can do, at location data[0] store a specific number which you can use as the identifier, let’s say 345, and then at the location data[1], you can store the sensor value. Similarly for the other transmitter you can store a different identifier value let’s say at data[0] = 675, and then at data[1] location you can store the sensor value.

Now on the receiver side, you can access these values, if you see the value 345 it means the data is sent from the first transmitter, and if you see the value 675 then it means the value is sent form the 2nd transmitter, you can use if conditions to compare the values.

For now the only thing that you need to focus on is the correctionfactor value. You can adjust this value if the measured value is a bit off from the voltage source value. Let’s say if the battery voltage is 12.3 and on the Arduino you are reading 12.4 then you can simply replace this value with .1.

Now, let’s take a look at the receiver side programming.


Battery Voltage Monitoring Receiver Code:

//Receiver coding for the nrf24L01 radio transceiver.
//NRF24L01, Bluetooth and Arduino based Battery voltage monitoring System
//https://www.electroniclinic.com/
/*
pins connections

vcc 3.3
gnd gnd
ce pin9
scn pin10
sck pin13
mosi pin11
moso pin12

*/
#include <SPI.h>
 #include <nRF24L01.h>
 #include <RF24.h>
 #define CE_PIN 9
 #define CSN_PIN 10
 
 const uint64_t pipe = 0xE8E8F0F0E1LL;

RF24 radio(CE_PIN, CSN_PIN);
float data[6]; // depending on the number of sensors used

unsigned long lastReceiveTime = 0;
unsigned long currentTime = 0;


void setup()
 {
 Serial.begin(9600);
 delay(1000);
 Serial.println("Nrf24L01 Receiver Starting");
radio.begin();
 radio.openReadingPipe(1,pipe);
 radio.startListening();
 resetData();
 }

void loop()
 {
 if ( radio.available() )
 {
 bool done = false;
 while (!done)
 {
 done = radio.read( data, sizeof(data) );
 lastReceiveTime = millis(); // At this moment we have received the data
 
Serial.println("Battery_Voltage:"); 
Serial.println(data[0]);

delay(500);

 }


 }
 else
 {
currentTime = millis();
if ( currentTime - lastReceiveTime > 1000 ) { // If current time is more then 1 second since we have recived the last data, that means we have lost connection
resetData(); 


 }
 }
 }
 
void resetData() 
{
// we are going to place our default code over here. 
Serial.println("Connection Lost");
}

This is the same exact code from my previous project based on the Sensors monitoring using NRF24LO1. The purpose of this code to receive the data from the transmitter and then send it to the android cell phone app using a Bluetooth Module. The Bluetooth module is connected with the Arduino’s default Serial port. So, that’s why I am using the same Serial.println() functions. Remove the Bluetooth Module while upload the code, otherwise you will get an error.


Android Application:

I have a very detailed tutorial on how to design your own Android cell phone application, the android cell phone App apk file download link is already given above.

Watch Video Tutorial:

 

 

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...

One Comment

  1. Hi in your circuit diagram you also show one capacitor is being used however in the picture of your completed circuit you have 4 capacitors being used , could you explain where the capacitors are connected to ?

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button