-->
Page 1 of 1

Is there a way to avoid the randomness of RTC_memory ?

PostPosted: Tue Apr 19, 2016 9:18 am
by AmineSmiri
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?

Re: Is there a way to avoid the randomness of RTC_memory ?

PostPosted: Tue Apr 19, 2016 10:05 am
by martinayotte
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.

Re: Is there a way to avoid the randomness of RTC_memory ?

PostPosted: Tue Apr 26, 2016 5:32 am
by AmineSmiri
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:

Re: Is there a way to avoid the randomness of RTC_memory ?

PostPosted: Tue Apr 26, 2016 5:58 am
by fdufnews
AmineSmiri wrote:I know, that's a very lazy way to solve the "problem" :lol:
At least you shall write in 2 different locations, 2 numbers that relates one to the other in order to be sure.