Last modified July 9, 2021

The MH-Z19B CO2 sensor is fantastic. A cheap, accurate 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.

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.

In this article you will find everything you want to know about these two sensors (and if you can't find it, ask for it in the comments).

Maybe calling it a bible, right now, is a little pretentious, but I give you my word that it will become. Give it time…

This article is alive and it never stops growing. Subscribe to the Newsletter and don't miss a thing.

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 detectedCarbon dioxide
Operating voltage4.5 ~ 5.5 V DC
Average current<60m A (@ 5V supply)
Peak current150 mA (supply @ 5V)
Interface level3.3 V (compatible with 5V)
Measuring range0 ~ 2000 ppm
0 ~ 5000 ppm
Output signalSerial (UART) - TTL level 3.3 V - PWM analog output
Preheating time3 minutes
Response timeT90<120s
Operating temperature0 ~ 50 ° C
Operating humidity0 to 90% RH (non-condensing)
Dimensions33mm × 20mm × 9mm (Length * Width * Height)
Weight5 grams
Lifetime> 5 years

MH-Z19B Features

Gold-plated gas chamber, waterproof and corrosion resistant
High sensitivity, low power consumption
Excellent stability
Temperature compensation, excellent linear output
Long duration

MH-Z19B Sensor Applications

HVAC Refrigeration Equipment
Surveillance and air quality equipment
Fresh air systems
Air purification equipment
Smart home
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.

Winsen MH-Z19C

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

Winsen MH-Z19D

I still have not found the official datasheet in English, here you can find the MH-Z19D datasheet in Chinese.

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:

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

Maybe you are also interested in:  Gallery: User CO₂ Meters

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

Hardware calibration

If we have physical access to the sensor connections, we can easily initiate the zero point calibration procedure, bypassing terminals 5 (HD) and 7 (GND) for 7 seconds.

Software calibration

The sensor has a command, which will order it to perform the zero point calibration at the same time.

We only have to send the command 0xFF, 0x01,0x87,0x00,0x00,0x00,0x00,0x00,0x78

Calibration using 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.

  1. Do the zero point calibration first, as explained above
  2. Put the sensor in a stable environment at 2000 ppm
  3. Allow the sensor to stabilize 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 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.

Official sources

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.

Maybe you are also interested in:  The Sensirion SCD41 CO2 sensor (and the SCD40)

Manufacturer data sheets:

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

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

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

MH-Z19 DatasheetC in english from 02-04-2020. This version is problematic with food (more information here).

MH-Z19D Datasheet in Chinese, 3-16-2021

Unofficial sources


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


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

Source code

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:

MH-Z19 pins

Old MH-Z19 pins (long gone).


MH-Z19B pins

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


MH-Z19C pins

Pins of the MH-Z19C. Latest version of sensor. Currently sold.


Connector version

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.

Connections MH-Z19B connector

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).
Maybe you are also interested in:  CO2 Monitor on your cell phone with ESP32 and Sensirion SCD30 sensor [BASIC VERSION]

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.

