Created
April 15, 2015 23:16
-
-
Save thinkl33t/2557f6f77f3a56566b06 to your computer and use it in GitHub Desktop.
esp8266 MQTT button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wifi.setmode(wifi.STATION) | |
wifi.sta.config("SSID","PASSWORD") | |
wifi.sta.connect() | |
tmr.alarm(1, 100, 1, function() | |
if wifi.sta.getip() ~= nil then | |
tmr.stop(1) | |
m = mqtt.Client( "ESP8266-" .. node.chipid(), 120) | |
m:connect( "192.168.1.13" , 1883, 0, function(conn) | |
m:publish("button/1/pressed", "", 0, 0, function(conn) | |
node.dsleep(0) | |
end) | |
end) | |
end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment