kizniche / Mycodo

An environmental monitoring and regulation system
http://kylegabriel.com/projects/
GNU General Public License v3.0
2.96k stars 494 forks source link

MH-Z19B automatic baseline correction (ABC) can introduce errors in closed environments #545

Closed Theoi-Meteoroi closed 5 years ago

Theoi-Meteoroi commented 5 years ago

Mycodo Issue Report:

Problem Description

The MH-Z19B sensor is shipped with automatic baseline correction enabled. This means the sensor will recalibrate every 24 hours to a baseline (400ppm) assuming the current measured concentration is back to ~400ppm. If used in an enclosure that is not vented it is possible to disrupt the linear response of the sensor and make readings incorrect. This re-calibration is not usually needed more often that about 4-6 months.

Re-calibrating zero and span is not trivial and shouldn't be necessary.

Errors

The error will be in the linearity of response for this sensor if ABC is not disabled in long term use.

Steps to Reproduce the issue:

How can this issue be reproduced?

  1. Use the MH-Z19B sensor in enclosure with either persistent high or low concentrations of CO2.
  2. Observe comparison readings from MH-Z16 sensor without ABC
  3. Note the large differences in readings over time.
  4. Place both sensors in normal room (~400ppm) air for 48 hours
  5. Note that eventually readings will match as MH-Z19B re-corrects improper offset.

Additional Notes

I saw this issue in experimentation by running multiple sensors in the same graph and observing odd readings. Further research online surfaced this problem - eventually I found a version of the datasheet that mentioned explicitly how to turn the ABC feature off.

mh-z19b-co2-ver1_0.pdf

When you look at the notes section for the command to turn off ABC, Winsen declares:

All Winsen sensor with ABC logic on before delivery if no special request.

I have found discussions ( one google translated from russian, so kinda fun to read ) that focus on hacking these by just fuzzing the serial port.

MH-Z19 should disable ABC mode (Auto Base Calibration) upon init · Issue #466 · letscontrolit:ESPEas.pdf

MHZ19 - RevSpace.pdf

In Russian - use google translate and it mostly comes through. Mostly.

I'll work on the code changes to address this and submit a pull request.

kizniche commented 5 years ago

Added the option to disable ABC (disabled by default) in the latest version (unreleased)