RTC Memory ESP8266 12-E read an write
I'm assuming you're using the Arduino ESP8266 firmware, from your edit. Start by reading the documentation...

I've not used the Arduino ESP8266 firmware, but it appears you can use ESP.rtcUserMemoryWrite(offset, &amp;data, sizeof(data)) and ESP.rtcUserMemoryRead(offset, &amp;data, sizeof(data)).

For example,

...
int32_t foo = 100;
ESP.rtcUserMemoryWrite(0, &amp;foo, sizeof(foo));
ESP.deepSleep(5e6);
...


and then

...
int32_t bar = 0;
ESP.rtcUserMemoryRead(0, &amp;bar, sizeof(bar)));
// check the data
...


You will likely need to keep a checksum of your data and verify it after reading, in order to make sure that you have valid data.

This should persist across sleep, but I'm not sure if it persists across resets, and I'm pretty sure it doesn't persist across power cycles.