Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/costastf/micropython_hourly_sleeper_library
A micropython library that enables an esp8266 to sleep for hourly increments for a setup amount of hours.
https://github.com/costastf/micropython_hourly_sleeper_library
Last synced: about 1 month ago
JSON representation
A micropython library that enables an esp8266 to sleep for hourly increments for a setup amount of hours.
- Host: GitHub
- URL: https://github.com/costastf/micropython_hourly_sleeper_library
- Owner: costastf
- License: gpl-3.0
- Created: 2017-06-20T17:00:40.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-06-20T17:24:20.000Z (over 7 years ago)
- Last Synced: 2024-04-22T12:35:09.940Z (8 months ago)
- Language: Python
- Size: 17.6 KB
- Stars: 13
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-micropython - micropython_hourly_sleeper_library - A MicroPython library that enables an ESP8266 to sleep for hourly increments for a setup amount of hours. (Libraries / IO)
README
# esp8266 hourly deep sleep for multiple increments
Micropython library that enables multiple hourly increments of deep sleep.# Problem statement
By default micropython can sleep up to 71 minutes. This creates a problem
when one needs code to run once every day or even longer.# Solution
This library is an easy and unintrusive way to run some code once every a
long window of hours. The way it works is that it deep sleeps the board for
an hour and upon waking checks the state of the RTC memory where it keeps an
increment.# Usage
# boot.py
from library import HourlySleeper
# we instantiate the sleeper with the hours that we want it to sleep after
# the first execution of our code.
hourly_sleeper = HourlySleeper(24)and that is all its needed in boot.py
# main.py
import machine
import timedef main():
try:
hourly_sleeper()# here is where our code would be
# we need the reset after our code so we enter the deep sleep loopmachine.reset()
except Exception:
machine.reset()if __name__ == '__main__':
main()# Resetting the counter
If we need to reset the counter we need to hard reset the board through the
reset button. Its best to try a couple of times to make sure that the signal
is properly caught.# Debugging
In order to debug our code and the loop we can set
HOURLY_SLEEP_DEBUG=True
either in boot.py or in main.py
If that variable is set the deepsleep performed is 6 seconds long instead of
an hour to make the monitoring a bit more manageable.