summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-01-16 21:45:31 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2024-01-16 21:45:31 +0100
commit817e7fdbb7f7259c0c8ef53002f13a38bc5de734 (patch)
treec9b8ec99026b5439623d8c6e0ba83a4d804afe09
parente134b03803f8b5fb9315381040c160e6a2b50bb5 (diff)
Remove adc_counts; only work with lx output for now
-rw-r--r--README.md9
-rw-r--r--init.lua6
-rw-r--r--temt6000.lua12
3 files changed, 8 insertions, 19 deletions
diff --git a/README.md b/README.md
index 9960e2d..35120e4 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/init.lua b/init.lua
index 646df3b..fd3c74d 100644
--- a/init.lua
+++ b/init.lua
@@ -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)
diff --git a/temt6000.lua b/temt6000.lua
index 69c7110..511e5aa 100644
--- a/temt6000.lua
+++ b/temt6000.lua
@@ -1,17 +1,7 @@
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