Advertisement
Guest User

ESP8266 Door Alert Code (For NodeMCU + Vibration Sensor)

a guest
May 22nd, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.52 KB | None | 0 0
  1. gpio.mode(5, gpio.INPUT)
  2. doortime = 0
  3. function dooralert(level)
  4.     if(doortime + 5 < tmr.time()) then
  5.         doortime = tmr.time()
  6.         print("doorbell")
  7.         conn=net.createConnection(net.TCP, 0)
  8.         conn:on("receive", function(conn, pl) print(pl) end) --not really needed, remove after testing
  9.         conn:connect(80,"<REMOVED>")
  10.         conn:send("GET <REMOVED> HTTP/1.1\r\nHost: <REMOVED>\r\n Connection: keep-alive\r\nAccept: */*\r\n\r\n")
  11.         conn=nil
  12.     end
  13. end
  14. gpio.trig(5, "up", dooralert)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement