Close

Battery voltage measurement

A project log for ESP32 Small Alarm Clock

Small alarm clock with ESP32 module, 0.96" OLED panel and small speaker.

teruteru 05/02/2022 at 11:220 Comments

Changed battery voltage measurement to measure input of voltage regulator battery voltage measurement using circuit from https://jeelabs.org/2013/05/17/zero-powe-battery-measurement/. Also display battery level on the clock screen.

Previous version measured voltage output from GPIO pin so value is capped to 3.3V, which was enough to see if battery is too low but not so nice for displaying battery level.

Fortunately it wasn't hard to modify - replace resistor between Vout and Vmes with BSS138, connect drain of BSS138 to new resistor, and connect the other side of the new resistor to vcc.

kicad image of the modification

Unfortunately, measurement didn't work. It shows greater value than correct voltage. Modification was worked fine when tested with develeopment board. It turned out that ADC of the ESP32 of the clock seems to be broken. The adc pin reads as almost 0 as expected when connected to GND, but the adc pin reads as 4095 (maximum of 12bit) when it is left open.

Discussions