Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Connecting to WiFi...")
- wifi.setmode(wifi.STATION)
- wifi.sta.config("xxx","xxx")
- wifi.sta.connect()
- while (wifi.sta.status() ~= 5) do
- print("IP unavaiable, Waiting...")
- tmr.delay(1000000)
- end
- print(wifi.sta.getip())
- time_between_sensor_readings = 60000
- temp_decimial = 0
- humi_decimial = 0
- DHT= require("dht22_min")
- DHT.read(4)
- temperature = DHT.getTemperature()
- humidity = DHT.getHumidity()
- if humidity == nil then
- print("Error reading from DHT22")
- else
- print("Temperature: "..(temperature / 10).."."..(temperature % 10).." deg C")
- print("Humidity: "..(humidity / 10).."."..(humidity % 10).."%")
- conn=net.createConnection(net.TCP, false)
- conn:on("receive", function(conn, pl) print(pl) end)
- conn:connect(80,"xx.xx.xx.xx")
- 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")
- end
- DHT = nil
- package.loaded["dht22_min"]=nil
- print("Going to sleep...")
- --node.dsleep(time_between_sensor_readings*1000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement