diff options
author | Daniel Friesel <derf@finalrewind.org> | 2022-05-26 07:52:52 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2022-05-26 07:53:05 +0200 |
commit | 102dd0072d34fa081f5861148be61c0c3739827c (patch) | |
tree | 301fe5c2bb61d06da0db3e45cf573509a85e5fd3 /init.lua | |
parent | ee6a1033c293f3d3b327568fe9554d4651c4c964 (diff) |
verify checksum, parse automatic baseline correction data
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -16,7 +16,7 @@ ledpin = 4 gpio.mode(ledpin, gpio.OUTPUT) gpio.write(ledpin, 0) -mhz19 = require("mh-z19") +mh_z19 = require("mh-z19") poll = tmr.create() @@ -58,13 +58,13 @@ function connect_wifi() end function uart_callback(data) - if not mhz19.parse_frame(data) then + if not mh_z19.parse_frame(data) then print("Invalid MH-Z19 frame") return end - local json_str = string.format('{"rssi_dbm":%d,"co2_ppm":"%d"}', wifi.sta.getrssi(), mhz19.co2) - local influx_str = string.format("co2_ppm=%d", mhz19.co2) + local json_str = string.format('{"rssi_dbm":%d,"co2_ppm":"%d"}', wifi.sta.getrssi(), mh_z19.co2) + local influx_str = string.format("co2_ppm=%d", mh_z19.co2) if not publishing_mqtt then watchdog:start(true) @@ -94,7 +94,7 @@ function publish_influx(payload) end function query_data() - port:write(mhz19.query()) + port:write(mh_z19.c_query) end function hass_register() |