Last modified 12 months
- 1 General data of the CO2 sensor MH-Z19B and MH-Z19C and MH-Z19D
- 2 What versions of the MH-Z19 sensor are there?
- 3 Zero Point Calibration
- 3.1 Manual zero point calibration of the MH-Z19, MH-Z19B and MH-Z19C sensors
- 3.2 Self-calibration of the zero point of the MH-Z19, MH-Z19B and MH-Z19C sensors
- 3.3 Should I have the ABC active or inactive?
- 3.4 High point calibration (Span Point)
- 4 Are the temperature sensors on the MH-Z19, MH-Z19B and MH-Z19C reliable?
- 5 Are there different models of the MH-Z19, MH-Z19B and MH-Z19C depending on the detection range?
- 6 Where can I find more information about the MH-Z19, MH-Z19B and MH-Z19C sensors?
- 7 Sensor connection MH-Z19, MH-Z19B and MH-Z19C MH-Z19D
- 8 Data provided by the sensor
- 9 Is it true that there are fake MH-Z19Bs?
- 10 The MH-Z19B label
- 11 Precautions and things to keep in mind
- 12 MH-Z19C Sensor Review
The MH-Z19B NDIR CO2 sensor is fantastic. A Inexpensive, accurate NDIR CO2 sensor (for the price it has) and very easy to use. Without a doubt, one of the most used sensors with Arduino, ESP8266, EPS32 and the like.
Discover all the secrets of the CO2 sensor MH-Z19B in one place. A cheap, accurate CO2 sensor (for the price it has) and very easy to use.
Also the CO2 sensor MH-Z19C (although a bit special) is a good sensor, as long as you know what there is to know about it and what makes it special.
It even has a low-consumption version, the Winsen CO2 NDIR sensor MH-Z1311A.
In this article you will find everything you want to know about these sensors (and if you can't find it, ask for it in the comments).
Maybe calling it a bible, at the moment, is a bit pretentious, but I give you my word that it will become one. Give it time...
This article is alive and it never stops growing. Subscribe to the Newsletter and don't miss a thing.
General data of the CO2 sensor MH-Z19B and MH-Z19C and MH-Z19D
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
|Output signal||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|
The CO2 sensor MH-Z19C
The MH-Z19 sensorC it is very similar to the MH-Z19B although it has some things that make it a bit special ...
Its precision, on paper, is slightly worse than that of the MH-Z19B (50 ppm + 5% of the MH-Z19B measurement vs 50 ppm + 5% of the MH-Z19C.
In practice, and according to my experiments and observations, the MH-Z19C is a much more volatile sensor. Not that it's worse than the MH-Z19B, but I like it less.
The CO2 sensor MH-Z19D
The MH-Z19 sensorD is practically the same as the MH-Z19C. It is very recent (June 2021) so there is not much information about it yet.
This sensor is so new on the market that its manufacturer in English does not even appear on the web, it is necessary to look for it in the Chinese version to find some information (not too much).
I still have not found the official datasheet in English, here you can find the MH-Z19D datasheet in Chinese.
CO2 sensor MH-Z1311A by Winsen
Although I do not include it here, because it is not an MH-Z19x strictly speaking, I could not stop naming the energy saving sensor MH-Z1311A by Winsen.
Cousin 99% compatible with the MH-Z19 with a 99% energy saving.
A very new sensor to consider. We will have to wait for the tests.
If you want to know him better, visit the following blog post:
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.
- MH-Z19B model of 400 ~ 2000 ppm range, which is a more modern and improved version. This version has a precision of 50 ppm + 3% of the measurement.
- 400 ~ 5000 ppm range MH-Z19B model, which is a more modern and improved version. This version has a precision of 50 ppm + 3% of the measurement.
- 400 ~ 10000 ppm range MH-Z19B model, 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-Z19C with range 400 ~ 10000 ppm. This version has an accuracy of 50 ppm + 5% of the measurement.
- Model MH-Z19D with range 400 ~ 2000 ppm. This version has an accuracy of 50 ppm + 5% of the measurement.
- Model MH-Z19D with range 400 ~ 5000 ppm. This version has an accuracy of 50 ppm + 5% of the measurement.
- Model MH-Z19D with range 400 ~ 10000 ppm. This version has an accuracy of 50 ppm + 5% of the measurement.
IMPORTANT: MH-Z19B sensors with black printed circuit board, everything indicates that they are versions they are false.
If you want to know more about fake sensors, you can find all the information here: MH-Z19B FALSE CO2 Sensors
Zero Point Calibration
The MH-Z19B and MH-Z19C sensors they are already factory calibrated and, although under normal conditions manual calibration should not be necessary, I recommend that you calibrate it when you receive it and periodically.
Changes in environmental conditions, such as temperature and humidity, atmospheric pressure, storage and transport conditions and the aging of the sensor itself, cause that, over time, your measurements vary (as with all sensors of this type).
This 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.
Manual zero point calibration of the MH-Z19, MH-Z19B and MH-Z19C sensors
VERY IMPORTANT: It is essential that, during the manual calibration process, the sensor is running beforehand for, at least 20 minutes, in a stable CO2 environment with a fresh air CO2 concentration of 400ppm (outdoors or by a window, for example).
If we have physical access to the sensor connections, we can easily initiate the zero point calibration procedure by connecting together terminals 5 (HD) and 7 (GND) for, at least, 7 seconds.
The sensor has a command, which will command it to perform the zero point calibration at that moment.
We only have to send the command 0xFF, 0x01,0x87,0x00,0x00,0x00,0x00,0x00,0x78
Calibration using ESP Easy
If we are using ESP Easy, among the available commands, we have the command mhzcalibratezero.
We can send the command, for example, by loading the page http: // xxxx / tools? Cmd = mhzcalibratezero (we will replace the xxxx with the IP address of ESP Easy).
Note: The command should be mhzCMDCalibrateZero, but for some reason it doesn't work (at least in the current version of ESP Easy, at the time of writing).
If ESP Easy does not recognize the command mhzcalibratezero, test mhzCMDCalibrateZero (You will know because ESPEasy responds with «Command unknown: mhzCMDCalibrateZero"Or"Command unknown: mhzcalibratezero«).
Self-calibration of the zero point of the MH-Z19, MH-Z19B and MH-Z19C sensors
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 taken will be equivalent to 400 ppm.
This means that in a well-ventilated room, with clean air at some point in the day, the lowest measurement will be around 400 ppm and the sensor will assume that concentration (whatever it is) 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.
Should I have the ABC active or inactive?
It depends on where you have it working.
The ABC works quite well, but for this the sensor has to be in a site that is ventilated at least once a day (up to those, about 400 ppm).
My advice is to activate ABC if the sensor is installed in places such as classrooms, offices, etc., that are not used during the weekend and allow time for the CO2 to drop to room level.
If the sensor is installed in places that are not usually ventilated (indoor rooms that are usually very busy, or greenhouses, for example) better disable ABC.
In a house, it depends ... in my office it does not have time to reach 400 ppm daily because I have it almost always closed (door and window) and I spend many hours in it a day. In the living room there is time because we usually ventilate every day and, although there are more people, it is larger and the door is usually open.
High point calibration (Span Point)
Just as we have a calibration of the lowest point that the sensor is going to measure (the approximately 400 ppm of CO2 found in “clean” outside air), we have the possibility to calibrate the high point of the measurement (for example, at 2000 ppm).
In my opinion this calibration not available to fans, since you have to achieve a stable and calibrated atmosphere with exactly 2000 ppm of CO2 and that is tremendously difficult without the adequate laboratory resources.
My recommendation is that don't even think about trying to calibrate the Span Point on your own. Logically, if you have access to the necessary laboratory, surely you have the necessary knowledge to do it, in which case, go ahead ...
If you decide to do so despite the warnings, the method is very similar to zero point calibration.
- Do the zero point calibration first, as explained above
- Put the sensor in a stable environment at 2000 ppm
- Allow the sensor to stabilize for a minimum of 20 minutes
- Send the Span Point Calibration command to the sensor
The command to send is 0x88 and you can find it in the datasheet that I have left you before with its parameters.
This command will not be able to send it directly from ESP Easy.
Are the temperature sensors on the MH-Z19, MH-Z19B and MH-Z19C reliable?
No, they are not at all.
Please note that the temperature sensor it's only for internal use of the sensor, to be able to do the temperature compensation. Its use is really undocumented by the manufacturer and we are using it based on reverse engineering of the possible commands and responses (come on, it's a hack).
Are there different models of the MH-Z19, MH-Z19B and MH-Z19C depending on the detection range?
The sensor looks like is exactly the sameregardless of the detection range. In fact, it is possible to change the detection range by software, sending a command to the sensor.
You can find information about the command to send in the datasheet.
The accuracy of the MH-Z19, MH-Z19B and MH-Z19C sensors up to 2000 ppm is surprisingly good. Above 2000 ppm the accuracy progressively deteriorates.
Where can I find more information about the MH-Z19, MH-Z19B and MH-Z19C sensors?
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:
You can find a lot of information, although scattered, in the ESP Easy 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.
Sensor connection MH-Z19, MH-Z19B and MH-Z19C MH-Z19D
The basic connection of the MH-Z19, MH-Z19B and MH-Z19C sensors 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
MH-Z19D: 4.9 to 5.1 Volts DC
Have watch out for the MH-Z19C (and MZ-Z19D). 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 don't have a multimeter to measure that the voltage that reaches the MH-Z19C is within these ranges, I recommend avoiding it. In addition, it is important that this tension is well stabilized.
You have more information here.
It is important that you check your specific sensor pins, as some users have reported variations.
Anyway, don't worry, you can see in the serigraphy of the sensor which corresponds to each of the pins:
Old MH-Z19 pins (long gone).
Pins of the MH-Z19B. This sensor is still sold, but has been replaced by the MH-Z19C
Pins of the MH-Z19C. Latest version of sensor. Currently sold.
There are versions of this sensor with connector, instead of pins.
Below, you can see the connection of the main pins.
You will see that I have only marked four wires, and that is because in the tests I have done with different versions of the MH-Z19 sensor (including the fake ones) only these four connections have matched in all. The rest may vary.
I recommend that, if you have any questions, and Before connecting, make sure how your specific sensor is wired.
If you discover a sensor with different wiring, please let me know to include the information
The sensor is a delicate measuring instrument. You should take the following precautions when mounting:
- The sensor is sensitive to static electricity - Avoid touching the pins with your fingers as much as possible.
- Before touching the sensor, touch something with your hand, which is grounded, to discharge static electricity (a water or heating pipe, for example).
- The case is not just a box. It is an active part of the sensor - Be careful not to force it.
- The sensor is sensitive to high temperatures - Solder it with a low power electronic soldering iron (about 30w can be fine) and don't apply heat to the pins for too long. Let it cool between soldering one pin and the next.
Data provided by the sensor
The sensor provides three pieces of information with each measurement:
PPM: It is the CO2 concentration at that moment. Is the only data which must be used by the user.
T: It is the internal sensor temperature. This is a internal data which the sensor uses to adjust CO2 measurements as they are temperature dependent, and should not be used by the user. There are huge differences in the temperature reported from one sensor to another.
OR: Nobody knows what the U-value is for sure. What is known is that it is a internal parameter what has to do with him ABC (zero point autocalibration) and with the CO₂ concentrations that the sensor has detected in the last cycle of ABC, but nothing else. Some versions of the sensor always provide this value at 0.
Is it true that there are fake MH-Z19Bs?
Yes there are, unfortunately, so you have to be careful where you buy.
I have written a full article on that because it is affecting a lot of people. If you are going to buy one of these sensors, or you already have one, be sure to read it.
The MH-Z19B label
The MH-Z19B paper label, affixed to the side, shows the sensor model, the measuring range with which it left the factory (can be changed later with a command) and what It seems be a date (possibly of manufacture, calibration or quality control), and a QR code.
It is curious because in false sensors this date doesn't seem to make sense. In the photo sensor, what we assume is the "date" indicates December 25, 2020 (Christmas Day) and the seller sent it to me on December 25, 2020.
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 casing during welding, installation and use.
- When installed in a small space, the space must be well ventilated, especially your broadcast windows.
- The module must be away from heat sources and its direct exposure to the sun or other sources of heat should be avoided.
- The module must be periodically calibrated. 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.
- Do not use the sensor in an environment dusty for too much time.
- Check the requirements of feeding of your specific model (see your specific version in the "MH-Z19B connection" section of this article). The source current should 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).
- Prior to the manual zero point calibration procedure, the sensor must be operated 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 solder or dip 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 (solder it fast, Do not entertain).
MH-Z19C Sensor Review
Variation with supply voltage
As I have been saying for a long time, I don't recommend the MH-Z19C sensor at all, in a general way, and here I am going to document some of the conclusions that I have reached through some tests that I am going to describe.
This sensor has a major problem with eating, since the operating voltage range is very narrow (of 4.9V to 5.1V according to the manufacturer, although as we will see it is even narrower).
This very narrow supply voltage is very difficult to keep stable and many of the USB power supplies we use provide values above and below this voltage.
In addition, there is another added problem that, although it can be minimized with a good design, it is not easy for the average hobbyist: This type of sensors have a relatively high consumption, which causes drops in the power supply produced in the circuit cables themselves ( it is normal that these drops can be 0.2V ~ 0.4V and even higher), which makes it extremely difficult to have a stabilized supply voltage.
In this first test I have kept the sensor working for about 10 hours powered by a programmable laboratory power supply that modified the supply voltage every 60 seconds between 4.5V and 5.15V in steps of 0.5V. That is: it fed the sensor at 4.5V for 60 seconds, it switched to 4.55V for another 60 seconds, 4.6V for another 60 seconds and so on (when it reached 5.15V it switched to 4.95V for 5 minutes, to stabilize it, and restart the cycle at 4.5V.
In order to see the deviation in the CO2 concentration measurements provided as the supply voltage changed, I have compared to my reference sensor, a Senseair S8.
In the graph you can see how the CO2 measurement reported by the MH-Z19C (in green) was changing with the supply voltage (in blue) and its deviation with respect to the Senseair S8 reference sensor (in orange).
It may seem that the differences are not very important, but if we zoom in on a shorter period of time:
And if we go even more in detail we will clearly see the oscillations of the MH-Z19C sensor:
Notice how in the period of feeding with 4.95V for 5 minutes the MH-Z19C slowly stabilizes.
In the graphs above, you may have noticed the large differences in CO2 concentration reported by both sensors.
The MH-Z19C was brand new, with its factory calibration and ABC disabled (disabled in its first minute of operation after connecting it for the first time to maintain its factory calibration).
The Senseair S8, although it has not been calibrated for a few weeks, is my reference sensor and does not usually show (taking 5-minute moving averages) more than 80 ppm deviation compared to my other sensors. reliable that I have running simultaneously in the same room (Winsen MH-Z19A, Cubic CM1106 and Senseair Sunrise).
As you can see, the calibration of the MH-Z19C sensor is quite far from the correct point. Most surprisingly, this sensor came with a Winsen calibration certificate. This type of certificate does not seem to be very reliable and it seems more like a marketing element by this Chinese manufacturer than anything else.
Essential: Stabilize the power supply of the MH-Z19C
Okay, the differences seen in the measurements from the previous test are very subtle, but now we will see that it's a lot worse than it looked, and no wonder some people did not see a problem in those measurements. It is not very difficult for me to know that something is wrong because I have done many, many tests with CO2 sensors and I have dedicated many, many hours to their analysis. So I've done another "real world" test to make what is going on more clearly:
In this graph you can see the measurements of the MH-Z19C (in green) put to the test together with my reference Senseair S8 LP sensor (yellow line) and the supply voltage of the MH-Z19C (blue line) for a period of ten days.
In the first part the sensor is powered through a USB charger multiple with a capacity of 2.5A per port. In the second, I have included in the diet a voltage stabilizer (a step up down), but how the MH-Z19C power supply is stabilized at 5.0V (Even if you see that it is on the 5.2V line, that is because I did not go to much trouble to calibrate the voltage divider and the small power "spikes" are due to the ADC noise of the ESP8266, which is not very good ).
In the first part you can see how the blue line fluctuates (remember, the supply voltage of the MH-Z19C) and with it the CO2 measurement, introducing noise, jumps and spikes nonexistent.
I recommend that you click on the image to see it larger and even zoom in on it. You will see that it has all kinds of problems: non-existent large peaks, slow measurements, saw teeth, etc.
In the second part, with the MH-Z19C power supply is stabilized at 5.0V, the CO2 measurement stays close to the Reference Sensor measurement all the time.
Conclusions with the MH-Z19C
Based on my tests, it seems clear that the MH-Z19C sensor is a good sensor and can be used without problems as long as the supply voltage stabilizes at 5.0V always.
If you feed it with a USB power supply / charger you have to put the stabilizer ALREADY. These devices do not provide the quality of voltage stabilization that the MH-Z19C needs,
I leave you here, in case it suits you, the link to voltage stabilizer in AliExpress. It is the same place where I bought it. For what it costs, it's very worth it.
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?