-->
Page 1 of 1

check if ESP is powered on first time or from deep sleep

PostPosted: Tue Jan 03, 2023 4:28 pm
by impeham
is there a way at the setup/loop logic to know if the device is powered on for the first time or was waken up from:
ESP.deepSleep(sleepTime, WAKE_RF_DISABLED);

i need to differentiate the two scenarios and do some different logic for each of these cases

Re: check if ESP is powered on first time or from deep sleep

PostPosted: Tue Jan 03, 2023 8:47 pm
by davydnorris
The raw NonOS API has a method that will let you find this out, but I don't know if it's in the Arduino API

Check out

struct rst_info *rst_info = system_get_rst_info();

Re: check if ESP is powered on first time or from deep sleep

PostPosted: Wed Jan 04, 2023 2:33 am
by impeham
thanks! seems possible with:
rst_info* rinfo = ESP.getResetInfoPtr();