Read temperatur, when more than 12k RAM is free
This commit is contained in:
parent
ffa3bb69de
commit
8bc3b0cb66
5
mqtt.lua
5
mqtt.lua
@ -215,12 +215,13 @@ function startMqttClient()
|
|||||||
local mqtttimer = tmr.create()
|
local mqtttimer = tmr.create()
|
||||||
mqtttimer:register(6001, tmr.ALARM_AUTO, function (kTemp)
|
mqtttimer:register(6001, tmr.ALARM_AUTO, function (kTemp)
|
||||||
if (mqttConnected) then
|
if (mqttConnected) then
|
||||||
|
local heapusage = node.heap()
|
||||||
local temperatur = nil
|
local temperatur = nil
|
||||||
if (oldBrightness ~= briPer) then
|
if (oldBrightness ~= briPer) then
|
||||||
m:publish(mqttPrefix .. "/brightness", tostring(briPer), 0, 0)
|
m:publish(mqttPrefix .. "/brightness", tostring(briPer), 0, 0)
|
||||||
oldBrightness = briPer
|
oldBrightness = briPer
|
||||||
else
|
else
|
||||||
if (t ~= nil) then
|
if ((t ~= nil) and (heapusage > 12000)) then
|
||||||
local ds18b20=require("ds18b20_diet")
|
local ds18b20=require("ds18b20_diet")
|
||||||
ds18b20.setup(2) -- GPIO4
|
ds18b20.setup(2) -- GPIO4
|
||||||
readTemp(ds18b20) -- read once, to setup chip
|
readTemp(ds18b20) -- read once, to setup chip
|
||||||
@ -234,7 +235,7 @@ function startMqttClient()
|
|||||||
oldTemp = temperatur
|
oldTemp = temperatur
|
||||||
m:publish(mqttPrefix .. "/temp", tostring(temperatur/100).."."..tostring(temperatur%100), 0, 0)
|
m:publish(mqttPrefix .. "/temp", tostring(temperatur/100).."."..tostring(temperatur%100), 0, 0)
|
||||||
else
|
else
|
||||||
m:publish(mqttPrefix .. "/heap", tostring(node.heap()), 0, 0)
|
m:publish(mqttPrefix .. "/heap", tostring(heapusage), 0, 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user