SparkFun Thing Plus - Power Switch

Howdo,

I’m using a SparkFun Thing Plus (ESP32-S2) for a remote control, powered by a lipo, and I have added a power switch that brings enable low to put the board to sleep.

As I understand it, this switches off the 3v regulator and I’d assume cuts all power? When I switch the board back on I get LEDs lighting up from the various components but the screen that’s attached doesn’t spring back in to life.

Am I using the En pin correctly or should I just put the switch on the battery? I was hoping to be able to charge it while it’s switched off for example which wouldn’t be possible that way.

Edit: I just tested using reset after switching back on and the board rebooted fine so I suspect this is going in to a low power state and not recovering gracefully. Is there an “OnAwake” type event I could use to detect power on?

Any tips would be greatly appreciated.

I’ve found a workaround or fix for this, using the watchdog timer, details as follows.

add this import:

#include <esp_task_wdt.h>

This definition:

#define WDT_TIMEOUT 5

Add this to setup(), somewhere near the top seems more reliable:

esp_task_wdt_init(WDT_TIMEOUT, true); //enable panic so ESP32 restarts

esp_task_wdt_add(NULL); //add current thread to WDT watch

Add this to loop():

esp_task_wdt_reset();

Seems to work, hope it helps someone