I had this code generated by a chatbot, so it might be incorrect. It does create two sensors that show values, but the output for battery percentage (Akkustand in %) seems weird to me. Please take a look
LiPo battery voltage range is 3-4.2V from empty to full. You can’t read that directly with esp32, which has ADC capable of reading max ~3.1V. And giving >3.6V to any pin will eventually damage it.
You need ~1:2 voltage divider to scale down the battery voltage.
Thanks everybody. I guess don’t trust chatgpt I assumed that it was correct when it told me the Lolin32 Lite was capable of measuring the voltage directly without having to connect additional GPIO.
Also, my boards polarity was reversed to the JST battery connector. I am giving up on this project for now.
You’re absolutely right. But it feels like this project was doomed from the start.
I wanted an “is there still enough water in the dogs’ bowl” sensor with battery / without the need to be connected via any power cable.
It suggested capacitive stuff with copper foil. That did not work as expected.
Then, it recommended the Lolin32 Lite because “it would support any JST battery pack and allow measurement of energy / calculating how much capacity is left in the battery out of the box”. Which doesn’t seem to be the case.
Then the polarity was wrong with multiple battery packs that I tested, which is pretty weird.
Finally, I remembered I could use contact-less water sensors, which I still had lying around. But then realized they needed 5V to run, while all the battery packs I found only provided 3.7V tops. Yeah, step up etc., but all these occurrences combined made me think perhaps I should just look at the water bowl every now and then and have this one thing not be automated. Maybe I’ll get back to it when I got more time and space to work on this project…
Just wait for the dogs to be so desperately thirsty that they inform me by barking? Don’t really see what’s so bad about AI if people come up with solutions like this without it.