把ssid和pwd改成自己的,波特率15200。
wifi.setmode(wifi.STATION)
wifi.sta.config{ssid="you ssid", pwd="you password"}
wifi.sta.autoconnect(1)
tmr.alarm(0, 1000, 1, function()
if wifi.sta.getip() == nil then
print("Connecting...")
else
tmr.stop(0)
print("Connected, IP is "..wifi.sta.getip())
sntp.sync({"194.94.224.118", "ptbtime1.ptb.de","ntp.shu.edu.cn","ptbtime1.ptb.de","cn.pool.net.org","ntp.shu.edu.cn","ntp.sjtu.edu.cn","202.112.10.36","202.112.29.82"},
function(sec, usec, server, info)
print('sync', sec, usec, server)
print('@')
end,
function()
print('failed!')
end)
end
end)
tmr.alarm(1, 1000, 1, function()
secs = rtctime.get()