- 1 General data CO2 sensor MH-Z19B and MH-Z19C and MH-Z19D
- 2 Which versions of the MH-Z19 sensor are available?
- 3 Zero Point Calibration
- 3.1 Manual zero point calibration of the sensors MH-Z19, MH-Z19B and MH-Z19C
- 3.2 Auto-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 Span Point Calibration
- 4 Are the temperature sensors of 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 Connection of the sensors 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 Analysis of the MH-Z19C sensor
The MH-Z19B NDIR CO2 sensor is fantastic. A cheap, accurate NDIR CO2 sensor (for the price it has) and very easy to use. Undoubtedly, one of the most used sensors with Arduino, ESP8266, EPS32 and similar.
Discover all the secrets of the CO2 sensor MH-Z19B in one place. A cheap, accurate CO2 sensor (for the price) and very easy to use.
Also CO2 sensor MH-Z19C (although a bit special) is a good sensor, as long as you know what you need to know about it and what makes it special.
It even has a low-energy version, the NDIR CO2 sensor Winsen MH-Z1311A.
In this article you will find everything you want to know about these sensors (and if you can't find it, ask 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 anything.
General data CO2 sensor MH-Z19B and MH-Z19C and MH-Z19D
CO₂ sensor MH-Z19B
The carbon dioxide gas sensor MH-Z19B is an intelligent, small, general-purpose sensor, which uses the principle of non-dispersive infrared (NDIR) to detect the presence of CO₂ in the air.
It has good selectivity, long lifetime and other features, such as integrated temperature compensation.
It has simultaneous serial, analogue 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|
|Medium current||< 60m A (@ 5V supply)|
|Maximum current||150 mA (supply @ 5V)|
|Interface level||3.3 V (5V compatible)|
|Measuring range||0～2000 ppm
|Output signal||Serial (UART) - TTL level 3.3 V - Analogue output PWM|
|Preheating time||3 minutes|
|Operating temperature||0 ~ 50 °C|
|Operating humidity||0 to 90% RH (non-condensing)|
|Dimensions||33 mm×20 mm×9 mm (Length*Width*Height)|
|Life||> 5 years|
Features of the MH-Z19B
|Gold-plated gas chamber||water and corrosion resistant|
|High sensitivity||low energy consumption|
|Temperature compensation||excellent linear output|
MH-Z19B sensor applications
The CO2 sensor MH-Z19C
The MH-Z19 sensorC is very similar to the MH-Z19B although it has a few things that make it a bit special...
Its accuracy, on paper, is a little worse than that of the MH-Z19B (50 ppm + 5% of measurement the MH-Z19B vs 50 ppm + 5% the MH-Z19C.
In practice, and according to my experiments and observations, MH-Z19C is a rather more volatile sensor. Not that it is worse than MH-Z19B, but I like it less.
The CO2 sensor MH-Z19D
The MH-Z19 sensorD is virtually the same as the MH-Z19C. It is very new (June 2021) so there is not much information about it yet.
This sensor is so new on the market that it does not even appear on the manufacturer's website in English, you have to look for it in the Chinese version to find some information (not too much).
I haven't found the official datasheet in English yet, here you can find the official one. MH-Z19D datasheet in Chinese.
CO2 sensor MH-Z1311A
Although I am not including it here, because it is not strictly speaking an MH-Z19x, I could not fail to mention the energy-saving sensor MH-Z1311A of Winsen.
First 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 get to know him better, visit the following blog post:
Which versions of the MH-Z19 sensor are available?
It is difficult to know exactly, as Chinese manufacturers are quite used to making changes to their products without communicating them, and there is sometimes a parallel market for units rebranded with other names or references.
To be sure, the following versions are available:
- The original 400~2000 ppm range model MH-Z19, with an accuracy of 50 ppm + 5% accuracy of measurement.
- The original 400~5000 ppm range model MH-Z19, with an accuracy of 50 ppm + 5% accuracy of measurement.
- Model MH-Z19B 400~2000 ppm range, which is a more modern and improved version. This version has an accuracy of 50 ppm + 3% of measurement.
- Model MH-Z19B 400~5000 ppm range, which is a more modern and improved version. This version has an accuracy of 50 ppm + 3% of measurement.
- Model MH-Z19B 400~10000 ppm range, which is a more modern and improved version. This version has an accuracy of 50 ppm + 3% of measurement.
- Model MH-Z19C 400~2000 ppm range. This version has an accuracy of 50 ppm + 5% of measurement.
- Model MH-Z19C 400~5000 ppm range. This version has an accuracy of 50 ppm + 5% of measurement.
- Model MH-Z19C 400~10000 ppm range. This version has an accuracy of 50 ppm + 5% of measurement.
- Model MH-Z19D 400~2000 ppm range. This version has an accuracy of 50 ppm + 5% of measurement.
- Model MH-Z19D 400~5000 ppm range. This version has an accuracy of 50 ppm + 5% of measurement.
- Model MH-Z19D 400~10000 ppm range. This version has an accuracy of 50 ppm + 5% of measurement.
IMPORTANT: The MH-Z19B sensors with black printed circuit boardall indications are that these versions are false.
If you want to know more about the dummy sensorsYou can find all the information here: CO2 Sensors MH-Z19B FALSE
Zero Point Calibration
The sensors MH-Z19B and MH-Z19C are factory calibrated and, 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 conditions, transport conditions and the ageing of the sensor itself, cause the sensor to age over time, their measurements vary (as with all sensors of this type).
This zero point calibration, refers to the method by which the sensor "learn". to which CO2 concentration corresponds to a concentration of 400 ppm, or zero point.
This sensor has two methods for performing zero point calibration: manual calibration and self-calibration.
Manual zero point calibration of the sensors MH-Z19, MH-Z19B and MH-Z19C
VERY IMPORTANT: It is essential that, during the manual calibration process, the sensor is previously operating during, at least 20 minutesin a stable CO2 environment with a CO2 concentration of fresh air, 400ppm (outdoors or by a window, for example).
If we have physical access to the sensor connections, we can easily start the zero point calibration procedure by jumpering terminals 5 (HD) and 7 (GND) for 7 seconds.
The sensor has a command, which will command the sensor to perform the zero point calibration at that moment.
We just have to send the command 0xFF,0x01,0x87,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78
Calibration via 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://x.x.x.x/tools?cmd=mhzcalibratezero (we will replace the x.x.x.x.x 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 recognise the command mhzcalibratezerotry with mhzCMDCalibrateZero (you'll know this because ESPEasy responds with "Command unknown: mhzCMDCalibrateZero" o "Command unknown: mhzcalibratezero").
Auto-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 a self-calibration routine, called ABCwhich 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 around 400 ppm and the sensor will assume that concentration (whatever it is) as 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 running.
ABC works quite well, but for this the sensor has to be at a place that is aired at least once a day (up to about 400 ppm).
My advice is to activate ABC if the sensor is installed in places such as classrooms, offices, etc., which are not used during the weekend and allow time for the CO2 to drop to ambient level.
If the sensor is installed in places that are not usually ventilated (indoor rooms which are often very busy, or greenhouses, for example) better deactivates the ABC.
In a house, it depends... in my office it doesn't have time to reach 400 ppm daily because I keep it almost always closed (door and window) and I spend many hours a day in it. In the living room it is enough time because we usually ventilate it every day and, although there are more people, it is bigger and the door is usually open.
Span Point Calibration
Just as we have a calibration of the lowest point that the sensor will measure (the approximately 400 ppm CO2 found in "clean" outdoor air), we have the possibility of calibrate the high point of the measurement (e.g. at 2000 ppm).
In my opinion this calibration is not affordable for amateursYou have to achieve a stable and calibrated atmosphere with exactly 2000 ppm CO2 and that is tremendously difficult without adequate laboratory resources.
My recommendation is that don't even think of trying to calibrate the Span Point on your own.. Logically, if you have access to the necessary laboratory, you probably have the necessary knowledge to do it, in which case, go ahead....
If, despite the warnings, you decide to do so, the method is very similar to the zero point calibration.
- First do the zero point calibration, as explained above.
- Place the sensor in a stable environment at 2000 ppm.
- Allow the sensor to stabilise 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 I left before with its parameters.
You will not be able to send this command directly from ESP Easy.
Are the temperature sensors of the MH-Z19, MH-Z19B and MH-Z19C reliable?
No, they are not at all.
Please note that the temperature sensor is only for internal use of the sensorThe temperature compensation can be done in order to compensate the temperature. In fact, its use is undocumented from the manufacturer and we are using it on the basis of reverse engineering of the possible commands and responses (it's a hack).
Are there different models of the MH-Z19, MH-Z19B and MH-Z19C depending on the detection range?
The sensor seems to 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 becomes progressively worse.
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 unofficialvery interesting, if you want to get more information about the sensor.
The quintessential official source for any electronic component is its datasheet, or data sheet. This is the document in which the manufacturer includes all the information about its product.
Manufacturer's data sheets:
You can find quite a lot of information, albeit scattered, in the official ESP Easy forum.
Although it is not easy to locate, as it is very scattered, I have learned a lot by studying the source code I have been able to find to use the MH-Z19B.
GitHub is a great source of information in this regard.
Connection of the sensors 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, requiring only four connections. Two for power supply and two for data transmission.
I recommend that you look carefully at the power requirements of 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 acceptable:
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
Ten beware of the MH-Z19C (and MZ-Z19D). Getting a power 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 reaching the MH-Z19C is within these margins, I recommend you to avoid it. In addition, it is important that this voltage is well stabilised.
You have more information here.
It is important that check the pins of your specific sensor, as some users have reported variations.
Anyway, don't worry, you'll be able to see in the screen printing of the sensor which pin corresponds to which pin:
Pins from the old MH-Z19 (no longer on the market).
MH-Z19B pins. This sensor is still sold, but has been replaced by the MH-Z19C.
MH-Z19C pins. Latest sensor version. Currently sold.
Versions of this sensor are available with a 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 dummy ones). only these four connections have coincided in all. The rest may vary.
I recommend that, if you have any doubts, and before connecting, make sure you are 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 (e.g. a water or heating pipe).
- The housing 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 should be fine) and don't apply heat to the pins for too long. Let it cool down between soldering one pin and the next.
Data provided by the sensor
The sensor provides three data with each measurement:
PPM: It is the CO2 concentration at that time. It is the only data to be used by the user.
T: It is the sensor internal temperature. This is a internal data which the sensor uses to adjust the CO2 measurements, as they are temperature dependent, and must not be used by the user. There is huge differences in the reported temperature from one sensor to another.
U: Nobody knows what the U-value is for sure. What is known is that it is a internal parameter that has to do with the ABC (self-calibration of the zero point) and with the CO₂ concentrations that the sensor has detected in the last cycle of ABC, but nothing else. Some versions of the sensor provide this value always at 0.
Is it true that there are fake MH-Z19Bs?
Yes there are, unfortunately, so you have to be careful where you shop.
I have written a whole article on this because it is affecting so many people. If you are going to buy one of these sensors, or already have one, be sure to read it.
The MH-Z19B label
The label on the paper MH-Z19B, attached to the side, shows the sensor model, the measuring range with which it was shipped from the factory (this can be changed at a later date by command) and what the sensor is capable of measuring. it looks like be a date (possibly manufacturing, calibration or quality control), and a QR code.
It is curious because in the fake sensors is dated does not seem to make sense. On the sensor of the photograph, what we assume to be the "date" indicates 25 December 2020 (Christmas Day) and the seller sent it to me on 25 December 2020.
Precautions and things to keep in mind
There are some basic things to watch out for, and while most of them are obvious, it doesn't hurt to bring them all together under the same heading here:
- Avoid any pressureThe plastic casing shall be welded to the plastic casing in any direction during welding, installation and use.
- When installed in a small space, the space must be well ventilatedespecially its broadcasting windows.
- The module must be away from heat sources and direct exposure to direct sunlight or other heat sources should be avoided.
- The module must be regularly calibrated. The manufacturer suggests that this should be done every six months. This will of course depend on the use of the device and the environment in which it is used.
- Do not use the sensor in an environment dusty for too long.
- Check very carefully the requirements of feeding of your specific model (see your specific version in the "Connecting the MH-Z19B" section of this article). The source current must not be less than 150mA. Outside this range, it will cause the sensor to malfunction (it may indicate a lower than actual CO2 concentration, 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) during more than 20 minutes. Turn the HD pin low (0V) for more than 7 seconds.
- Do not use wave or dip welding for the sensor.
- When soldering with a soldering iron, the temperature must be set at (350 ± 5) °C, and the soldering time must be 3 seconds maximum (weld it fastdon't dawdle).
Analysis of the MH-Z19C sensor
Variation with supply voltage
As I have been saying for some time, I do not recommend the MH-Z19C sensor at all.In general, and here I will document some of the conclusions I have reached through some of the tests I will describe.
This sensor has a major problem with foodThe operating voltage range is very narrow (from 4.9V to 5.1V depending on manufacturer(although, as we shall 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 problem that, although it can be minimised with a good design, is not easy for the average hobbyist: These types of sensors have a relatively high power consumption, which causes drops in the power supply produced in the wires of the circuit (it is normal that these drops can be 0.2V~0.4V and even higher), which makes it extremely difficult to have a stabilised power supply voltage.
In this first test I have kept the sensor running for about 10 hours powered by a programmable laboratory power supply which modified the supply voltage every 60 seconds between 4.5V and 5.15V in 0.5V steps. That is: I powered the sensor at 4.5V for 60 seconds, switched to 4.55V for another sixty seconds, 4.6V for another sixty seconds and so on (at 5.15V I switched to 4.95V for 5 minutes, to stabilise it, and started the cycle again at 4.5V).
In order to be able to see the deviation in the CO2 concentration measurements provided, as the supply voltage was changing, 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) varied with the supply voltage (in blue) and its deviation from the Senseair S8 reference sensor (in orange).
The differences may not seem to be very important, but if we zoom in on a shorter time span:
And if we go even more into detail we can clearly see the oscillations of the MH-Z19C sensor:
Notice how in the power supply period with 4.95V for 5 minutes the MH-Z19C slowly stabilises.
You may have noticed in the graphs above the large differences in CO2 concentration reported by the two sensors.
The MH-Z19C was brand new, with its factory calibration and with the ABC disabled (disabled in its first minute of operation after being switched on for the first time to maintain its factory calibration).
The Senseair S8, even though it has not been calibrated for a few weeks, is my reference sensor and does not usually show (doing 5 minute moving averages) more than 80 ppm deviation from my other sensors. reliable 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 right point. The most surprising thing is that this sensor came with a calibration certificate from Winsen. This kind of certificate doesn't seem to be very reliable and it seems to be more a marketing element from this Chinese manufacturer than anything else.
Essential: Stabilising the power supply of the MH-Z19C
Granted, the differences observed in the above test measures are very subtle, but we will now see that is a lot worse than it lookedI am not surprised that some people didn't see a problem with those measurements. It is not very difficult for me to know that something is wrong because I have done many, many, many tests with CO2 sensors and I have spent many, many, many hours analysing them. So I have done another test "in the real world" to make it clearer what is going on:
In this graph you can see the measurements of the MH-Z19C (in green) tested 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 part one the sensor is powered through a USB charger with a capacity of 2.5A per port. In the secondI have included in the feed a voltage stabiliser (a step up down), but form that the MH-Z19C power supply is stabilised at 5.0V. (although you see it's above the 5.2V line, that's because I didn't go to much trouble to calibrate the voltage divider and the small power "spikes" are due to the ESP8266's ADC noise, which isn't 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, by entering noise, jumps and non-existent peaks.
I recommend that you click on the image to see it bigger and even zoom in on it. You will see that it has all sorts of problems: large non-existent peaks, slow measurements, sawtooths, etc.
In the second partwith the MH-Z19C power supply is stabilised at 5.0V.the measure of CO2 remains at all times close to the measurement of the Reference Sensor.
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 is stabilised at 5.0V at all times..
If you power it with a USB power supply/charger you have to put the stabiliser on. YA. These devices do not provide the quality of voltage stabilisation that the MH-Z19C needs,
I leave here, in case it is useful for you, the link to the voltage stabiliser on AliExpress. It's the same place where I bought it. For what it costs, is very worthwhile.