Closed
Description
Has something change in how to use system_rtc_mem_write?
The following sketch works with the old 1.6.1 release and the serial prints show the rtc byte incrementing, but with the latest code it doesn't work and always outputs "first time".
extern "C" {
#include "user_interface.h"
}
byte rtcStore[2];
void setup() {
Serial.begin(115200);
Serial.println();
system_rtc_mem_read(64, rtcStore, 2);
if (rtcStore[0] != 123) {
Serial.println("first time");
rtcStore[0] = 123;
rtcStore[1] = 0;
} else {
rtcStore[1] += 1;
Serial.print("rtc = ");
Serial.println(rtcStore[1]);
}
system_rtc_mem_write(64, rtcStore, 2);
Serial.println("deep sleep 3 seconds...");
//ESP.deepSleep(5000000, WAKE_RF_DISABLED);
system_deep_sleep_set_option(4); // 4 = low power, radio off mode
system_deep_sleep(2000000);
delay(1000);
}
void loop() {
// shouldn't get here
}