Hey There,
thank you for this workaround. I hope ESPHome will have that sooner than later implemented itself.
I did what you wrote and created the costumization:
It did show up as a battery under devices correctely for a short time (until some variable updates in HASS i guess) and then it turned back to the default “Eye” Icon.
Does someone know why that happens?
Best regards
Florian
thanks for sharing your settings, was very useful.
May I ask you a question? why did you add the templeate voltage if you already had the adc sensor for it?
Well I probably added it while testing and never removed it… so yeah haha! There are always easier ways to do it, but I am just too lazy to make the code as efficient as possible
Edit: I actually never figured it would also be in Home assistant… Appears like they do! Now I got 2 sensors with the same value in Home Assistant. Oops!
Can I ask for help with the formula? I’m using an ESP32 board with an 18650 lipo battery
The max voltage should be around 4.2, and the suggested min voltage should be 2.95
I adjusted the formula to this
return ((id(ESPBat).state-2.95) /1.25 * 100.00);
it returns values as 0.4xxx, it seems that I’m doing something wrong with the multiplier
3v is the minimum voltage for the esp chip to work so you should consider that value as a 0%
However you can make a test to see at what voltage the chip will shutdown, but consider that is not reccomended to drain the battery voltage to its limit.
Keeping the voltage between 20%-80% will make the battery life last longer.
Understood, but I changed the formula because this is the result
[12:13:55][D][sensor:113]: 'sim7600e Battery Percentage': Sending state -199.52148 % with 0 decimals of accuracy
[12:13:56][D][sensor:113]: 'sim7600e Battery Voltage': Sending state 0.44808 V with 2 decimals of accuracy
Do you guys see anything wrong with this configuration?
I am planning to use a 3.7V LiPo battery but in the meantime I am using a 3.3V power supply. So I am considering the battery range to be min voltage 3.0V and max 3.7V
With the following code I was expecting a 42% result for a 3.3V input, but I am getting 100%.
I figured out the problem. I had connected the A0 straight to the 3.3V instead of connecting it through a voltage divider such that 3.7V supply corresponds to 1V ADC.
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.