thanks for sharing of all these snippets but how did you wired your ESP board???
E.g. i’m using a battery shield. It gives me exactly 5V. Perfect to power my esp. I’m created my own circuit divider with 2 resistant and wired it directly to the battery and A0 of my ESP.
Did you do it differently??
Because, using “VCC” gives me always 100% and wiring A0 over the bat. shield the same! VCC is the internal power isn’t it? And wiring about the battery out pols to A0 is also always 100% because it ensure, that the battery always gives the right power supply.
Neither VCC nor A0 wired over bat. shield decrease over the time…different when I wired A0 over the circuit divider to the battery directly!
I am really late to the forum, but I have a question.
I recently received a gift of dozens of components from a friend. Among the pile of stuff is like 30 adafruit LC709203F Battery Fuel Gauge. I have played with the dev board and it seems to be a little more precise than setting up a pin to the battery with voltage divider. My problem, is I have no idea how to use it with all my devices that are all ESP32 based.
Could someone who knows hook me up with a suggestion of what to do? I see that adafruit’s “whipper snapper” or AFIO has usage for this so it has to be possible…
Maybe a custom sensor…but again I don’t know how to do that, and I can’t find a how to that is specifically adding a i2c sensor that does not have a pre-built platform.
but when using a volts meter it’s 4.1 volts still.
what am I doing wrong???
[19:47:26][D][sensor:093]: ‘A0 Voltage of 3.7V’: Sending state 3.70000 V with 3 decimals of accuracy
[19:47:26][D][sensor:093]: ‘Battery_Percentage’: Sending state 100.00001 % with 0 decimals of accuracy
my battery is currently at 4.1v
I have changed 0.7 to 1.2 and now getting
[07:20:24][D][sensor:093]: ‘Battery_Percentage’: Sending state 36.95476 % with 0 decimals of accuracy
[07:20:25][D][sensor:093]: ‘A0 Voltage of 3.7V’: Sending state 3.45791 V with 3 decimals of accuracy
fyi
As I have v1.2.0 I have soldered jumper 2. Do I need any other resistor? I have seen that I might need a 130k resistor.
Depending on your resistor you might need to change the calculation. The best thing I could recommend is using a variable voltage input and try to see what the raw input is on A0 when the voltage is 3V (with the resistor connected at all times) and then going up to 4.2V
If it says 1 at like 3.5V, try adding a higher-ohm rated resistor.
ok I will need to invest in a variable voltage power supply.
This is what I found on the internet. could this help me?
The new battery shield
There now is a new version (V1.2.0) of the battery shield that has an inbuilt resistor connecting A0 to the battery, through Jumer J2 (‘Jumper’ being a big word for 2 solderpads), so if you want to measure the battery voltage, all you need to do is to put some solder connecting J2
However, rather than a 100k resistor, a 130k resistor was used. The voltage divider thus becomes 100/(130+220+100), so for a full reading of 1023 (=1Volt on A0) a total of (1/100k)*(130+220+100)=4.5Volt would be necessary.
In reality the Lipo cell will not give off 4.5Volt.
The best way to check is to use a multimeter, or at leat a meter to measure the ohm rating. Some D1 mini boards don’t work quite well with the A0. I’ve had mine die after a year. At this point the battery voltage was always 0…
Try to measure with and without a battery connected.
You could be overvolting the A0, which might cause damage.
These test where performed without any additional resistors.
Without Battery
ok so testing from the bat+ to A0 with the D1 Mini v3.0.0 disconnected = 129.4
when connecting the battery shield and the d1 mini wemos v3.0.0 it starts at about 90 and then counts up. i got to 116 something and it was still going. (takes a while to get there
With Battery
testing from the bat+ to A0 with the D1 Mini v3.0.0 disconnected = 129.3
connecting the d1 mini Wemos V3.0.0 together i get 20.36
Hi All
I see this tutorial very interesting for this purpose Power ESP32/ESP8266 with Solar Panels and Battery | Random Nerd Tutorials
It’s explain well how doing Solar Panel + Battery level sensor for ESP32/ESP8266… but formula is for Arduino and not for ESPHOME Yaml Code… so If someone could make it because I’m begener with ESPHOME…
Alexandre from France
so i am struggeling with the same problem…
i have an esp8266 running with a battery shield 1.2.0. I did solder the J2 “jumper” and should now have a 130K resistor between battery+ and A0.