RTC memory

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
kwiley
Posts: 97
Joined: Wed May 16, 2018 5:53 pm
Contact:

RTC memory

Post by kwiley » Sat May 16, 2020 5:59 am

Apparently a trick to both reduce power consumption to increase battery life while simultaneously saving EEPROM cycles is to pass small amounts of data across deep sleep cycles by writing that data (up to 512 bytes) into the RTC memory. I don't see API endpoints for this in the docs. Does MicroPython not support this feature?

Thanks.

jomas
Posts: 49
Joined: Mon Dec 25, 2017 1:48 pm
Location: Netherlands

Re: RTC memory

Post by jomas » Sat May 16, 2020 9:22 am

kwiley wrote:
Sat May 16, 2020 5:59 am
Apparently a trick to both reduce power consumption to increase battery life while simultaneously saving EEPROM cycles is to pass small amounts of data across deep sleep cycles by writing that data (up to 512 bytes) into the RTC memory. I don't see API endpoints for this in the docs. Does MicroPython not support this feature?

Thanks.
You can use it like this
rtc=RTC()
rtc.memory(b'hello world') # write
rtc.memory() # read

If you need more data items you use a json string

kwiley
Posts: 97
Joined: Wed May 16, 2018 5:53 pm
Contact:

Re: RTC memory

Post by kwiley » Sat May 16, 2020 2:53 pm

Okay. I see that in the REPL now:

Code: Select all

>>> 
PYB: soft reboot
MicroPython v1.10-8-g8b7039d7d on 2019-01-26; ESP module with ESP8266
Type "help()" for more information.
>>> import machine
>>> rtc = machine.RTC()
>>> rtc.[TAB]
__class__       ALARM0          alarm           alarm_left
datetime        irq             memory
>>> rtc.
It's worth noting that the memory function of RTC isn't documented on either the general MicroPython machine module webpage or the ESP8266-specific webpage:
docs.micropython.org/en/latest/library/machine.RTC.html:
http://docs.micropython.org/en/latest/l ... e.RTC.html
docs.micropython.org/en/latest/esp8266/quickref.html:
http://docs.micropython.org/en/latest/e ... ckref.html

In fact, the string "rtc.memory" doesn't occur anywhere in the docs:
docs.micropython.org/en/latest/search.html?q=rtc.memory&check_keywords=yes&area=default# :
http://docs.micropython.org/en/latest/s ... a=default#

So the only way to discover the memory function is through the REPL, and even then, merely discovering it doesn't document its parameters or how to use it. The only way to figure out its actual parameter list, return type, or behavior, is to got the Github and find it in the source.

Am I not understanding the proper way to use the documentation? I hate to ask newbie questions like, "How do you do a task that is clearly documented if you just look here."

Thanks.

Post Reply