Factory calibration

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.

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

  1. Very complete information about the sensor ... it will become more than a bible ... hehe
    Tell you that the web link that you put in "Manufacturer's data sheets" about the MH-Z19C leads to the same sheet as the Z19B. And I see it for sale on Aliexpress: (web link shortened, the original spans a bunch of lines). I think I understand that the differences with the B are in a shorter start-up time, a greater amplitude of working humidity and others related to voltages and intensities in mA, which I don't know exactly what they imply ... I suppose a better operation. Also that the precision raises it to the 5%, but I see this of little importance, since the range is still + -50 ppm. Since it is newer, do you recommend buying the C model over the B model as better?
    Greetings again

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

      It seems, as you say, that the sensor is already on sale. The link you have put does not look good (in the photograph it is not like the official manufacturer). You can find here one that seems to be the official one:

      Now that it's available, I'll calmly study the differences and expand the table with the new data. By boat soon, it seems like a step backwards: lower precision (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 have pointed out, is in the preheating time (1 minute, compared to 3 minutes in the old one) and the consumption somewhat lower. This can be interesting for users who want to use it in a portable or portable format with batteries.

      I still do not recommend its purchase, until I know if it will work for the 100% with ESPEasy or it will be necessary to adapt the code (as it had to be done when the previous ones appeared, because, although there are no major differences, there are some, and adjustments must be made)
      I know, almost rebound, from a person who is testing the HM-Z19C with ESPEasy and, for the moment, it seems that it is working correctly.

      If someone is encouraged to try it, tell us how it went.

  2. Hello Mariete,

    Thanks for all this information. I'll tell you how I am doing because in my life I have soldered nothing, but for this project I have encouraged myself.

    I have a question about the sensor that has come to my house regarding the list you put ... On the label of my sensor it says:

    Model MH-Z19B with range 0 ~ 5000 ppm

    But I don't see this range on any of the sensors you've listed.

    It is specifically this one, the one with the green printed circuit:

    Do I have one of the good ones?
    Thank you!

    • Hello Israel.

      Great, that you have cheered up. You'll tell us ... Be careful, the gadget hooks!

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

      Knowing if it is authentic or not is very difficult, unless it has a black plate. Last week I got a fake one (with a black plate) and I'm going to take the opportunity to make a video explaining the differences.

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

    Ps: by the way, the use of a good charger cannot be because the ESP does not get to give 4.5V for the Vin for the 19B? Because consume, consume less than 0.1A

    The third is more relevant and is related to the sensor: it can even screw up the project for many people. The point is that even though I bought the MH-Z19B, after many dizziness with the aliexpress seller, he sent me the MH-Z19C. It is physically different ... but also electronically, as you will 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 fretting (I am very new to this). The point is that after having connected everything ... it did not work well. The red light was blinking. Values came out, I even connected them to Thingspeak with the partner's tutor. But the values were very unstable: they jumped 50 or more PPM up and down, and the temperature did not add up either. It came out 2 or 3 degrees less than the real thing.

    Total, I thought they had put a fake on me and it bothered me a lot ... until I saw the 19C sheet. It turns out that there is a substantial difference between the 19B and the 19C in electronics: while the 19B works by powering it 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 it on the Vin / GND… et voila, 4.57V. Insufficient.

    I have been documenting myself and it turns out that the ESP is unable to give 5V. The Vin / GND is to supply it with "unregulated" voltage between 5V and 12V. But not to get 5V out of there. In fact, the power supply when connecting with 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 Vin (from what I've been reading). With the MH-Z19B you are lucky because its input range is wider (although it is so close to the limit that it is almost certain that it is not working for some and it comes out jumping values), but not with the MH-Z19C.

    When buying the breadboard came a feeder. I connected the MH-Z19C to 5V (by the way, it gives 4.92V, a little low) and… BINGO, everything perfect:



    • 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 in espeasy (setup has worked with a MH-Z19B before).


      • Hi Wolfgang.

        I understand that what was happening to Jesus was that his sensor was giving unstable results, with jumps up and down of about 50 ppm.

        In his message, he indicates that the sensor's lamp went on and off, as it should.

        The symptoms of what is happening to you with the unknown response are described in some messages in the main article of the CO2 meter at

        Additional information and some tips for using the MH-Z19C can be found at:

  4. Hello Mariete, I have one of those sensors, and I paint the ppm and the temperature on a homeassistant. What I have seen is that when I open the window of the room (now that it is quite colder outside), almost immediately the ppm drops drastically. (It does not make sense how fast the CO2 concentration is lowering) It seems to me that in reality what happens is that the sensor detects that the temperature drops, that is correct, and he uses the temperature to give the ppm, but that is not it is right. In fact, if I close the window, when the temperature rises again, it is observed how the ppm also increases rapidly. I wonder if the value of ppm per sw should not be corrected with the value read from T. (now I can't think of how)

    • Hi Alex.

      I have not observed that 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 that from happening and, in theory, they make the temperature correction internally.

      What we do know for sure is that air currents affect them quite a bit. Check if what happens to him is not that when you open the window a draft is formed that is affecting him.

      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 go down from 1800 ppm to 500 ppm in a very few minutes (not always, I think it depends on where the wind is coming from).

      I just did an experiment, right now, opening the window a little: Look how here five different sensors in the same room (all different makes and models) they have dropped rapidly from about 1500 ppm to about 600 ppm in less than 10 minutes (with the steepest 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 recently calibrated, except for the CM1106, which I calibrated a few days ago).

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

      A greeting.

  5. Hello, excellent article, thanks for sharing.
    I have a doubt. You talk about the source code of the sensor and that it is scattered and hard to find. Are you referring to 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 that you show, in this and other articles, with what program do you make them?
    a greeting

    • Hello Jesus.

      There are quite a few Arduino libraries that support the MH-Z19. As I comment in the article, I recommend that you look at GitHub because that way you see the one that you like the most or best suits what you need.

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

      The graphics in this article are made with Grafana.

      A greeting.

      • Thank you very much Mariete, I will get to it, since 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 greater than OLED 0.91 and it looks better. I would also like to store the readings in a SD, to be able to graph them.
        I would appreciate any advice or suggestions.
        Greetings and congratulations for such excellent articles.

  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?

  7. Good evening dear. I am about to finish a project in which I am using the MH-Z19 sensor and everything works fine, but I would like to know what is the range of a sensor per m2, that is, for 2400 m2 how many MH-Z19 sensors do I need to monitor all the area?
    I have been reading this and other websites and I have not found an answer to my question.

    If you can help me, I would appreciate it very much.

    Greetings from Peru.

    • Hello, Enmanuel.

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

      My recommendation is that you use the calculator that you can find here created by the professor of chemistry and biochemistry at the University of Colorado José Luis Jiménez ( / jose-luis-jimenez) together with Dr. Zhe Peng.

      I hope it helps you.

      A greeting.

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

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

        Thank you

        • Hello, Enmanuel.

          I understand that you would like an answer, but, as I mentioned, that 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.

          Since your case is an area of 2400m2, I recommend that you contact a ventilation professional (a specialized engineer).

          A greeting.

  8. Hello, I have a voltage drop problem every time the MHZ19B takes a reading. I assembled the CO2 meter and attached a 16 × 2 display, a buzzer and an RGB LED to it. I assembled it on a breadboard with Arduino 1. When feeding Arduino 1 with 9V from the jack every time the sensor takes a reading, a slight flicker is noticed on the display. I measured the current that the sensor consumes and it is variable, by taking the value when the internal led turns on, it consumes approx. 100 mA and when the internal led turns off, 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 already very evident. The only solution I found is to try feeding the sensor with another 5V source and sharing the GNDs. There by not taking the current from Arduino it works perfectly. But the idea is to use a single font. Which I don't understand why the voltage drops if Arduino delivers up to 500 mA on the 5V outputs. If I feed it from Vin it performs the same voltage drop.

    • Hello, Juan Manuel.

      Indeed, voltage drops are very frequent. Both in this article and, above all, in the one called "Power from NodeMCU, Wemos Mini D1 and Arduino" (at /) the problem is explained and various solutions are given.

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

      The immediate and simplest solution is to use a voltage stabilizer (SEPIC or boost-buck converter) like this:

      A greeting.

  9. Hello, 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 that I feed the sensor but only register measurements of 5000ppm. When I remove the voltage converter module and connect the sensor directly to the GND and 5v of the Nano, the measurement normalizes. I don't know what I can be doing wrong. Thanks greetings

    • Hello Miguel.

      Step ups require a voltage difference between their input and their output.

      Depending on what the step up is, it can even be 1.2 volts or more. In other words, you cannot apply more than 3.8 volts, 5-1.2 = 3.8, to the input.
      You will have to look at the datasheet for the particular step up you are using to see what minimal difference it needs.

      In your case, as the input and output voltage are so close together, you need a "step up / down" that raises or lowers the output voltage to keep it at 5V as necessary, "as I explain 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:

      A greeting.

  10. It is 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 so often it measures 5000ppm and I have passed with two sensors. The funny thing is that when placing it new it works well but after a few days it begins to give these errors.
    Excellent information that you provide, thanks for the effort👏👏👏

    • Hello, Marcelo.

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

      A greeting.

  11. Hello, excellent page! And I bring a query, I bought one that has a date of 9/3/2021, fresh out of the oven for the publication date, and when I consult the value of ppm with the 86 command, it responds one more byte to what the sheet says of data, I send you:
    FF 01 86 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 CO2 ppm
    96: Least significant byte of CO2 ppm
    39: ????, this I do not know what it is, I know that it goes up when the ppm goes up and goes down when the ppm goes down
    00: Ok that's 00, I think!
    01: ????, this value increases over time
    00: Ok make it 00
    A9: CRC, all good

    Anyone know what that additional data is? It is not noise because I am good at the checksum, which by the way gives me that it is the complement to 0, not the complement to 1 as the datashet says ... or I am doing something wrong that I am good at haha.

    For now I know that this value of 39 accompanies the ppm level, and the value that I have in 1 in the example, goes up over time, it would seem to be a timer.

    • Hi Cesar.

      From what I see in your message the answer "FF 86 01 96 39 00 01 00 A9" is correct and matches what the datasheet indicates. They 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 it has been 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.

      A greeting.

  12. Hello in the design microcontroller and sensor can both be powered with 5V? Will the Usart of the sensor not be burned by the 5v levels of the serial signal?

    • Hello Alvaro.

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

      A greeting.

  13. Hello, I just received my MH-Z19B sensor, my question is about the range, the sensor says it has a range of 0-5000, I want to use it for a greenhouse, where values less than 400ppm can be recorded. My question is, can those 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 to be understood, greetings.

    • Hi Carlos.

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

      A greeting.

        • It is always better to use the digital output, unless you have to use it with something that is only capable of reading analog inputs (for example some type of PLC, SCADA or industrial controller).

    • Hi Ger.

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

      A greeting.


Leave a Comment