Removed temperature reading
This commit is contained in:
25
mqtt.lua
25
mqtt.lua
@@ -38,32 +38,10 @@ function startMqtt()
|
||||
end)
|
||||
end
|
||||
|
||||
function readTemp()
|
||||
if (t ~= nil) then
|
||||
addrs=t.addrs()
|
||||
-- Total DS18B20 numbers
|
||||
sensors=table.getn(addrs)
|
||||
local temp1=0
|
||||
if (sensors >= 1) then
|
||||
temp1=t.read(addrs[1])
|
||||
end
|
||||
return temp1
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
function startMqttClient()
|
||||
if (mqttServer ~= nil and mqttPrefix ~= nil) then
|
||||
startMqtt()
|
||||
print "Started MQTT client"
|
||||
if (file.open("ds18b20.lc")) then
|
||||
t=require("ds18b20")
|
||||
t.setup(2) -- GPIO4
|
||||
readTemp() -- read once, to setup chip
|
||||
print "Setup temperature"
|
||||
end
|
||||
|
||||
oldBrightness=0
|
||||
oldTemp=0
|
||||
tmr.alarm(5, 5001, 1 ,function()
|
||||
@@ -74,9 +52,6 @@ function startMqttClient()
|
||||
end
|
||||
if (oldBrightness ~= briPercent) then
|
||||
m:publish(mqttPrefix .. "/brightness", tostring(briPercent), 0, 0)
|
||||
elseif (temp ~= nil and temp ~= oldTemp) then
|
||||
oldTemp = temp
|
||||
m:publish(mqttPrefix .. "/temp", tostring(temp), 0, 0)
|
||||
else
|
||||
m:publish(mqttPrefix .. "/heap", tostring(node.heap()), 0, 0)
|
||||
end
|
||||
|
Reference in New Issue
Block a user