Last modified 1 year

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

ModelMH-Z19B
Gas detectedCarbon dioxide
Operating voltage4.5 ~ 5.5 V DC
Medium current< 60m A (@ 5V supply)
Maximum current150 mA (supply @ 5V)
Interface level3.3 V (5V compatible)
Measuring range0~2000 ppm
0~5000 ppm
Output signalSerial (UART) - TTL level 3.3 V - Analogue output PWM
Preheating time3 minutes
Response timeT90<120s
Operating temperature0 ~ 50 °C
Operating humidity0 to 90% RH (non-condensing)
Dimensions33 mm×20 mm×9 mm (Length*Width*Height)
Weight5 grams
Life> 5 years

Features of the MH-Z19B

Gold-plated gas chamber water and corrosion resistant
High sensitivity low energy consumption
Excellent stability
Temperature compensation excellent linear output
Long life

MH-Z19B sensor applications

HVACfromequipmentfromcooling
Equipmentfromsurveillanceyfromqualityfromair
Systemsfromairfresh
Equipmentfrompurificationfromair
HomeSmart
Schoolsycentreseducational

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.

Winsen MH-Z19C

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).

Winsen MH-Z19D

I haven't found the official datasheet in English yet, here you can find the official one. Datasheet of the MH-Z19D dated 11-10-2021.

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.

Winsen CO2 Sensor MH-Z1311A

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:

  1. The original 400~2000 ppm range model MH-Z19, with an accuracy of 50 ppm + 5% accuracy of measurement.
  2. The original 400~5000 ppm range model MH-Z19, with an accuracy of 50 ppm + 5% accuracy of measurement.
  3. 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.
  4. 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.
  5. 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.
  6. Model MH-Z19C 400~2000 ppm range. This version has an accuracy of 50 ppm + 5% of measurement.
  7. Model MH-Z19C 400~5000 ppm range. This version has an accuracy of 50 ppm + 5% of measurement.
  8. Model MH-Z19C 400~10000 ppm range. This version has an accuracy of 50 ppm + 5% of measurement.
  9. Model MH-Z19D 400~2000 ppm range. This version has an accuracy of 50 ppm + 5% of measurement.
  10. Model MH-Z19D 400~5000 ppm range. This version has an accuracy of 50 ppm + 5% of measurement.
  11. 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).

Hardware calibration

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.

Software calibration

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.

  1. First do the zero point calibration, as explained above.
  2. Place the sensor in a stable environment at 2000 ppm.
  3. Allow the sensor to stabilise for a minimum of 20 minutes.
  4. 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.

Official sources

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:

Datasheet of the MH-Z19 (an earlier version of the MH-Z19B) in English from 03-03-2015

MH-Z19 DatasheetB in English from 23-09-2019

MH-Z19 DatasheetB in Chinese from 15-10-2020

MH-Z19 DatasheetC in English from 04-02-2020. This version is problematic with power supply (more info here).

Datasheet of the MH-Z19D dated 11-10-2021

Unofficial sources

Blogs

In the blog of RevSpace you have two pages with a lot of information, technical especially, very useful and interesting about the MH-Z19 and on the MH-Z19B

Forums

You can find quite a lot of information, albeit scattered, in the official ESP Easy forum.

Source code

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.

Feeding

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.

Pins

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:

MH-Z19 pins

Pins from the old MH-Z19 (no longer on the market).

MH-Z19

MH-Z19B pins

MH-Z19B pins. This sensor is still sold, but has been replaced by the MH-Z19C.

MH-Z19B

MH-Z19C pins

MH-Z19C pins. Latest sensor version. Currently sold.

MH-Z19C

Connector version

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.

Connections MH-Z19B Connector

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

Precautions

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.

Factory calibration

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.

