martinayotte wrote:BryanLee wrote:Unless there is a way of determining if the ESP is in it's initial boot
I don't know if that can help since I didn't tried it in deepsleep context.
Code: Select allrst_info *rinfo;
rinfo = ESP.getResetInfoPtr();
Serial.println(String("ResetInfo.reason = ") + (*rinfo).reason);
Looks like it's working. Initially I got a compile error, but then I found your post at
viewtopic.php?p=26862Turns out I didn't need to include Arduino.h, but the external C include I did:
Code: Select allextern "C" {
#include <user_interface.h>
}
From there I found all the values for rst_info.reason at
https://github.com/devicehive/esp8266-f ... nterface.h . 0 = boot, 4 = soft reset, 5 = wake from deep sleep.
So I added this code to my setup() function, right after setting up the serial debugging port
Code: Select all Serial.println("We're alive") ;
rst_info *rinfo;
rinfo = ESP.getResetInfoPtr();
Serial.println(String("ResetInfo.reason = ") + (*rinfo).reason);
// if we woke from deep sleep, do a full reset
// this is needed because http gets from deep sleep are not properly returned.
// test to see if this is fixed in future esp8266 libraries
if ((*rinfo).reason == REASON_DEEP_SLEEP_AWAKE) {
Serial.println("Woke from deep sleep, performing full reset") ;
ESP.restart() ;
}
This very much feels like a work-around for a bug, perhaps somewhere in the esp8266 libraries, or maybe the chip itself? It will take better programmers than I to determine that.
But the good news is, I have gone through many sleep/wake cycles, and it now works great. I have yet to see a null string returned. Thank you!