Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By AmineSmiri
#45779 Hey,

Still using ESP12-E, I'm trying to build a system whose the behavior after deepsleep depends on some counters saved on RTC.
The problem here is that RTC has really random values when powered on, so it could make everything go wrong.

I thought of using SPIFFS, still its data remains persistant after a poweroff.

I was wondering if there isn't some other way?
User avatar
By AmineSmiri
#46218
martinayotte wrote:Any RAM on any MCU has random values at power-up.
Maybe your code should looks for some "magic" numbers around your data structure, and maybe even a CRC, then the code would make the differences between real wakeup and power-on state.


Well, I didn't want to go this way x)
What I did was to check the value stored in 68th slot (68 being a random number I picked). Is this value higher than 1, which is almost always the case, it turns ON a LED on GPIO12, initiates RTC as I wish it to be, stores the value 0 on 68th slot, delay(2000), and then goes into deepsleep for one second. On the next wakeup, 68th on RTC is checked again, if it's equal to 0, it goes into its normal duty cycles.

If 68th has the value 0 when I first powerit up, I'd notice that ; the LED wouldn't be ON.

I know, that's a very lazy way to solve the "problem" :lol: