Carbon Dioxide (CO2) Detection

A project log for Frank'n'Sense

Low-cost IoT device with a range of sensors for Building Environmental Monitoring.

David OgilvyDavid Ogilvy 03/12/2016 at 18:265 Comments

Finding a low cost CO2 sensor has been a challenge.

Looking on digikey or element14, all of the commercial sensors start at $130 and go up from there...

Unlike all of the cheap MQ-series sensors, which cost <$10 each, the MG-811 CO2 sensor is around $40-50, requires a high impedence op-amp, and generally requires calibration. The MG-811 is a solid electrolyte sensor, so the base voltage can vary over time (however the change in voltage with CO2 concentration remains quite stable).

The better CO2 sensors are the NDIR type - Non-Dispersive Infrared Sensor.

These are generally quite stable over long periods without requiring re-calibration.

Searching for NDIR sensors, I found the MH-Z14 from Winsen Sensor. It operates from 5V, has PWM and Analog outputs, as well as a serial UART interface.

5V isn't suitable for the ESP8266 UART but level shifters could be used.

However, looking at the Winsen website, I also found the MH-Z19. Similar to the MH-Z14, it operates from 5V power, but has 3.3V signal levels. Perfect. Best of all, it's only $35!

The UART interface looks pretty simple. There are three commands: get reading, calibrate zero point and calibrate span. I have no idea what the span calibration does yet.

Data packet sent to get reading is 9 bytes in length. Fixed 0xFF start byte, sensor address (0x01 default), followed by command byte, then zero padded until the last byte which is a checksum value.

Returned data is: fixed 0xff start byte, command byte echo'd, Reading high byte, Reading low byte, 0x47 (fixed? not sure what this is), zero padding, checksum.

I've got one ordered, so will post more details once I get it up and running.


Dave wrote 02/26/2018 at 13:27 point

Have you tested it? Tried to connect mine, but I just get a zero back and hoped for a good hint.

  Are you sure? yes | no

Simeon G wrote 07/07/2016 at 02:30 point

Looking at some data-sheets, mh-711a, span sets the ppm, the mh-z19 data-sheet shows it can do 0-2000ppm and 0-5000ppm. the example shows 0x07,0xD0 0x07D0=2000. so 0x13,0x88 may set 5000. probably have to calculate the check value though. the extra data may have temperature.

  Are you sure? yes | no

miha.brecl wrote 04/19/2016 at 08:55 point

I'm also testing MH-Z19 on RPi and Arduino pro mini. Not satisfied yet.

  Are you sure? yes | no

miha.brecl wrote 04/19/2016 at 08:40 point

any news?

  Are you sure? yes | no

David Ogilvy wrote 04/19/2016 at 08:51 point

MH-Z19 module arrived a few days ago. Haven't tested it yet. Will update when I do.

  Are you sure? yes | no