Am I doing something wrong? Would I be better off using float?
pin = 5
status, temp, humi, temp_dec, humi_dec = dht.read(pin)
if status == dht.OK then
-- Integer firmware using this example
print(string.format("DHT Temperature:%d.%03d;Humidity:%d.%03d\r\n",
math.floor(temp),
temp_dec,
math.floor(humi),
humi_dec
))
-- print("temp, last: "..temp.." ".._G.last_temp)
if _G.last_temp == nil or temp ~= _G.last_temp then
_G.last_temp = temp
_G.temperature = temp
_G.humidity = humi
_G.message = _G.ModID.." ".._G.temperature.." ".._G.humidity.." 0 "
dofile("sntptime.lua") -- was httpgettime.lua
end
-- Float firmware using this example
-- print("DHT Temperature:"..temp..";".."Humidity:"..humi)
elseif status == dht.ERROR_CHECKSUM then
print( "DHT Checksum error." )
elseif status == dht.ERROR_TIMEOUT then
print( "DHT timed out." )
end