53 thoughts on “La biblia del sensor de CO2 MH-Z19B”

  1. Very complete information about the sensor...it will become more than a bible...hehehe
    The web link you put in "Manufacturer's datasheets" about the MH-Z19C leads me to the same datasheet as the Z19B. And I see it for sale on Aliexpress: https://bit.ly/3pumjhE (shortened web link, the original goes on for a lot of lines). I think I understand that the differences with the B is in a shorter start-up time, greater working humidity amplitude and others related to voltages and currents in mA, which I don't know exactly what they imply... I guess a better performance. Also that the accuracy is increased to 5%, but I see little importance in this, as the range is also still +-50 ppm. Since it is newer, do you recommend buying the C model over the B?
    Greetings again

    Reply
    • I had made a mistake when linking to the MH-Z19B datasheet and repeated the MH-Z19C datasheet. It is now corrected. Thank you very much for the warning.

      It seems, as you say, that the sensor is already on sale. The link you have posted doesn't look good (in the photograph it is not like the manufacturer's official one). You can find one here that looks like the official one:
      https://s.click.aliexpress.com/e/_AOPAxf

      Now that it is available, I will take a closer look at the differences and expand the table with the new data. At first glance, it looks like a step backwards: lower accuracy (5% vs. 3% of the old one) and lower operating voltage range (4.9 to 5.1 V vs. 4.5 to 5.5 V of the old one).

      What does seem to improve, as you pointed out, is the warm-up time (1 minute, compared to 3 minutes for the old one) and the slightly lower power consumption. This could be interesting for users who want to use it in a portable or handheld format with batteries.

      I still do not recommend its purchase, until we know if it will work with the 100% with ESPEasy or if we will have to adapt the code (as we had to do when the previous ones appeared, because, although there are no big differences, there are some, and adjustments have to be made).
      I know, almost by ricochet, of one person who is testing the HM-Z19C with ESPEasy and, so far, it seems to be working well for him.

      If anyone is encouraged to try it out, please let us know how it went.

      Reply
  2. Hello Mariete,

    Thanks for all this information. I'll let you know how it goes because I've never welded anything in my life, but for this project I've been encouraged.

    I have a question about the sensor that I received at home with respect to the list you put... On the label of my sensor it says:

    Model MH-Z19B range 0~5000 ppm

    But I don't see this range in any of the sensors you have listed.

    This is the one with the green printed circuit board:
    https://s.click.aliexpress.com/e/_AFRbHD

    Do I have a good one?
    Thank you!

    Reply
    • Hello Israel.

      It's great that you've taken the plunge. You'll let us know... Be careful, because the gadgetry gets you hooked!

      The sensors I have listed have all been 5000 ppm (it can be changed by software anyway). I just changed it, because I just saw that the one that was on is no longer available.

      It is very difficult to know if it is authentic or not, unless it has a black plate. Last week I received a fake one (with a black plate) and I am going to make a video explaining the differences.

      Reply
  3. Although you mention it in a recent post, there is a sensor supply voltage difference that can be critical for the project: less than 4.9V and it will not measure accurately: extract from my general post:

    Ps: by the way, the use of a good charger can't be because the ESP doesn't give the 4,5V for the Vin for the 19B? Because it consumes less than 0.1A.

    ""
    The third thing is more relevant and is related to the sensor: it may even screw up the project for many people. The thing is that although I bought the MH-Z19B, after a lot of fussing with the aliexpress seller, he sent me the MH-Z19C. It's physically different... but also electronically, as you'll see. I tried to assemble the circuit with the tutorial, but instead of soldering I did it with a breadboard that I had also bought for tinkering (I'm very new at this). The thing is that after I connected everything... it didn't work properly. The red light was blinking. Values were coming out, I even connected them to Thingspeak with the partner's tuto. But the values were very unstable: 50 or more PPM jumped up and down, and the temperature didn't match either. It was 2 or 3 degrees lower than the real value.

    So, I thought they had given me a fake and I was really annoyed... until I saw the 19C's sheet. It turns out that there is a substantial difference between the 19B and the 19C in the electronics: while the 19B works with 5V+-0.5 (from 4.5 to 5.5V), the 19C needs 5V+-0.1 (from 4.9 to 5.1V). Also at the end of the sheet he insists that if the voltage is not in that range... the measurements become UNSTABLE. I looked at what the ESP was giving on the Vin/GND... et voila, 4.57V. Insufficient.

    I have been doing some research and it turns out that the ESP is incapable of supplying 5V. The Vin/GND is there to supply it with "unregulated" voltage between 5V and 12V. But not to get 5V from there. In fact, the fact that it gives voltage when connected to micro USB is a by-product, not a specification. In fact, in any project that needs 5V (motors), you need a specific power supply, you can't pull from Vin (from what I've been reading). With the MH-Z19B you're lucky because its input range is wider (although it's so close to the limit that it's almost certainly not working for some people and they're getting jumpy values), but with the MH-Z19C it's not.

    When I bought the breadboard, a power supply came with it. I connected the MH-Z19C to the 5V (by the way, it gives 4.92V, a bit low) and... BINGO, everything was perfect:

    https://thingspeak.com/channels/1279169/charts/1?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&type=line&update=15

    THANK YOU VERY MUCH FOR EVERYTHING

    ""

    Reply
    • Hi Jesus,

      what was the response of the MH-Z19C while being undervolted? Did the measurement lamp blink? Did you receive responses on the serial port?

      I have received today a MH-Z19C where the measurement lamp blinks but gives Unknown response: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 in espeasy (setup has worked with a MH-Z19B before).

      Thanks,
      Wolfgang

      Reply
  4. Hi Mariete, I have one of those sensors, and I paint the ppm and temperature on a homeassistant. What I have seen is that when I open the window of the room (now that it is much colder outside), the ppm almost immediately drops drastically (it doesn't make sense that the CO2 concentration is dropping so fast). It seems to me that what actually happens is that the sensor detects that the temperature is dropping, that is correct, and it uses the temperature to give the ppm, but that is not correct. In fact, if I close the window, when the temperature rises again, the ppm also rises quickly. I wonder if I shouldn't correct the ppm value by sw with the value of T. (I can't think how).

    Reply
    • Hi Alex.

      I haven't observed this effect on my sensors, but it seems like a good test to do. As soon as I have time I will do it and document it here.

      Precisely the internal temperature sensor that these sensors have is supposed to prevent this from happening and, in theory, they make the temperature correction internally.

      What we do know, with a fair degree of certainty, is that draughts affect them quite a lot. Check to see if what is happening is not that when you open the window a draught is forming and affecting them.

      On the other hand, the sensors are quite fast in responding to the CO2 concentration and the air mixes very quickly as well. Sometimes when I open the window, I can drop from 1800 ppm to 500 ppm in a few minutes (not always, I think it depends on where the wind is coming from).

      I just did an experiment, right now, by opening the window a little bit: See how here five different sensors in the same room (all different makes and models) have dropped rapidly from about 1500 ppm to about 600 ppm in less than 10 minutes (with the sharpest drop in the first 2 minutes). Look especially at the Senseair S8, which is the reference sensor, (the others are dedicated to testing and are not even calibrated recently, except for the CM1106, which I calibrated a few days ago).

      The temperature inside was around 25º at the start and 23º after 10 minutes (it didn't drop much either, so you can see that the window opening wasn't very big either).

      Best regards.

      Reply
      • Hey Mariete,

        just wanted to let you know that I noticed the same phenomen as Alex: Only moments after I open the window, the measurements drop very low (way below 400, even 0 sometimes).
        It's very cold outside (2°C), so maybe the temperature sensor reacts slower to changes than the CO2 sensor. This could lead to wrong temperature compensations that result in senseless measurements.
        Maybe someone else living in cold climate can confirm this?

        Best regards
        Florian

        Reply
  5. Hi, excellent article, thanks for sharing.
    I have a doubt. You talk about the source code of the sensor and that it is scattered and difficult to find. Do you mean a library to be able to use it with the Arduino IDE? Do you know if there are such libraries?
    Another question I have is about the graphs you show in this and other articles, what programme do you use to produce them?
    Best regards

    Reply
    • Hello Jesus.

      There are quite a few Arduino libraries that support the MH-Z19. As mentioned in the article, I recommend you to look at GitHub to see which one you like the most or best suits your needs.

      When I say, "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."I mean that you have to go digging through the source code of many different projects to see the comments written by their authors with interesting information or how they have implemented certain things.

      The graphs in this article are made with Grafana.

      Best regards.

      Reply
      • Thank you very much Mariete, I will get to it, as I would like to create code to use this sensor in an Arduino Nano without internet access, in which the readings can be made on an LCD screen that I have, which is larger than the OLED 0.91 and looks better. I would also like to store the readings on an SD card, so I can graph them.
        I would be grateful for any advice or suggestions.
        Best regards and congratulations for such excellent articles.

        Reply
  6. Wow, this site is great news for us DIYers trying to avoid Co2-poisoning in our little workshops.

    I recently got my MH-Z19B and I am very satisfied with its performance-to-cost equation.

    However, I am trying to find out what 7-pin terminal connector is used on the PCB. I guess it is a JST something, but cannot find the exact type in any documentation.

    Any ideas, anyone?

    Reply
  7. I am about to finish a project in which I am using the MH-Z19 sensor and everything is going well, but I would like to know what is the range of one sensor per m2, i.e. for 2400 m2 how many MH-Z19 sensors do I need to monitor the whole area?
    I have been reading this and other websites and have not found an answer to my question.

    If you can help me, I would be very grateful.

    Greetings from Peru.

    Reply
    • Hello, Enmanuel.

      The truth is that this is a question with a very complex answer and requires a significant number of calculations using many parameters. It is not possible to give a generic answer.

      My recommendation is to use the calculator that you can find here http://tinyurl.com/covid-estimator created by University of Colorado chemistry and biochemistry professor José Luis Jiménez (https://www.colorado.edu/chemistry/jose-luis-jimenez) together with Dr. Zhe Peng.

      I hope you find it helpful.

      Best regards.

      Reply
      • ok thank you very much Mariete, I will check the calculator.

        But according to your experience and knowledge of this sensor, one could use it for an area of how many m2?

        thank you

        Reply
        • Hello, Enmanuel.

          I understand that you would like to get an answer, but, as I said, it is impossible to know without an in-depth study. It depends on so many parameters that it is not possible to give a quick answer.

          In your case, being an area of 2400m2, I recommend that you contact a ventilation professional (a specialised engineer).

          Best regards.

          Reply
  8. Hi, I have a voltage drop problem every time the MHZ19B takes a reading. I assembled the CO2 meter and put a 16×2 display, a buzzer and a RGB LED. I put it on a breadboard with arduino 1. By feeding Arduino 1 with 9V from the jack every time the sensor takes a reading there is a slight flicker on the display. I measured the current that the sensor consumes and it is variable, when taking the value when the internal led is turned on it consumes 100 mA approx and when the internal led is turned off it consumes 20 mA. The flickering of the display is quite passable but when testing it with an Arduino Nano, which is the one I want to use, it is very evident. The only solution I found is to try to power the sensor with another 5V supply and share the GND. Then, as it doesn't take the current from the Arduino, it works perfectly. But the idea is to use only one power supply. What I don't understand is why the voltage drops if the Arduino delivers up to 500 mA on the 5V outputs. If I feed it from Vin it has the same voltage drop.
    Greetings!

    Reply
    • Hello, Juan Manuel.

      Indeed, voltage drops are very frequent. Both in this article and, above all, in the article entitled "Powering from NodeMCU, Wemos Mini D1 and Arduino" (at https://emariete.com/alimentar-desde-nodemcu-wemos-mini-d1-y-arduino/) the problem is explained and several solutions are given.

      To understand why this happens, when you say "What I don't understand is why the voltage drops if the Arduino delivers up to 500 mA on the 5V outputs".The most important thing is in the sentence "Arduino delivers". to 500 mA". As a general rule can deliver to 500 mA but this depends on several things (regulator circuit used, input voltage, temperature, etc).

      The immediate and simplest solution is to use a voltage stabiliser (SEPIC or boost-buck converter) like this one: https://s.click.aliexpress.com/e/_A6VUHZ

      Best regards.

      Reply
  9. Hi, I have a Mhz19c sensor to which I connect a step up to the 5v and GND output of the arduino nano board and with the regulated voltage of 5v I get power to the sensor but I only register measurements of 5000ppm. When I remove the voltage converter module and connect the sensor directly to GND and 5v of the Nano the measurement is normalized. I don't know what I am doing wrong. Thanks, best regards

    Reply
    • Hello Miguel.

      Step-ups need a voltage difference between their input and output.

      Depending on what the step up is, it can be as low as 1.2 volts or more. In other words, you can't apply more than 3.8 volts, 5-1.2=3.8, to the input.
      You will need to look at the data sheet for the particular step up you are using to see what minimum difference it needs.

      In your case, as the input and output voltages are so close, you need a "step up/down" that steps the output voltage up or down to keep it at 5V as needed', as explained in the article.

      I recommend that you put a plate like the one indicated in the article (or a similar one). Many users are using it with very good results: https://s.click.aliexpress.com/e/_A6VUHZ

      Best regards.

      Reply
  10. It's true what you say, I have the same problems. With a supply voltage to the MH-Z19C of 4.85VDC it measures between 400ppm and 403ppm (probably wrong) and every now and then it measures 5000ppm with two sensors. The funny thing is that when I put it in new it works fine but after a few days it starts to give these errors.
    Excellent information you provide, thanks for the effort👏👏👏👏👏
    Greetings

    Reply
    • Hello Marcelo.

      Indeed, when the supply voltage of the MH-Z19C is outside the manufacturer's specifications or not perfectly filtered and stabilised, the operation of the sensor can be quite random and unstable.

      Best regards.

      Reply
  11. Hi, excellent page! And I bring a query, I bought one that is dated 9/3/2021, just out of the oven for the date of publication, and when I consult the value of ppm with the command 86 responds me a byte more than what the data sheet says, I send:
    FF 01 86 00 00 00 00 00 00 00 00 79
    And he responds:
    FF 86 01 96 39 00 01 00 A9
    FF: Home
    86: command responding
    01: Most significant byte of the CO2 ppm
    96: Least significant byte of CO2 ppm
    39: ????, I don't know what this is, I know it goes up when the bpm goes up and down when the bpm goes down.
    00: It's OK to make it 00, I think!
    01: ????, this value is increasing over time.
    00: it's OK to be 00
    A9: CRC, all good

    Does anyone know what this additional data is? It is not noise because I get the checksum right, which by the way gives me that it is the complement to 0, not the complement to 1 as datashet says... or I'm doing something wrong that gives me well haha.

    At the moment I know that this value of 39 accompanies the ppm level, and the value I have at 1 in the example is going up over time, it would seem to be a timer.

    Reply
    • Hello César.

      From what I see in your message the answer "FF 86 01 96 39 00 01 00 A9" is correct and matches the datasheet. These are the 9 bytes that you should receive.

      The rest of the data is not documented by the manufacturer, but thanks to the work of some people we have partially found out what it corresponds to. This is a quick summary, but you can find more information in the links included in the article.

      r[2..3], r[4], r[5], r[6], r[7]
      r[2..3] "final" CO2 level.
      r[4] - (temperature in C) + 40
      r[6] and r[7] - if ABC turned on - counter in "ticks" within a calibration cycle and the number of performed calibration cycles.

      Best regards.

      Reply
    • Although it's been a long time since the message, as for the CRC it gives me 59. I'm not trying to be a pain in the ass hehe, it's just to check if it still gives you the correct checksum or I'm wrong in the calculation hehe. Cheers.

      Reply
  12. Hello, in the microcontroller and sensor design can both be powered with 5V? Won't the Usart of the sensor burn out because of the 5v levels of the serial signal?
    Greetings

    Reply
    • Hello Alvaro.

      If you look at the datasheet of the sensor you will see that the manufacturer indicates that the serial pins are 3.3V, compatible with 5V, so you will not have any problem.

      Best regards.

      Reply
  13. Hello, I have just received my MH-Z19B sensor, my question is about the range, the sensor says that it has a range of 0-5000, I want to use it for a greenhouse, where values lower than 400ppm can be registered. My question is, can these values lower than 400ppm be registered by this sensor? In this case, will it be necessary to remove the automatic calibration? Since the lower value will not correspond to 400ppm, I hope I made myself understood, greetings.

    Reply
    • Hello Carlos.

      If you look at the manufacturer's datasheet you will see that the sensor can measure below 400ppm (from 0, according to the datasheet) and in fact it refers to its use in greenhouses.
      Indeed, you will have to deactivate the automatic calibration and calibrate it manually from time to time.

      Best regards.

      Reply
        • It is always best to use the digital output, unless you have to use it with something that is only capable of reading analogue inputs (e.g. some kind of PLC, SCADA or industrial controller).

          Reply
    • Hello Ger.

      I usually glue it with hot melt glue (what they call glue or hot glue) but I guess you can glue it with most normal glues like cyanoacrylate (Superglue, for example) or epoxy.

      Best regards.

      Reply
  14. Good morning, I need help with a mhz19b sensor project with my WeMos d1 mini pro board,
    To sum up, my sensor doesn't work even with the arduino example code, it always gives the value 0, I have tried changing the pin jumpers and everything but I can't get it to work.

    I need to have it up and running by Monday, if there is a whatsapp group or something where I can send you photos I would be very grateful.

    Reply
    • Hello Juan Antonio.

      I don't know if there is a WhatsApp group, but you have the eMariete Telegram group: https://t.me/emariete_chat

      I would recommend that, as a first step, you follow the CO2 Easy project with your board. By starting from something that you know positively works and is well documented you will know for sure that the hardware is OK and, when you are sure, you can focus on the Arduino code you are using.

      Best regards.

      Reply
  15. I have a B & C version, and both got somehow caught in an ABC cycle and are now reading ~400ppm lower than a reference sensor I have. It's bitter cold winter now where I live, and so the house is closed up tight - CO2 levels are consistently running 800-1200 without intervention (based on my desktop monitor -https://www.amazon.ca/gp/product/B00H7HFINS)

    I have the Z19 wired to an ESP and some relays to control my HRV to bring in fresh air - I have tried putting the unit in the fresh air stream for an hour and then connecting the HD pin to ground for 10 seconds (> 7) but it does not seem to bring the zero point back down to a reasonable level.

    Has anyone had success getting these to recalibrate to a lower baseline (ie: back to 400ppm == 400ppm?)

    Reply
    • Hi Al.

      Most of the times issues with low readings and calibration problems come from problems with the sensor's power supply.
      It's very important to have a steady power for the sensor within the voltage range indicated by the manufacturer (4.5~5,5V for the MH-Z19B and 4.9~5,1V for the MH-Z19C.
      Take care of long or very thin wires for the power supply that can cause big voltage drops.
      Calibration by shorting the HD pin to GND for > 7 secs. works very well and is something that should give no problems at all.

      Reply
  16. I've been using the MH-Z19B sensor for a while and I've noticed that the values fluctuate wildly. I have the meter outside and values shoot back and forth from 400 to over 1000 PPM. I am using a NodeMCU ESP8266 board with ESP_Easy and the calibration is on. I even used the web command for calibration mhzCMDCalibrateZero, but it doesn't seem to help. Could the sensor be broken or is it very common for those readings to shoot back and forth like that?

    Reply
    • Hi Gudio.

      Most of the times issues with wrong readings and calibration problems come from problems with the sensor's power supply.
      It's very important to have a steady power for the sensor within the voltage range indicated by the manufacturer (4.5~5,5V for the MH-Z19B and 4.9~5,1V for the MH-Z19C.
      Take care of long or very thin wires for the power supply that can cause big voltage drops.
      Look also for bad connections that can cause all kind of issues. Check soldering.

      Reply
  17. Hi,
    I have read somewhere that quering the sensor via serial (UART) too often will decrease it's life expectancy. However, this seems to be controversial since it seems to take a measurement on it's own every second when using PWM. Can you tell something about this?

    Thanks

    Reply
  18. Hi,
    I have read somewhere that querying the sensor over UART too often can result in a reduced lifespan. Can you say something to that? Is it safer to use PWM as there are no manual queries being made to the sensor?

    Thanks!

    Reply
  19. Dear Mariete Team,

    I'm Summer from Winsen, which is the manufacturer of the MH-Z series CO2 sensor.

    So glad to to find such a professional and detailed blog introduction to our product.
    Thank you so much!
    We also have many other different types of gas sensors and other sensors. If you have any questions about our sensors of need some samples for your evaluation, please advise me freely. 😊
    My Email & Skype : [email protected]
    My Whatsapp: +86 17806246591
    Thank you again!

    Reply
  20. Hi Mariete,
    Excellent information you provide, thanks for the effort.

    Unfortunally I found the page at the end of my work. But the tipp about the calibration via command helps me to avoid the hardware stuff. As I bought my chip some weeks ago - without knowing Your investigations I have a 'C' type. Anyway, for my 'hobby' activites it will fit 😉

    Rgds, Dieter

    Reply
  21. Hi Mariete,

    Thank you very much for your work on these sensors and this article. I was about to give up on this sensor but I bought a stabiliser and got it to work due to your article. This saved a lot of frustration 🙂

    Regards, Guus

    Reply

Leave a comment