I use a small delay in PUBLISH and reduce keepalive timer so the restart is more frequent.
Is it possible a collision during transmission of simultaneous messages?
Explore... Chat... Share...
PANIC: unprotected error in call to Lua API (sending in process)
NodeMCU 0.9.5 build 20150213 powered by Lua 5.1.4
TIME_READ = 10000 -- 10 second
KEEPALIVE_PERIOD = 10 -- 10 second
sTopic = "mytest/"
function pubTemp()
val = node.heap()
-- publish a message with data = val, QoS = 0, retain = 0
m:publish(sTopic.."heap",val,0,0, function(conn) print("sent "..val)
print("tmr.time = "..tmr.time())
end)
end
m = mqtt.Client("testESP", KEEPALIVE_PERIOD , "", "")
function reconnect()
print("reconnecting")
m:connect("192.168.0.7", 1883, 0, function (client)
print("OK Reconnected")
tmr.alarm(0,500,0,function()
m:subscribe(sTopic.."action",0, function(conn)
print("Resubscribe success") end)
end)
end)
end
function closeClient()
m:close()
tmr.alarm(0,1000,0,reconnect)
end
m:on("offline", function(con)
print ("offline")
tmr.alarm(0,1000,0,closeClient)
end)
m:connect("192.168.0.7", 1883, 0, function (client)
print("OK connected")
tmr.alarm(0,500,0,function()
m:subscribe(sTopic.."action",0, function(conn)
print("subscribe success") end)
end)
end)
print("start reading")
-- loop
tmr.alarm(1, TIME_READ, 1, pubTemp)
NodeMCU 0.9.6 build 20150406 powered by Lua 5.1.4
It takes about 20-25 seconds for home assistant c[…]
I tried to upgrade tof my sonoff basic R2 with the[…]
a problem Perhaps you want to define "Probl[…]
Rebooting your router will not give you a faster I[…]
There are no other notifications from esptool.py i[…]
Using the Arduino IDE, you'll learn how to set up […]
In this project, you will post to Twitter using an[…]
In this project, we will build a water level contr[…]
I guess I'm late, but I had the same problem and f[…]
Last night I received my first D1 Minis for a lear[…]
Although I am aware that this is an old post, I fe[…]