-- John Longworth December 2017 -- This program gets the time from an SNTP server and sets the internal RTC -- Uses rtctime & sntp modules local days = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"} sntp.sync({"0.uk.pool.ntp.org", "1.uk.pool.ntp.org"}, function(sec, usec, server, info) print("\nSeconds: "..sec,"Micro seconds: "..usec,"Server: ".. server) rtctime.set(sec, usec) tm = rtctime.epoch2cal(rtctime.get()) sdate = string.format("\n%02d/%02d/%04d %02d:%02d:%02d", tm["day"], tm["mon"], tm["year"], tm["hour"], tm["min"], tm["sec"]) sdate = sdate.." "..days[tm["wday"]].." Day number "..tm["yday"].." of the year." print(sdate) print(string.format("\nToday is: %04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"])) end, function() print('Failed!') end, autoreset)