Determine power source on TTGO T7 v1.5
I'm working on a project using the TTGO T7 v1.5 board, using the Arduino IDE. When the board is running only on battery power, I want to be able to turn off some devices that use a lot of power. However, I'm not sure how to detect whether the board is running on battery power or on USB/wall power.
I took a look at the schematic for the board but I'm a complete novice when it comes to electronics, so I couldn't figure anything out from that.
Is it possible to detect which power source the board is using in software? If so, how can I do that?
teastain2 last edited by
@turaiel There is no way to tell whether battery or USB!
If you are plugged in to USB, then you are running on USB and the battery is charging. When you unplug USB it will re-boot and run on battery.
The Radio is the biggest consumer especially during transmit.
Thanks for that info.
For anyone else that stumbles across this in the future: what I ended up doing was setting up a simple voltage divider (https://randomnerdtutorials.com/how-to-level-shift-5v-to-3-3v/) and connecting the 3.3V output as an input to one of the GPIO pins, set to pull down.
When the TTGO board is running on battery, the 5V pin I'm using for input from the external power supply becomes a 5V output, which backfeeds into the 5V rail I'm using to detect external power. To solve this, I put a diode between the external power rail and the 5V pin on the TTGO board. This does result in some voltage loss when operating on external power, so I've been advised to use a Schottky diode instead, but I haven't tried that yet.
So far, so good!