From 8bc3b0cb666faf9a576001f257070efb717af8c9 Mon Sep 17 00:00:00 2001 From: Ollo Date: Sun, 28 Nov 2021 19:02:29 +0100 Subject: [PATCH] Read temperatur, when more than 12k RAM is free --- mqtt.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mqtt.lua b/mqtt.lua index 52c7c46..8d90add 100644 --- a/mqtt.lua +++ b/mqtt.lua @@ -215,12 +215,13 @@ function startMqttClient() local mqtttimer = tmr.create() mqtttimer:register(6001, tmr.ALARM_AUTO, function (kTemp) if (mqttConnected) then + local heapusage = node.heap() local temperatur = nil if (oldBrightness ~= briPer) then m:publish(mqttPrefix .. "/brightness", tostring(briPer), 0, 0) oldBrightness = briPer else - if (t ~= nil) then + if ((t ~= nil) and (heapusage > 12000)) then local ds18b20=require("ds18b20_diet") ds18b20.setup(2) -- GPIO4 readTemp(ds18b20) -- read once, to setup chip @@ -234,7 +235,7 @@ function startMqttClient() oldTemp = temperatur m:publish(mqttPrefix .. "/temp", tostring(temperatur/100).."."..tostring(temperatur%100), 0, 0) else - m:publish(mqttPrefix .. "/heap", tostring(node.heap()), 0, 0) + m:publish(mqttPrefix .. "/heap", tostring(heapusage), 0, 0) end end end