# How to store data in RTC internal memory of ESP8266 thing dev board ?

**URL:** <https://forum.arduino.cc/t/how-to-store-data-in-rtc-internal-memory-of-esp8266-thing-dev-board/531738>\
**Category:** Home Automation\
**Created:** [June 15, 2018, 8:09am UTC](https://forum.arduino.cc/t/how-to-store-data-in-rtc-internal-memory-of-esp8266-thing-dev-board/531738 "2018-06-15T08:09:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mnaveed1](https://avatars.discourse-cdn.com/v4/letter/m/bc8723/32.png) [@mnaveed1](https://forum.arduino.cc/u/mnaveed1)\
**Post date:** [June 15, 2018, 8:09am UTC](https://forum.arduino.cc/t/how-to-store-data-in-rtc-internal-memory-of-esp8266-thing-dev-board/531738/1 "2018-06-15T08:09:47Z")

</div>

I am using the code below to read and write the data stored in esp8266 internal rtc memory:

#include \<ESP8266WiFi.h\>

const unsigned long SLEEP\_INTERVAL = 10 \* 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(65, rtcStore, 2); //offset is 65

Serial.print("current value = ");  
Serial.println(\*rtcStore);

(\*rtcStore)++; //increment the value  
Serial.print("new value = ");  
Serial.println(\*rtcStore);

system\_rtc\_mem\_write(65, rtcStore, 2); //offset is 65

//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  
}  
When I upload the code and open serial monitor, value of rtcCounter starts from 109. However, I want to store some other value like 4,3, 0 etc. How can I store particular value in rtcStore ? Thank You!!

---

<div class="post-metadata">

**Author:** ![Juraj](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/juraj/32/238785_2.png) [@Juraj](https://forum.arduino.cc/u/Juraj)\
**Post date:** [June 15, 2018, 8:18am UTC](https://forum.arduino.cc/t/how-to-store-data-in-rtc-internal-memory-of-esp8266-thing-dev-board/531738/2 "2018-06-15T08:18:34Z")

</div>

> <https://github.com/esp8266/Arduino/blob/master/libraries/esp8266/examples/RTCUserMemory/RTCUserMemory.ino>

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 6, 2021, 11:52am UTC](https://forum.arduino.cc/t/how-to-store-data-in-rtc-internal-memory-of-esp8266-thing-dev-board/531738/3 "2021-05-06T11:52:49Z")

</div>


