Skip to content

Commit 52207eb

Browse files
author
fuermohao
committed
added: sync time
1 parent f73017e commit 52207eb

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

emp_utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,13 @@ def wrapper(*args, **kwargs):
109109

110110
return wrapper
111111

112-
112+
def sync_time():
113+
import urequests
114+
from machine import RTC
115+
rtc = RTC()
116+
print('before sync: ', rtc.datetime())
117+
time = urequests.get('http://www.1zlab.com/api/get-time/').json()
118+
# print(time)
119+
rtc.init(tuple(time['rtc']))
120+
print('after sync: ', rtc.datetime())
121+

0 commit comments

Comments
 (0)