Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. print("Connecting to WiFi...")
  2. wifi.setmode(wifi.STATION)
  3. wifi.sta.config("xxx","xxx")
  4. wifi.sta.connect()
  5.  
  6. while (wifi.sta.status() ~= 5) do
  7.   print("IP unavaiable, Waiting...")
  8.   tmr.delay(1000000)
  9. end
  10.  
  11. print(wifi.sta.getip())
  12.  
  13. time_between_sensor_readings = 60000
  14.  
  15. temp_decimial = 0
  16. humi_decimial = 0
  17.  
  18. DHT= require("dht22_min")
  19. DHT.read(4)
  20. temperature = DHT.getTemperature()
  21. humidity = DHT.getHumidity()
  22.  
  23. if humidity == nil then
  24. print("Error reading from DHT22")
  25. else
  26.  
  27. print("Temperature: "..(temperature / 10).."."..(temperature % 10).." deg C")
  28. print("Humidity: "..(humidity / 10).."."..(humidity % 10).."%")
  29.  
  30. conn=net.createConnection(net.TCP, false)
  31. conn:on("receive", function(conn, pl) print(pl) end)
  32. conn:connect(80,"xx.xx.xx.xx")
  33. conn:send("GET /temp1/index.php?tempV="..(temperature / 10).."."..(temperature % 10).."&humV="..(humidity / 10).."."..(humidity % 10).." HTTP/1.1\r\nHost: www.domena.cz\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n")
  34.  
  35. end
  36.  
  37. DHT = nil
  38. package.loaded["dht22_min"]=nil
  39.  
  40. print("Going to sleep...")
  41. --node.dsleep(time_between_sensor_readings*1000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement