NTP integrated
This commit is contained in:
parent
1c7f3156ad
commit
c431d93895
7
main.lua
7
main.lua
@ -1,4 +1,7 @@
|
||||
dofile("wlancfg.lua")
|
||||
dofile("timecore.lua")
|
||||
|
||||
timezoneoffset=1
|
||||
|
||||
-- Wait to be connect to the WiFi access point.
|
||||
tmr.alarm(0, 100, 1, function()
|
||||
@ -11,7 +14,7 @@ tmr.alarm(0, 100, 1, function()
|
||||
print('IP: ',wifi.sta.getip())
|
||||
|
||||
--ptbtime1.ptb.de
|
||||
sntp.sync('192.53.103.108',
|
||||
sntp.sync('ptbtime1.ptb.de',
|
||||
function(sec,usec,server)
|
||||
print('sync', sec, usec, server)
|
||||
end,
|
||||
@ -26,6 +29,8 @@ end)
|
||||
|
||||
tmr.alarm(1, 1000, 1 ,function()
|
||||
sec, usec = rtctime.get()
|
||||
time = getTime(sec, timezoneoffset)
|
||||
print("Time : " , sec)
|
||||
print("Local time : " .. time.year .. "-" .. time.month .. "-" .. time.day .. " " .. time.hour .. ":" .. time.minute .. ":" .. time.second)
|
||||
end)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user