EEVblog Electronics Community Forum

Electronics => Microcontrollers => Topic started by: Winfried on September 23, 2022, 12:06:48 am

Title: [newbie] On/off switch to handle battery?
Post by: Winfried on September 23, 2022, 12:06:48 am
Hello,

Lilygo's TTGO T-Display (http://www.lilygo.cn/prod_view.aspx?Id=1126) has 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 switch (https://www.aliexpress.com/item/4000125221474.html) can 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.
Title: Re: [newbie] On/off switch to handle battery?
Post by: ledtester on September 23, 2022, 12:39:52 am
1. What (compact) on/off switch (https://www.aliexpress.com/item/4000125221474.html) can 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)?

You 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/B01M9AAUEM (https://www.amazon.com/JST-2-pin-Extension-Cable-Switch/dp/B01M9AAUEM)

Also see this reddit thread:

https://www.reddit.com/r/esp32/comments/jq9zev/how_to_power_off_ttgo_tdisplay_while_charging/ (https://www.reddit.com/r/esp32/comments/jq9zev/how_to_power_off_ttgo_tdisplay_while_charging/)

Quote
2. When the board is powered by USB, will it recharge the battery after I set the switch to ON?

Yes - it will be the same as if the battery is connected.
Title: Re: [newbie] On/off switch to handle battery?
Post by: Winfried on September 23, 2022, 12:40:27 pm
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
Title: Re: [newbie] On/off switch to handle battery?
Post by: DavidAlfa on September 24, 2022, 11:01:34 am
Check the schematics! Yeah, it has built-in charger...
https://github.com/Xinyuan-LilyGO/TTGO-T-Display/blob/master/schematic/ESP32-TFT(6-26).pdf

The 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.
Title: Re: [newbie] On/off switch to handle battery?
Post by: mikerj on September 24, 2022, 01:10:28 pm
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?

"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.
Title: Re: [newbie] On/off switch to handle battery?
Post by: DavidAlfa on September 24, 2022, 08:23:18 pm
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.
Title: Re: [newbie] On/off switch to handle battery?
Post by: Winfried on September 25, 2022, 09:21:25 am
Thanks. That's way above my head. A plain switch seems a much easier path to the goal.