Post your best Lua script examples here

User avatar
By sigrokBlack
#9179 Hey,
i wrote a little lua which reads a state of a button and notifys me when the button is pushed :
Code: Select allpin = 4
gpio.mode(pin,gpio.INPUT)
if gpio.read(pin)== 1 then
     conn=net.createConnection(net.TCP, false)
     conn:on("receive", function(conn, pl) print(pl) end)
     conn:connect(80,"50.116.34.97")
     conn:send("GET /publicapi/notify?apikey=apikey&application=ESP8266&event=START&description=Der%20Schalter%20wurde%20gedrückt\r\n"
          .."Connection: keep-alive\r\nAccept: */*\r\n\r\n")
end


What do I've to do, that it starts at the boot of the esp8266 and repeats so often as possible?
User avatar
By raz123
#9186 Look for GPIO.trig in the api document. Then set a trigger to execute your code when then signal rises on the pin.