Loading README.md +4 −5 Original line number Diff line number Diff line Loading @@ -41,13 +41,12 @@ temt6000 = require("temt6000") -- can be called as often as the ADC permits function some_timer_callback() local lx, raw = temt6000.read() local lx = temt6000.read() if lx ~= nil then -- lx: estimated illuminance [lx] -- raw: raw ADC counts -- Note that lx is limited to a usable range of about 20 to 2500 lx. -- Darkness cannot be detected properly, -- anything brighter than ~2500 lx will be reported as 2500 lx. -- Note that lx is limited to a usable range of about 20 to 1000 lx. -- Darkness cannot always be detected reliably, -- anything brighter than ~1024 lx will be reported as 1024 lx. else print("TEMT6000 error") end Loading init.lua +3 −3 Original line number Diff line number Diff line Loading @@ -55,12 +55,12 @@ function connect_wifi() end function push_data() local lx, raw = temt6000.read() local lx = temt6000.read() if lx == nil then print("TEMT6000 error") else local json_str = string.format('{"illuminance_lx": %d, "adc_counts": %d, "rssi_dbm": %d}', lx, raw, wifi.sta.getrssi()) local influx_str = string.format("illuminance_lx=%d,adc_counts=%d", lx, raw) local json_str = string.format('{"illuminance_lx": %d, "rssi_dbm": %d}', lx, wifi.sta.getrssi()) local influx_str = string.format("illuminance_lx=%d", lx) if not publishing_mqtt then publishing_mqtt = true watchdog:start(true) Loading temt6000.lua +1 −11 Original line number Diff line number Diff line local temt6000 = {} function temt6000.read() local raw = adc.read(0) if raw < 70 then return raw, raw end if raw == 1024 then return 2500, raw end if raw < 300 then return (raw-70) * 2, raw end return raw * 2, raw return adc.read(0) end return temt6000 Loading
README.md +4 −5 Original line number Diff line number Diff line Loading @@ -41,13 +41,12 @@ temt6000 = require("temt6000") -- can be called as often as the ADC permits function some_timer_callback() local lx, raw = temt6000.read() local lx = temt6000.read() if lx ~= nil then -- lx: estimated illuminance [lx] -- raw: raw ADC counts -- Note that lx is limited to a usable range of about 20 to 2500 lx. -- Darkness cannot be detected properly, -- anything brighter than ~2500 lx will be reported as 2500 lx. -- Note that lx is limited to a usable range of about 20 to 1000 lx. -- Darkness cannot always be detected reliably, -- anything brighter than ~1024 lx will be reported as 1024 lx. else print("TEMT6000 error") end Loading
init.lua +3 −3 Original line number Diff line number Diff line Loading @@ -55,12 +55,12 @@ function connect_wifi() end function push_data() local lx, raw = temt6000.read() local lx = temt6000.read() if lx == nil then print("TEMT6000 error") else local json_str = string.format('{"illuminance_lx": %d, "adc_counts": %d, "rssi_dbm": %d}', lx, raw, wifi.sta.getrssi()) local influx_str = string.format("illuminance_lx=%d,adc_counts=%d", lx, raw) local json_str = string.format('{"illuminance_lx": %d, "rssi_dbm": %d}', lx, wifi.sta.getrssi()) local influx_str = string.format("illuminance_lx=%d", lx) if not publishing_mqtt then publishing_mqtt = true watchdog:start(true) Loading
temt6000.lua +1 −11 Original line number Diff line number Diff line local temt6000 = {} function temt6000.read() local raw = adc.read(0) if raw < 70 then return raw, raw end if raw == 1024 then return 2500, raw end if raw < 300 then return (raw-70) * 2, raw end return raw * 2, raw return adc.read(0) end return temt6000