In the previous tutorial i put forward some ways in which batteries connected in series and parallel can be monitored individually. Each battery voltage can be measured separately and smartly through those methods. In this tutorial i thought to implement one method practically to show how it works in the real world. So the scenario is four batteries are connected in series string array. Individual battery is rated at 12 volts and 100 amperes. Recall in series combination of batteries voltage ads up. So total voltage of 4 batteries connected in series becomes 48 volts and this 48 volt is utilized by your ups to power your house in case of power failure. We are interested in measuring the voltage of each battery.
Arduino cluster of batteries monitoring – project overview
Circuit diagram of the project is below. Four voltage dividers method is used to measure a cluster of four dc batteries. Resistance values of all four voltage dividers are calculated using the technique discussed in the previous tutorial. I highly recommend to take the previous tutorial to know about the technique and how resistance values are calculated in this scenario. Take the below tutorial.
Arduino voltage divider battery voltage monitoring – circuit diagram
Arduino uno four analog channels are used to measure four batteries. Note the ground of all the four voltage dividers and arduino are at the same level. If you do not connect the arduino ground with voltage dividers ground then the arduino adc circuit will not complete up. ADC pin will become floating and it will read raw and wrong voltage values. So please make sure to ground all the necessary grounds.
Arduino series battery monitoring – project code
After circuit coming to the code portion. First i calculated the ratio factors for each voltage divider circuit. R1, R2, R3 and R4 are ratio factors for respective voltage dividers. After ratios comes the readvcc function. This function is actually about configuring the arduino to accurately read its applied power voltage. Imagining arduino works on 5 volts is not necessary all the time. It may be working on 4.8 or 4.7 volts. May be our power supply to arduino is supplying 4.8 volts and we are considering it 5 volts. Usually arduino is powered through laptop/work station USB port and USB port is not truly outputting 5 volts. Its output is between 4.6 to 5.3 volts. Any how the readvcc function give us back the true arduino applied power or power on which it is working. This reading is further used in translating the arduino analog channel read value to actual voltage.
In the setup function i initialized the serial communication port or arduino serial monitor. Communication speed is set to 9600 bps. In the loop function some variables are initialized for further use in the code. Than arduino reference voltage is calculated. After reference voltage individual analog channels are read one by one. Next the raw values read at the analog channels are converted to 5 volt range. Further the statements
B4Voltage = RealBat4V * R4; //Calculating actual voltages
B3Voltage = RealBat3V * R3 – B4Voltage;
B2Voltage = RealBat2V * R2 – B4Voltage – B3Voltage;
B1Voltage = RealBat1V * R1 – B4Voltage – B3Voltage – B2Voltage;
are calculating the actual battery voltage. These battery voltages are then printed on the serial monitor of arduino ide. Two seconds delay at the end of the code prevents the arduino from overloading and give its analog channels and serial monitor some rest. You can skip the delay function, code still works. But its wise to give some delay at the end to pause calculations.
Make battery and arduino uno connections. Now just upload the code to arduino uno. Please make sure to select the right board before uploading the code to arduino uno. Open arduino serial monitor from arduino ide. You will see battery voltages displayed on arduino serial monitor. If you did not see any thing on arduino serial monitor watch for the baud rate and set it to 9600 bps. If still you did not see and thing watch the analog channel connections. Check for every possible error.
The code is modular and can be transferred to any other arduino board with little modifications in code or may require no modification.
If you are interested in IOT field than the same but little complex project on monitoring battery voltage over WiFi with nodemcu WiFi module is for you. Tutorial link is below
The code is modular and can be transferred to any other arduino board with little modifications in code or may require no modification.
If you are interested in IOT field than the same but little complex project on monitoring battery voltage over WiFi with nodemcu WiFi module is for you. Tutorial link is below
Download the project code. Folder contains project .ino file. Please give us your feed back on the project and in case you have any questions or queries. Write them below in comments section.
Filed Under: Arduino Projects, Microcontroller Projects
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.