Go Down

Topic: How to store data in RTC internal memory of ESP8266 thing dev board ? (Read 607 times) previous topic - next topic

mnaveed1

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!!

Juraj

You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

Go Up