Where to add a power on/off switch to an ESP32 board with battery

Hi there,

I got a XIAO ESP32C3 board which is connected to a battery which charges through the USB-C connection. I want to install an on/off slide switch to be able to turn off the device while keeping the battery charging.

I have no idea where do I need to install the 3-pins slide switch (example) on my circuit to make this work. Does someone has a clue how I can go about this?

Here are the schematics for my current build: tiny-screen - Wokwi ESP32, STM32, Arduino Simulator


Please post schematics showing how You have wired the parts together, including the powering.

No, that's not schematics for the build.

1 Like

Thank you for your reply, I have added the current schematics for my circuit with the disconnected slide switch.

No, You have not. The coloured wires go to positions, useless for every helper that doesn't have the components at hand to solve the crypto.
The logic names of the components are needed.

1 Like

Note that this circuit currently works and I don't need help and have no issues with the components nor need help with those components.

I was wondering how would one traditionally implement an on/off switch for an ESP32 board with battery, regardless of what you use the board for.

Power on/off?

Yes, to be able to turn off my board when connected to battery or while charging on USB-C.

Power on/off?

If you just let it run it will turn off when the battery dies. I would like to say I am clairvoyant and can answer your question but without knowing exactly what you have I can only guess and I do not like doing that. You say everything works how about the switch with 3 leads.

Cut the battery "+" lead and solder in the switch.

Example

1 Like

Look at your 2 position switch as an "or" switch.
Centre pin connects to your battery positive and the remaining outer pins connect to either the charger, OR, to your uC.

1 Like

Not going to happen, because charger and MCU are on the same board, using the same supply.

You can however put the processor to sleep, with a switch or button connected to a pin. The charger chip will continue to do it's thing, because it doesn't rely on the processor to work.
Schematics here.
Leo..

1 Like

As Leo says, traditionally, the switch would be between the charger/battery circuit and the regulator. That would eliminate all battery drain but still allow charging.

However, it appears the regulator has a Chip Enable pin. If there's a way to cut the trace that ties that pin high, and connect a switch that switches it between high and low, that would be very close to the same as an on/off switch.

Also, I notice on the bottom of the board there's a pad labeled "EN". I suspect that has to do with the processor, not the regulator, but you might investigate what that EN pad is for. It's possible the designers have provided a way to shut things down.

Edit: Yes, from the schematic, it looks like that's the CE pin of the ESP32, and it's pulled high through a resistor. But you could ground that pad to bring the CE pin low. But I don't know how much current the ESP would still draw. So it might not be a full shutdown.

1 Like

Thank you all for your replies and suggestions.

@jremington, if I place the switch between the battery and the + pad, I would think the battery would only charge if the switch is "on" is that right? Also I would think the board would still turn on if plugged and switch is "off".

Correct.

1 Like

@Wawa wiring the switch enable/disable deep sleep does seem like a viable option even though I would rather have it completely off.

@ShermanP thank you for the clue on the CHIP_EN pin it does seem to offer a way to switch off the chip, though I am not sure I would have it low by default. I will be reaching on Seeed forum for further help on that specific board (link).

I fail to see why software deep sleep isn't an option. Battery self-discharge and the charging chip itself could use a lot more than an ESP32 is deep sleep. Never done that myself, but I see current draws of the ESP32 of 10uA, or 2.5uA in hibernation mode (click).
Leo..

1 Like

Oh I do think it is a viable option though I wanted to first try and see if disabling the board entirely was possible. Though I understand that for charging to still work, it can't be completely off either and deep sleep might then be the best option.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.