In terms of the node I`ve tried the test and example code posted herehttp://www.esp8266.com/viewtopic.php?f=19&t=1278
In terms of R.Pi
I'm running two separate terminal windows one running a subscribing mosquittto line, and another publishing
mosquitto_sub -h 192.168.0.102 -p 1883 -t /#
while true; do mosquitto_pub -h 192.168.0.102 -p 1883 -t /test -m Hi; done
SSID = "Bakery229"
password = "electronics229"
wifi.setmode(wifi.STATION)
wifi.sta.config(SSID, password)
wifi.sta.connect()
print("ESP8266 mode is: " .. wifi.getmode())
print("The module MAC address is: " .. wifi.ap.getmac())
print("Config done, IP is "..wifi.sta.getip())
m = mqtt.Client(wifi.sta.getmac(), 120)
m:lwt("/lwt", wifi.sta.getmac(), 0, 0)
m:on("offline", function(con)
print ("reconnecting...")
print(node.heap())
tmr.alarm(1, 10000, 0, function()
m:connect("192.168.0.102", 1883, 0)
end)
end)
-- on publish message receive event
m:on("It works", function(conn, topic, data)
print(topic .. ":" )
if data ~= nil then
print(data)
end
end)
tmr.alarm(0, 1000, 1, function()
if wifi.sta.status() == 5 then
tmr.stop(0)
m:connect("192.168.0.102", 1883, 0, function(conn)
print("connected")
m:subscribe("/test",0, function(conn)
m:publish("/test","hello",0,0, function(conn) print("sent") end)
end)
end)
end
end)I'm getting the message sent through to the other terminal, however nothing for the NodeMCUoutput:
> dofile("test270515.lua")
ESP8266 mode is: 1
The module MAC address is: 1A-FE-34-A0-7A-FC
Config done, IP is 192.168.0.186
test270515.lua:19: method not supported
>
The 19th line:
m:on("It works", function(conn, topic, data)http://b.truzzi.me/home-temperature-monitoring-using-openhab-rpi-esp8266-and-hdc1000/
I also looked at his code for the NodeMCU - similar errors with the m:connect line
Thanks again if you're willing to help