Real time graph – Warning may appear to freeze your browser as it downloads data points from Thingspeak – assuming the system is still running – started 2016-9-1 😉 This is a small 110AH 12V lead acid battery charged by about 200W solar panels – the spikes in charging are from clouds going by + the cheap PWM charging regulator 🙂
Since initially creating this page I have realized that the D1 Mini NodeMcu I used contains a built in voltage divider so as to make the A0 pin compatible with 3.3V full scale input… Hence all the values below have a 3x margin built in and could be used with 3 times the voltage input. Here is the schematic of the D1 Mini.
Using internal 220K/100K divider with an additional 10Mohm resistor in series with the input the formula for the ESP Easy is: %value%*0.1093
And the input voltage can go up to 100Volts.
For 20V max input (12V battery system) Calculator + another Calculator
Divider = 22K and 1.3K resistor
ESPEasy formula for analog input: %value%*0.0606
12V = 12V
13.7V = 13.7V
Ideas for future improvement:
Resolution with the ESP8266 10bit 0-1V input ADC with my current resistive divider comes to about .06V – good enough for battery monitoring but could be better
One way to improve resolution would be to use a 10V Zener diode in series with the 12V input measurement voltage, this would remove any voltage below 10V which is not necessary for 12V lead acid battery monitoring.
DIODE ZENER 10V 250MW SOT23 – for 12V battery monitoring.
DIODE ZENER 43V 250MW SOT23 – for 48V battery monitoring – keep in mind the DC-DC and voltage divider need to support 60V max input
7 thoughts on “ESP8266 Battery Voltage Monitor Simple”
Thanks for the info. If I wanted to measure a fully-charged lipo (4.2 volts) what would I need to add in line (series) with the wemos d1 mini A0 pin?
To figure out what resistance you need you can use this calculator : https://www.daycounter.com/Calculators/Voltage-Divider-Calculator.phtml
You would fill in the values like this:
Input voltage = 4.2V
Output Voltage = 1V
R2 as 100K because the D1 has 100K to ground as shown in its schematic here: http://hilo90mhz.com/wp-content/uploads/2016/09/d1_mini.pdf
The output should give you 320K for R2 ohm and since the D1 mini already has 220K ohm as R2 you only need to add an additional 100K in series with A0 pin to have 4.2V full scale. You may want to add 120K ohm to have a little bit more leeway on the max votage measurement.
Let me know if you have any other questions.
Do you have a arduino sample sketch you could share showing this?
Hi David, Sorry for the late reply, the firmware is not my creation, it is running the awesome ESPEasy https://www.letscontrolit.com/wiki/index.php/ESPEasy
Chester thank you so much for this post. I took your suggestion and used a 10Mohm resistor on my D1 mini to measure the voltage of a car battery. once fired up I get 8 as a readout with nothing connected (before any correction or math) Then when I apply a 12V connection to the resistor i get a 24-26 Read out. with your math suggestion of %value%*0.1093 this doesnt get me close to the 12v I was hoping for. Any ideas? Thank you again.
Hi Ryan, I am not sure what the problem is.. maybe your board has a different internal resistor? you could check that, or try a divider that makes sense for you, like .5 – and test it at different voltage inputs to see if it is valid.
Very interesting, I did similar with Domoticz as the main server to store data and a ADS1115 Voltage monitor https://www.youtube.com/watch?v=rpFmTUszNPI&t=749s Setup for 24V, I found that a capacitor across the voltage divider helped get rid of spikes in my setup. Thanks for sharing.