Xinyuan-LilyGO / LilyGo-EPD47

GNU General Public License v3.0
381 stars 119 forks source link

How do you read the battery voltage? #13

Closed atrueresistance closed 2 years ago

atrueresistance commented 3 years ago

Looking for a way to get the battery percentage from the board. I looked at the buttons example you posted and I see you defined #define BATT_PIN 36. Can this be used to read the battery voltage?

float voltage = analogRead(36) / 4096.0 * 7.46; seems to come out null. Is there a way without wiring into additional GPIO to check the voltage?

fpasteau commented 3 years ago

AFAIK according to the schematics you need to have PWR_EN = 3V3 to read the battery voltage. You can do this with the epd_poweron() function. After doing analogRead, you can power off the screen using epd_poweroff().

lewisxhe commented 3 years ago

IO36 is configured as voltage detection. It uses a voltage divider of 100k ohms up and down. As @fpasteau said, you need to use edp_poweron() to enable the voltage detection function.