sv=net.createServer(net.TCP)
sv:listen(1000,function(c)
c:on("receive", function(c, pl)
print(pl)
c:send(readDHT())
end)
end)
PIN = 4 -- data pin, GPIO2
function readDHT()
while h == nil do
dht22 = require("dht22")
dht22.read(PIN)
t = dht22.getTemperature()
h = dht22.getHumidity()
end
h = nil
dht22 = nil
package.loaded["dht22"]=nil
return "T"..((t-(t % 10)) / 10).."."..(t % 10)
end
--print("H"..((h - (h % 10)) / 10).."."..(h % 10))
tmr.alarm(0, 10000, 1, function() readDHT() end)