local t = require("DS1820") local pin = 1 function adc_read() local ao = adc.read(0) print(ao) end local function readout(temp) if t.sens then print("Total number of DS18B20 sensors: ".. #t.sens) for i, s in ipairs(t.sens) do print(string.format(" sensor #%d address: %s%s", i, ('%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X'):format(s:byte(1,8)), s:byte(9) == 1 and " (parasite)" or "")) end end for addr, temp in pairs(temp) do --if tonumber(temp) < 20000 then print(string.format("Sensor %s: %s °C", ('%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X'):format(addr:byte(1,8)), temp)) --end end -- Module can be released when it is no longer needed --t = nil --package.loaded["ds18b20"] = nil end local function read() t:read_temp(readout, pin, t.C) end if adc.force_init_mode(adc.INIT_ADC) then node.restart() return -- don't bother continuing, the restart is scheduled end timer = tmr.create() timer:register(7000, tmr.ALARM_AUTO,read) timer:start() sensorstimer = tmr.create() sensorstimer:register(5000, tmr.ALARM_AUTO, adc_read) sensorstimer:start()