-
Notifications
You must be signed in to change notification settings - Fork 639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MH-Z19 sensor has disabled auto-calibrating #1580
Comments
Regarding #1592 , it disables calibration and then re-enables it again. Maybe just wire things in the sensor::begin() + additional flag after read to send calibration setting? And because calibrateAuto() calls yield() + does serial reads / writes, I think it will straight up crash when saving settings in the web interface. I was looking at the ESPEasy MHZ code, pdf and referenced articles: Plugin waits for sensor to settle before disabling the calibration. And, technically, there is no need to enable it on boot as it is already enabled. |
I've added disabling of auto-calibration to the _sensorConfigure method because all other code related to calibration is present there.
|
Looks like it. Datasheet claims that it is on by default on boot. letscontrolit/ESPEasy#466 (comment), letscontrolit/ESPEasy#466 (comment) even suggests sending this value every 24h, but idk why would sensor reset it's settings. From pdf for 1.0:
And based on the links above, code should probably check if sensor is booting up and apply calibration setting after that.
I see the reasoning, but the problem is that it calls yield(), which will panic system when called from system context (lwip callback aka websocket request handler). So either configuring needs to happen in loop() or calibration command needs to happen somewhere else. |
What do you think then if we remove calibrateAuto(false); from MHZ19Sensor.begin() method and execute it from _sensorConfigure only if getSetting("mhz19CalibrateAuto", 0).toInt() != 1 ? |
It can stay in begin() and setting can be passed to the sensor via some setter method, like pins do. And force sensor to send calibration command when value changes.
edit to clarify, sry |
OK, pushed new version |
Added that. |
MH-Z19 sensor with auto-calibrating disabled can show incorrect values when working for a long time
I see that the library has the required methods (calibrateAuto/calibrateZero/calibrateSpan) but they are not used anywhere except setting autocalibrating to false during initialization
Ideally, there should be GUI setting disabling or enabling autocalibration and also command calibrating device to zero. But since this functionality is very custom, I think having settings parameter that could be adjusted in the text file and restored using admin page should be enough
The text was updated successfully, but these errors were encountered: