I am trying to make a simple LED based gauge to show the battery percentage on an ESP32. The idea is when there are 4 LED that are all on at 100%, 3 on at 75% and so on. I have tried multiple setups using voltage dividers and even bought a gravity I2C fuel gauge but for the life of e cannot get it to work. Is there a way to make this happen?
Thanks man, the gauge itself will have a switch attached so the LEDs will only be on when I want to check the battery (it is on a mouse glove so I dont need it on all the time.) I am able to get a reading from this setup (https://www.pangodream.es/esp32-getting-battery-charging-level) but it fluctuates too much to get an accurate reading. Really I am just wondering if it is possible to get an accurate battery percentage for this and future projects.
That fluctuation is probably due to your wiring picking up noise / mains hum.
You are likely to be measuring a DC voltage with 50Hz/60Hz superimposed on it.
The ADC takes an instantaneous reading at some random point in the mains cycle, giving a reading which can be higher or lower than the actual voltage.
Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.
Repeated cross-posting can result in a suspension from the forum.
In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.