1

I would like to save my Circular Buffer in the RTC memory of my ESP32 when I use deep sleep. So I have initialized it with RTC_DATA_ATTR but when I go into Deep Sleep I lose the data I've saved. Is there a way to do this?

Here is my function:

RTC_DATA_ATTR CircularBuffer<Datas, 178> test_SensorsDatas;

void test_RTC_memory(){
    

    for(int i=1; i<=20; i++){
        test_SensorsDatas.push(Datas);
        ID_msg.value++;
    }

    for(int i=0; i<test_SensorsDatas.size(); i++){
        Serial.println(String(Datas.value));
    }


    esp_deep_sleep_start();
}

Thank you very much! Ask me questions if something isn't clear ;)

EDIT: I tried something much simplier:

RTC_DATA_ATTR sensorsRecord newrecord{20, ID_sensor, ID_msg, epochUnion, ValueUnion, intValue, 30};
RTC_DATA_ATTR CircularBuffer<sensorsRecord, 50> test_SensorsDatas;

void test_RTC_memory2(){
    newrecord.ID_msg.value++;
    ID_msg.value++;
    Serial.println(String(newrecord.ID_msg.value));
    test_SensorsDatas.push(newrecord);
    Serial.println("buffer size: " + String(test_SensorsDatas.size()));
    esp_deep_sleep_start();
}```

But still not working, the ID_msg is incrementing well but not the buffer size even if I push a new value at every wake up.
Any suggestion?



3
  • I would guess the object is stored in RTC memory but the memory used by the object isn't. You'll need to apply the RTC_DATA_ATTR to the array inside the object, not the object itself. Commented Dec 28, 2021 at 13:47
  • Yes tried to define the data using RTC_DATA_ATTR outside of the function and after I push it in the Circular Buffer, I was unable to find it after the deep sleep... Commented Dec 28, 2021 at 14:18
  • first figure out what is really going on. test by storing a number- char, int, short etc. your simpler test case was a good thought but go even simpler. Commented Dec 30, 2021 at 13:05

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.