@eyal Hoping you'll have the answer to this, since I'm basically just trying to replicate what you've already done, however I can't seem to find an answer in your code on Github.
I'm doing a very basic wake, read DS18b20, sleep/restart loop.
Works 100% when using DHCP (albeit it takes several seconds to get an IP.) Using a static IP I need to put a delay of about 1 sec in before sending the packet for it to work. Anything less and the packet just disappears.
Checking wifi.sta.status() doesn't seem to produce the required outcome in this case.
t = require("ds18b20")
gpio4 = 1
-- Send the packet then go to sleep
local function readAndSend_18B20()
tmr.alarm(1,10, tmr.ALARM_SINGLE, function()
node.dsleep(1000000 * 3)
wifi.sta.status() -- rumoured to kick start WiFi connection
-- check DS18b20 pin is pulled up as an indicator to start normally
if(gpio.read(gpio4) == 1) then
temp = t.read().."'C"
if(wifi.sta.status() == 5) then
-- No IP - setup timer to check for it
tmr.alarm(0, 100, tmr.ALARM_AUTO, function ()
if (wifi.sta.status() == 5) then
print("Exit restart loop")