MHZ19: Difference between revisions

From RevSpace
Jump to navigation Jump to search
No edit summary
No edit summary
Line 19: Line 19:
A new measurement is started every 5 seconds, you can actually see a small amount of light coming out of the sensor while it's measuring.
A new measurement is started every 5 seconds, you can actually see a small amount of light coming out of the sensor while it's measuring.


The MH-Z19 is the cheapest optical CO2 sensor I could find on AliExpress.
The MH-Z19 is the cheapest optical CO2 sensor I could find on AliExpress, about E22,-.
 
== Hardware and reference data ==
See [http://www.winsen-sensor.com/products/ndir-co2-sensor/mh-z19.html the manufacturer MH-Z19 page].
 
== Software ==
See [https://github.com/bertrik/mhz19 this github repo] for code using this sensor with an ESP8266 board (WeMos D1 mini).
It publishes the CO2 concentration to topic "bertrik/co2" on test.mosquitto.org every 5 seconds.
 
It seems that support for this sensor was recently added to [https://www.esp8266.nu/index.php/ESPEasy ESPEasy].
 
=== Extended commands ===
Normally, this sensor is read out using a command/response sequence over serial.
 
It appears that there are some additional command beyond just reading the CO2 concentration:
* some calibration commands, e.g. to let the sensor know when it's breathing pure nitrogen (0 ppm), or some reference gas with a known CO2 concentration (e.g. 400 ppm)
* command XX, to enable/disable the ABC-algorithm (automatic baseline correction)
* command YY, to set the measurement range of the sensor in steps of 1000 ppm
 
Some of these commands appear in the MHZ-19<bold>B</bold> datasheet, but appear to work a little differently for the MH-Z19.

Revision as of 10:15, 22 October 2016

Project MHZ19
Mhz19.jpg
Some research into the MH-Z19 CO2 sensor
Status Initializing
Contact bertrik
Last Update 2016-10-22

Introduction

This page is about the MH-Z19 CO2 sensor and some experiments done with it.

This sensor gives a digital (serial) output of the CO2 concentration in air, in parts-per-million (ppm). It uses the optical measurement principle of measuring CO2, which should be much more accurate than the inexpensive electro-chemical sensors you can find. As far as I know, the optical measurement principle uses a broadband light-source to send some light through an air-sample. The sensor then looks at the relative intensity of the light at two different frequencies. The CO2 gas inside the air absorbs light strongly at very specific wavelengths, allowing a determination of the concentration (ppm) of CO2. This is then compensated for temperature and pressure for increased accuracy. See also wikipedia for this measurement principle. A new measurement is started every 5 seconds, you can actually see a small amount of light coming out of the sensor while it's measuring.

The MH-Z19 is the cheapest optical CO2 sensor I could find on AliExpress, about E22,-.

Hardware and reference data

See the manufacturer MH-Z19 page.

Software

See this github repo for code using this sensor with an ESP8266 board (WeMos D1 mini). It publishes the CO2 concentration to topic "bertrik/co2" on test.mosquitto.org every 5 seconds.

It seems that support for this sensor was recently added to ESPEasy.

Extended commands

Normally, this sensor is read out using a command/response sequence over serial.

It appears that there are some additional command beyond just reading the CO2 concentration:

  • some calibration commands, e.g. to let the sensor know when it's breathing pure nitrogen (0 ppm), or some reference gas with a known CO2 concentration (e.g. 400 ppm)
  • command XX, to enable/disable the ABC-algorithm (automatic baseline correction)
  • command YY, to set the measurement range of the sensor in steps of 1000 ppm

Some of these commands appear in the MHZ-19<bold>B</bold> datasheet, but appear to work a little differently for the MH-Z19.