I am trying to save and access values in the RTC memory during DEEP sleep. Here is the sketch:
#include <ESP8266WiFi.h>
const unsigned long SLEEP_INTERVAL = 20 * 1000 * 1000; // 20 sec
extern "C" {
#include "user_interface.h"
}
void setup() {
Serial.begin(74880);
Serial.println();
Serial.println("RTC Memory Test");
byte rtcStore[2];
system_rtc_mem_read(64, rtcStore, 2);
Serial.print("current value = ");
Serial.println(*rtcStore);
(*rtcStore)++;
Serial.print("new value = ");
Serial.println(*rtcStore);
system_rtc_mem_write(64, rtcStore, 2);
//sleep modes: WAKE_RF_DEFAULT, WAKE_RFCAL, WAKE_NO_RFCAL, WAKE_RF_DISABLED
ESP.deepSleep(SLEEP_INTERVAL - micros(), WAKE_RF_DISABLED);
delay(1000);
}
void loop() {
// should never get here
}
But it is not working. In the Serial output I am getting:
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld
RTC Memory Test
current value = 0
new value = 1
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld
RTC Memory Test
current value = 0
new value = 1
I am using Arduino 1.6.8. Do I need to flash ESP-12 with some specific firmware (isn′t arduino uploading all that is needed) ?
Thanx,
DiNo