Hi,
I'm in low power device project. That device check status periodic and send it data to server.
For reduce power consumption, my ESP32 is always go to deep sleep after finish all works.
But we need to store some data that before deep sleep, like 'is_first_boot'. This variable checks 'booting' or 'waking up' at start of my code. It means the changing value of data is not often.
So I used 'RTC_DATA_ATTR' keyword. but I still have a doubt of perfomance.
What is better?
1. Store to NVS and Restore.
2. Use RTC memory.
3. Anything else?
Thanks.
What is better way to store some data after deep sleep?
-
- Posts: 9708
- Joined: Thu Nov 26, 2015 4:08 am
Re: What is better way to store some data after deep sleep?
What do you mean, 'doubt of performance'? What performance are you worried about?
Re: What is better way to store some data after deep sleep?
Hmm... I just want to know what is better way!
Using NVS or RTC memory.
Using NVS or RTC memory.
-
- Posts: 9708
- Joined: Thu Nov 26, 2015 4:08 am
Re: What is better way to store some data after deep sleep?
There is no such thing as 'the (universally) better' way; asking for that is like asking if a screwdriver or a hammer is better; it depends on if you have screws or nails on hand. In general, RTC memory is better as storing/reading data is faster but a loss of power loses everything; NVS doesn't have that downside but is slower to use and depending on the amount of writes you do, you may need to keep flash write cycles in mind. Which one is 'better' depends on what you need to do with it.
Re: What is better way to store some data after deep sleep?
Thank you for kindly response.
I decide to use both of them.
And here is flow of my source code. Please advice to me.
Is there some best way to store configuration data?
Thank you!
I decide to use both of them.
And here is flow of my source code. Please advice to me.
Is this better than use only one of them(NVS, RTC memory)?
- 1. Check the device is reset. (check some value that restored in slow RTC memory is 0)
- a. If device is reset, load value to slow RTC memory from NVS.
- b. If device is just waken up, do noting.
- 2. Perform jobs with slow RTC data.
- 3. Check input about changing configuration data.
- a. If input data exists, apply that to NVS and RTC memory.
- 4. Clean before sleep.
- 5. Sleep and go to 1.
Is there some best way to store configuration data?
Thank you!
-
- Posts: 9708
- Joined: Thu Nov 26, 2015 4:08 am
Re: What is better way to store some data after deep sleep?
I think you're prematurely optimizing, to be honest... if you store your data to NVS as often as you do it to RTC mem, it simplifies your code to simply rip out the RTC mem path and only use NVS.
Re: What is better way to store some data after deep sleep?
I think my device won't be reset that often in normal scenario, because of using battery.
Even considering this, is it still a prematurely optimization?
Even considering this, is it still a prematurely optimization?
-
- Posts: 9708
- Joined: Thu Nov 26, 2015 4:08 am
Re: What is better way to store some data after deep sleep?
It depends. If you write your NVS as often as you write RTC memory, yes; there's no need to write it to RTC mem as you can get the data from NVS just as easily. It might be useful for flash life and maybe power use to update NVS less often than RTC and have both paths, but I'd run the numbers on that before making a decision. (To be honest: Or you can just do whatever you feel comfortable with, it'll work even if it's more complex.)
Who is online
Users browsing this forum: No registered users and 80 guests