Last modified January 12, 2021
The MH-Z19B CO2 sensor is fantastic. A cheap, accurate CO2 sensor (for the price it has) and very easy to use. The same one that I used to make the CO2 meter.
In this article you will find everything you want to know about it (and if you can't find it, ask in the comments).
Maybe calling it bible, at this moment (12/27/2020, when I start to write it), is a bit pretentious, but I give you my word that it will become. Give it time…
This article is alive and it never stops growing. Subscribe to the Newsletter and don't miss a thing.
During the next few weeks I plan to include a lot of information that I have been collecting, but, If you want any special information, tell me in the comments, to give it priority.
- 1 General data of the CO2 sensor MH-Z19B
- 2 What versions of the MH-Z19 sensor are there?
- 3 Zero Point Calibration
- 4 Where can I find more information about the MH-Z19B sensor?
- 5 MH-Z19B connection
- 6 Is it true that there are fake MH-Z19Bs?
- 7 Precautions and things to keep in mind
General data of the CO2 sensor MH-Z19B
CO₂ sensor MH-Z19B
The MH-Z19B Carbon Dioxide Gas Sensor is a small-sized, general-purpose smart sensor that uses the principle of non-scattered infrared (NDIR) to detect the presence of CO₂ in the air.
It has good selectivity, long service life, and other characteristics, such as built-in temperature compensation.
It has simultaneous serial, analog and PWM output and is easy to use.
It is a high-performance sensor that combines reliable infrared absorption gas detection technology with good design and an attractive price.
MH-Z19B sensor parameters
|Gas detected||Carbon dioxide|
|Operating voltage||4.5 ~ 5.5 V DC|
|Average current||<60m A (@ 5V supply)|
|Peak current||150 mA (supply @ 5V)|
|Interface level||3.3 V (compatible with 5V)|
|Measuring range||0 ～ 2000 ppm
0 ～ 5000 ppm
|exit sign||Serial (UART) - TTL level 3.3 V - PWM analog output|
|Preheating time||3 minutes|
|Operating temperature||0 ~ 50 ° C|
|Operating humidity||0 to 90% RH (non-condensing)|
|Dimensions||33mm × 20mm × 9mm (Length * Width * Height)|
|Lifetime||> 5 years|
|Gold-plated gas chamber, waterproof and corrosion resistant|
|High sensitivity, low power consumption|
|Temperature compensation, excellent linear output|
MH-Z19B Sensor Applications
|HVAC Refrigeration Equipment|
|Surveillance and air quality equipment|
|Fresh air systems|
|Air purification equipment|
|Schools and educational centers|
What versions of the MH-Z19 sensor are there?
It is difficult to know exactly, since Chinese manufacturers are quite used to making changes to their products without communicating them and, sometimes, there is a parallel market for units marked with other names or references.
Rest assured, there are the following versions:
- The original 400 ~ 2000ppm range MH-Z19 model, with 50ppm + 5% precision accuracy of the measurement.
- The original 400 ~ 5000ppm range MH-Z19 model, with 50ppm + 5% precision accuracy of measurement.
- Model MH-Z19B with range 400 ~ 2000 ppm, which is a more modern and improved version. This version has a precision of 50 ppm + 3% of the measurement.
- Model MH-Z19B with range 400 ~ 5000 ppm, which is a more modern and improved version. This version has a precision of 50 ppm + 3% of the measurement.
- Model MH-Z19C with range 400 ~ 2000 ppm. This version has an accuracy of 50 ppm + 5% of the measurement.
- Model MH-Z19C with range 400 ~ 5000 ppm. This version has an accuracy of 50 ppm + 5% of the measurement.
- Model MH-Z19B with range 400 ~ 10000 ppm. All that I discover up to this moment, makes me think it's fake.
- Model MH-Z19B with ranges 400 ~ 2000 ppm, 400 ~ 5000 ppm and 400 ~ 10000 ppm with black printed circuit board. Everything indicates that these versions are false.
Zero Point Calibration
The MH-Z19B sensor is pre-calibrated at the factory and, under normal conditions, manual calibration should not be necessary.
Like all sensors of this type, changes in environmental conditions, such as temperature and humidity, and the aging of the sensor itself, cause its measurements to vary over time.
Zero point calibration refers to the method by which the sensor learn at what concentration of CO2 corresponds to a concentration of 400 ppm, or zero point.
This sensor has two methods to perform the zero point calibration: manual calibration and self-calibration.
MH-Z19B Sensor Zero Point Manual Calibration
VERY IMPORTANT: It is essential that, during this manual calibration process, the sensor is pre-operating for at least 20 minutes in a stable CO2 environment (400ppm) (outdoors, for example).
If we have physical access to the sensor connections, we can easily begin the zero point calibration procedure, bypassing terminals 5 (HD) and 7 (GND) for 7 seconds.
The sensor has a command, which will order it to perform the zero point calibration at the same time.
We only have to send the command 0xFF, 0x01,0x87,0x00,0x00,0x00,0x00,0x00,0x78
Calibration using ESPEasy
If we are using ESPEasy, among the available commands, we have the mhzcalibratezero command.
We can send the command, for example, loading the page http: // xxxx / tools? Cmd = mhzcalibratezero (we will replace the xxxx with the ESPEasy IP address).
Note: The command should be mhzCMDCalibrateZero, but for some reason it doesn't work (at least in the current version of ESPEasy, at the time of writing this article).
If ESPEasy does not recognize the command mhzcalibratezero, test mhzCMDCalibrateZero (You will know because ESPEasy responds with «Command unknown: mhzCMDCalibrateZero"Or"Command unknown: mhzcalibratezero«).
MH-Z19B sensor zero point auto-calibration
To avoid the user having to perform a manual calibration periodically, the sensor incorporates in its firmware an autocalibration routine, called ABC, which works as follows:
Since the natural CO2 concentration in the atmosphere is approximately 400 ppm, when ABC is enabled, the sensor assumes that, over a 24 hour period, the minimum measurement it takes will be equivalent to 400 ppm.
This means that, in a well-ventilated room, which at some time of the day has clean air, the lowest measurement will be 400 ppm and the sensor will assume it as the zero point, or 400 ppm.
In other words, the sensor will assume that the lowest measurement in each 24 hour period will be 400 ppm.
This is a very convenient way to keep the sensor calibrated, using clean air as a reference value and automating the process.
In addition, we can easily activate and deactivate the ABC routine, so that we can adapt the way the sensor works to our particular needs.
Where can I find more information about the MH-Z19B sensor?
There are a number of sources of information, official and unofficial, very interesting, if you want to get more information about the sensor.
The official source par excellence of any electronic component is its datasheet, or data sheet. It is the document in which the manufacturer includes all the information about its product.
Manufacturer data sheets:
MH-Z19 DatasheetC in english from 02-04-2020 (available on AliExpress https://s.click.aliexpress.com/e/_AOPAxf). I have not tested this version with ESPEasy yet, nor do I have direct references on how it works.
You can find a lot of information, although scattered, in the ESPEasy official forum.
Although it is not easy to locate, because it is very scattered, I have learned a lot by studying the source code that I have been able to find to use the MH-Z19B. GitHub is a great source of information, in this regard.
The basic connection of the MH-Z19B sensor is very easy, it only requires four connections. Two for power and two for data transmission.
I recommend looking carefully at the power requirements for your specific sensor. Depending on the version, the acceptable operating voltage may vary.
According to the manufacturer's data sheets, the following operating voltages are accepted:
MH-Z19: 3.6 to 5.5 Volts DC
MH-Z19B: 4.5 to 5.5 Volts DC
MH-Z19C: 4.9 to 5.1 Volts DC
Have watch out for the MH-Z19C. Getting a supply of between 4.9 volts and 5.1 volts (a very narrow range) from a USB port can be "delicate" And if you do not have a multimeter to measure that the voltage that reaches the MH-Z19C is within these ranges, I recommend avoiding it.
It is important that you check the pins for your specific sensor, as some users have reported variations.
As a general rule, most MH-Z19B sensors follow the following pinning (images taken from the MH-Z19 and MH-Z19B sensor datasheets)
Is it true that there are fake MH-Z19Bs?
It seems that it does, unfortunately, so you have to be careful where you buy it.
These are especially warning signs:
- MH-Z19B models with measuring range up to 10,000 ppm. All that I discover up to this moment, It makes me think that all models with a measuring range up to 10,000 ppm are fake.
- Model MH-Z19B with black printed circuit board. Everything indicates that these versions with black printed circuit board are fake.
Updated Jan 8, 2021: I recently received a fake MH-Z19B (with black plate) that I bought from AliExpress.
I will take the opportunity to write an article with detailed information about fake sensors, how to detect them and the differences in the measurements they provide.
I already tell you that, at least in the one I have with a black plate, the differences in the measurements are enormous (compared to the meter with the Senseair S8 LP detector that I am using as a reference).
Precautions and things to keep in mind
There are a few basic things to watch out for, and while most are obvious, it doesn't hurt to put them together here under one point:
- Avoid any pressure, in any direction, on the plastic housing during its welding, installation and use.
- When installed in a small space, the space should be well ventilated, especially its diffusion windows.
- The module must be away from heat sources and its direct exposure to the sun or other heat sources must be avoided.
- The module must be calibrated periodically. The manufacturer suggests that it be done every six months. Logically this will depend on the use made of it and the environment in which it is used.
- Please do not use the sensor in a dusty environment for too long.
- To ensure normal work, the power supply must be in a range between 5.0V ± 0.1V DC (check your specific version in the "Connecting the MH-Z19B" section of this article). The source current must not be less than 150mA. Outside of this range, it will cause a sensor malfunction (it may indicate a CO2 concentration lower than actual, or the sensor may not function properly).
- During the manual zero point calibration procedure, the sensor must operate in a stable gas environment (400ppm) for more than 20 minutes. Connect the HD pin low (0V) for more than 7 seconds.
- Do not use wave or dip solder for the sensor.
- When welding with a soldering iron, the temperature should be set at (350 ± 5) ° C, and the welding time should be 3 seconds maximum.