code-lua-iot/mqtt.lua
2024-12-15 16:54:01 +01:00

16 lines
408 B
Lua

client = mqtt.client("ESP32", "192.168.1.76", 1883, false)
client:connect("","")
function printMaster(length, msg)
console("[MASTER]"..msg)
end
function printAlt(length, msg)
console("[ALT]"..msg)
end
client:subscribe("MASTER", mqtt.QOS0, printMaster)
client:subscribe("ALT", mqtt.QOS0, printAlt)
client:publish("MASTER", "Hello, world!", mqtt.QOS0)
client:publish("ALT", "Hello, world!", mqtt.QOS0)