Note, this module has a horrible bare-bones HTTP GET implementation using bare sockets. It is probably brittle and would benefit from being replaced by urllib, requests or some proper library. Ideas appreciated ...
Usage is as such:
- Register for an API key at timezonedb.com, which is free for non-commercial use and <1 time request/sec.
- Download nettime.py to your WiPy. (Optionally, set the default APIKEY variable in nettime.py to your API key.)
- Add something like the following to your boot.py so that your WiPy sets its RTC on every POWER_ON or HARD_RESET reset:
Code: Select all
if network.WLAN().isconnected() and machine.reset_cause()<=machine.HARD_RESET: rtc = nettime.sync_rtc_to_network_time(key='myapikey')