[newbie] On/off switch to handle battery? - Page 1
Forum section: electronics / general

author: Winfried
author_rank: Contributor
timestamp: September 23, 2022, 12:06:48 am
content: Hello,Lilygo's TTGO T-Displayhas a JST plug so that the board can be powered by a battery… but the board has no on/off switch.I have a couple of questions:1. What(compact) on/off switchcan I use to have the battery power the board? Do I need a four leg switch (red + black from the battery to the board, red and black from the switch to the JST)?2. When the board is powered by USB, will it recharge the battery after I set the switch to ON?Thank you.

author: ledtester
author_rank: Super Contributor
timestamp: September 23, 2022, 12:39:52 am
content: Quote from: Winfried on September 23, 2022, 12:06:48 amYou don't need to use a DPDT switch if that's what you're asking. You only need to break either the red or black connection.This inline JST power switch might work for you if the pitch of the connector is the same:https://www.amazon.com/JST-2-pin-Extension-Cable-Switch/dp/B01M9AAUEMAlso see this reddit thread:https://www.reddit.com/r/esp32/comments/jq9zev/how_to_power_off_ttgo_tdisplay_while_charging/QuoteYes - it will be the same as if the battery is connected.

author: Winfried
author_rank: Contributor
timestamp: September 23, 2022, 12:40:27 pm
content: Thanks. I'll see if I can find a compact switch to fit the tiny TTGO board.https://learn.adafruit.com/on-slash-off-switches

author: DavidAlfa
author_rank: Super Contributor
timestamp: September 24, 2022, 11:01:34 am
content: Check the schematics! Yeah, it has built-in charger...https://github.com/Xinyuan-LilyGO/TTGO-T-Display/blob/master/schematic/ESP32-TFT(6-26).pdfThe LDO has a quiescent current of just 55-80uA, that's at most 2mAh every day, even a really small 100mAh battery should last for weeks.However the schematic has some features that are wasting power.R32 (100K) will consume another 40uA, isn't really needed, can be removed.R25 (10K) will waste about 300uA when turned on, doesn't need to be that low, should work fine with 220K.Actually the esp32 needs to set IO14 high to work from batteries (PWR_EN pin), so it won't turn on unless it's connected from USB power first?The main program starts, enables the output and then USB power can be removed.Once it booted at leats once, it might go into sleep mode while keeping the pin high.Anyways sleep still consumes some power, not optimal.You could make a very simple hardware mod to make it switch on and off.- Add a push button between R28 and GND, as in attached picture.- Read a button in software and use it as power-off button switch, turning IO14 low when detecting a long press on this button.- Enable IO14 in the initialization code, but add a delay of 500mS first, this will prevent any noise from turning on the board, so the user must press the button for at least 500mS to ensure power-on.

author: mikerj
author_rank: Super Contributor
timestamp: September 24, 2022, 01:10:28 pm
content: Quote from: DavidAlfa on September 24, 2022, 11:01:34 am"BAT" and "3V3" are switched outputs controlled by IO14. "VBAT" is the supply rail from the battery, and the board runs as soon as the battery is plugged in.

author: DavidAlfa
author_rank: Super Contributor
timestamp: September 24, 2022, 08:23:18 pm
content: You're right, I missread the schematics.Moving the esp32 power from vdd3v3 to v3v would completely turn it off and work as I said.Q6 should be ok with it, it's a si2301, capable of almost 3Amps.

author: Winfried
author_rank: Contributor
timestamp: September 25, 2022, 09:21:25 am
content: Thanks. That's way above my head. A plain switch seems a much easier path to the goal.