-- init.lua local SSID = "WLAN NAME" local SSID_PASSWORD = "password" wifi.setmode(wifi.STATION) wifi.setphymode(wifi.PHYMODE_N) --wifi.sta.config(SSID, SSID_PASSWORD) wifi.sta.config {ssid=SSID, pwd=SSID_PASSWORD} wifi.sta.autoconnect(1) tmr.alarm(1, 1000, 1, function() if wifi.sta.getip()== nil then print ("Waiting for Wifi connection") else tmr.stop(1) tmr.stop(2) print ("ESP8266 mode is: " .. wifi.getmode ( )) print ("The module MAC address is: " .. wifi.ap.getmac ( )) print ("Config done, IP is " .. wifi.sta.getip ( )) dofile("dsleep.lua") end end) -- if there is no connection after some seconds, stop trying to connect and go to deep sleep for a minute tmr.alarm(2, 10 * 1000, 1, function() tmr.stop(1) tmr.stop(2) if wifi.sta.getip() == nil then print("down", wifi.sta.getip()) node.dsleep(60 * 1000000) end end)