-
Notifications
You must be signed in to change notification settings - Fork 115
MH-Z19 sensor: disable auto-calibration and some odd fixes #592
base: dev
Are you sure you want to change the base?
Conversation
Reported CO2 might be not correct while sensor is booting and while it boots it report value 15000 in response at offset 6-7. So skip reporting till this value is reported. Signed-off-by: Igor Mammedov <[email protected]> --- Idea is taken from ESPEasy implementation.
it will allow to report exact sensor type in dump config and later will be used for turning off autocalibration. Signed-off-by: Igor Mammedov <[email protected]>
MH-Z19B allows to enable/disable 'automatic baseline calibration'[*], which is enabled by default (MH-Z19B v1.2 datasheet). It operates on too short 24hr interval. So if the place where sensor is located is not ventilated well Every day, ABC will under-report CO2 since baseline (400ppm) is moved to lowest observed value in 24hr. With such short recalibrartion window, sensor often doesn't show correct CO2 levels when ABS is left enabled. Disable it on boot unconditionally. Signed-off-by: Igor Mammedov <[email protected]>
When sensor is connected to hardware uart, sometimes on boot uart's RX buffer contains several bytes of junk. Workaround it by consuming all of it before sending command. Also turn on cleanup logic only if problem is detected (i.e. when reply from sensor doesn't look correct. Signed-off-by: Igor Mammedov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Automatic baseline correction should probably indeed be turned off.
Also See #591 (comment)
* TODO: implement an option to recalibrate sensor, to allow for occasional | ||
* manual recalibration | ||
*/ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole block sounds a bit more like it should go in the setup()
function. We should probably move it there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried it first but then node hangs for good (had to restart mcu several times before I was able to flash it again) on boot. With UART0 occupied by sensor without hardware to read log from UART1 output, I don't have means to debug it.
I'd still like to move it to setup, but don't know how to fix boot issue.
|
||
/* | ||
* UART0 in NodeMCU v2, sometimes on boot has junk in RX buffer, | ||
* check for it and drain all of it before sending commands to sensor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm the flush
command should flush the RX buffer (naming is bad, but copied from arduino core). If it does not do so that would be a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's make on it as well,
but got arduino/esp only a couple days ago so I'm not sure where to look for respective code
and this workaround fixed non working sensor for me.
If it's within this git repo and you can point out to related code, I'll give it a try.
Description:
Checklist:
If user exposed functionality or configuration variables are added/changed: