본문 바로가기
Arduino Sensors/Chapter 3 Indoor air environmental senso

MH-Z19B Carbon Dioxide Gas Sensor [Arduino Sensors for Everyone]

by 로니킴 2021. 6. 12.


This chapter explains how to use the MH-Z19B sensor. You will learn its features, operating principles, specifications, connection pin arrangement, output values, and connect Arduino and the sensor together to measure the air around you easily using the library.

 

Contents

     


    MH-Z19B Carbon Dioxide Gas Sensor

     

     

     

     

     


     

    Effects on the human body

    Carbon dioxide is produced even when a person breathes.

     

    Carbon dioxide (CO2) can be used as a measure of indoor air quality or ventilation. If you turn on the air purifier and close the windows tightly, the room becomes stuffed with carbon dioxide. When air quality is measured with a simple measuring instrument, fine dust decreases, but the carbon dioxide concentration increases instead. Why?

     

    The air purifier keeps the air clean by filtering fine dust and ultrafine dust in the air through a HEPA filter of H13 or higher. However, air purifiers cannot filter gaseous substances such as carbon dioxide (CO2), formaldehyde (HCHO), radon (Rn), radiation, and indoor pollutants that accumulate indoors every day. The air purifier can only remove solid particles such as fine dust. There are two types of air purifiers: filtering through adsorption using a filter, and removing pollutants electrically.

     

    If doors and windows are closed tightly to enhance the air purifier effect, ventilation is not possible, so even if the concentration of fine dust decreases, the concentration of carbon dioxide rises. If do not ventilate, the accumulated carbon dioxide can adversely affect the human body.

     

    In poorly ventilated or dense indoor spaces (e.g. classrooms, offices, bedrooms, air-conditioned trains or airplanes, etc.), carbon dioxide concentrations exceed 1,000 ppm (a study by the University of Wisconsin, USA).

     

    At 1,000 ppm, there is no damage to health, but sensitive people feel uncomfortable, and if exposed for a long time, cognitive abilities may decrease. At 1,000-2,000 ppm, the air feels cloudy and people become sleepy. Loss of concentration and a mild headache can also occur.

     

    Carbon dioxide generated indoors is mainly caused by human breathing. In a closed room, the concentration of carbon dioxide increases, and the amount of oxygen becomes insufficient, so carbon dioxide is then treated as an indoor pollutant. Running the air purifier has no effect on the level of carbon dioxide; ventilation is the only method to lower indoor carbon dioxide levels.

    If the indoor carbon dioxide level exceeds 2000ppm, headache, drowsiness, decreased concentration, loss of attention, increased heart rate, and nausea may occur.

     

    According to research results, carbon dioxide (CO2) and human movement can affect fine dust. During the test (the sensor was calibrated using Sidepak PM meter temperature calibration and correlation), the PACMAN dust sensor measurement was averaged to 1 minute. It displayed in gray the detected movement percentage of each person. The user's temporal activity record was relatively poor and incomplete, but results were completely consistent with the motion record and CO2 data. In other words, the study showed that the concentration of carbon dioxide in each place in the room is different according to the movement of a person.
     


    [Effects of carbon dioxide on car interiors]

    As the carbon dioxide concentration in vehicles increases, the driver's likelihood of drowsy driving also increases. As the amount of oxygen in the car interior decreases, driving concentration decreases, and the risk of accidents due to distraction and sleepiness increases. According to a sutdy donr by the Korea Transportation Safety Authority, when all windows are closed on a day when the fine dust concentration is 'bad,' the amount of fine dust in the car was 35.6 µg per 1㎥ of air/ When windows are opened, it rose to 254.1 µg, which is about 7 times the standard level.

    According to “a study on the effect of atmospheric changes in vehicles on driver fatigue,” as a result of measuring changes in the carbon dioxide concentration of  in express buses, it was found that driving continuously for >90 minutes with >70% seat capacity is safe. The average carbon dioxide concentration in the vehicle was 3422 ppm, and the maximum was 6765 ppm.

     

    According to the Samsung Transportation Culture and Safety Research Institute, indoor carbon dioxide concentration increased to 3000ppm in 1 hour and 30 minutes of driving when a four-person vehicle is not ventilated. 

     

    In 2012, the American Industrial Hygiene Association published the results of a study on drowsy driving that when carbon dioxide concentration  in a confined space exceeds 2000 ppm, it can cause headaches or drowsiness. When it exceeds 5000 ppm, it can lead to brain damage due to lack of oxygen.

     

     

     


    MH-Z19B Sensor?

    Winsen's MH-Z19B sensor is a non-dispersive infrared (NDIR) carbon dioxide sensor. The MH-Z19B can be used for air purification systems (HVAC), indoor air quality monitoring, smart home appliances, schools, and air cleaners.

     

     

      

     

    MH-Z19B.pdf
    0.50MB

     

     

     

    The MH-Z19B sensor was manufactured by Winsen. In this book, we will use various types of gas sensors from WINSEN. Different types of carbon dioxide measurement sensors are provided.

     

     


    [MH-Z19B sensor specification]

     

     

    UART output is calculated as follows. 

    (1) Set the serial port baud rate to 9600, data bit 8 bytes, stop bit 1 byte, parity bit NULL. When a command is sent to the sensor using UART, the sensor sends a return value. 
    (2) The concentration calculation is as follows. CO2 concentration = HIGH * 256 + LOW For example, 
    Send command FF 01 86 00 00 00 00 00 79, 
    Return value FF 86 02 20 00 00 00 00 58
    (3) Converting hexadecimal 02 and 20 to the decimal system equals 2, 32. Substituting into the formula, the carbon dioxide concentration is 2 * 256 + 32 = 544 ppm.

     

     

    PWM output is calculated as follows.

    (1) The measurement range of PWM CO2 concentration is 0~2000ppm. 
    (2) Measurement is possible with Cppm=2000×(TH-2ms)/(TH+TL-4ms). For example, 1992 ppm = (998-2)/(998+6-4).

     

     

    DAC output
    The default setting for DAC is 0.4~2V, and it can be changed to 0~3V. If you use the DAC analog output of the MH-Z19B sensor, you can simply display the carbon dioxide concentration with a volt meter.

     

     

     

     

     


    Purchasing the MH-Z19B sensor

    As follows, the [MH-Z19B] sensor used in the book [Arduino Sensors for Everyone] can be purchased at Ali Express, Amazon.  

     

     

     

     

     

     


    Software Coding

    Run the example file in Steamedu123_Sensor-master > examples.

    /*
       @302 MH-Z19B Carbon dioxide gas sensor
    */
    
    #include <C302_Steam_Air_MH-Z19B_CO2_PWM.h>   // Internal library header file
    
    #define pwmPin 3
    
    SteamMHZ19BPWM mhz19b_pwm(pwmPin);    // pin number
    
    void setup() {
      Serial.begin(115200);       // Start serial communication at a speed of 115200bps.
      mhz19b_pwm.begin();         // (1) Initialize the sensor.
    }
    
    void loop() {
      mhz19b_pwm.read();        // (2) Measure the value of the sensor.
      mhz19b_pwm.display();     // (3) Output the sensor value.
      delay(5000);              // Wait for 5 second.
    }

     

     

     

     

     


     

    MH-Z19B Arduino sensor operation check

    When the hardware connection and software coding are completed, you can check the operation screen as follows.

     

    ------------------------------------------------------ 
    Development environment: WINDOWS 10
    Arduino IDE: 1.8.13
    ------------------------------------------------------ 

     

    01 library copy

    You can easily check the operation by using the  library.  
    The libraries \Steamedu123_Sensor-master folder is copied to the folder below.
    * This folder is created automatically after installing Arduino C:\Users\s\Documents\Arduino\libraries


    02 *. ino file execution
    -Connect Arduino and PC
    -Run Arduino IDE
    -Menu → Tools → Board: Check Arduino UNO
    -Menu → Sketch → Check/Compile

    03 Check compilation

    Select Sketch>OK/Compile (CTRL+R) to compile.


    04 Arduino Uno upload

    When the compilation is completed without any problems, select Sketch>Upload (CTRL+U) to upload the compiled file.


    05 Operation check

    You can check the operation as follows.
     

     


     

    Wrap-up

    You can connect Arduino and [MH-Z19B] sensor and practice the sensor easily with simple coding.

     

    In this section, we examined the effects of carbon dioxide on the human body, the reference concentration, the measurement ranges of simple measuring instruments, and the sensors used in simple measuring instruments. We also directly controlled the sensor using the PWM method. The UART method is also included in an example, so you can choose a connection interface for the sensor according to your project.

     

    The four-step criteria for the output operation of the MH-Z19B sensor were set by combining measures from Korean legislation, the US Centers for Disease Control and Prevention, the US Department of Labor, ASHRAE, and Australia SWA. According to the domestic indoor air quality management law, it is recommended to keep the indoor carbon dioxide concentration below 1000ppm (8 hours). This is the standard recommended by ASHRAE (American Refrigeration and Air Conditioning Association), and many countries around the world are using this regulation. 

     

    Indoor air filled with carbon dioxide has a bad effect on the human body such as headache, drowsiness, decreased concentration, loss of attention, increased heart rate, nausea, eyes, nervous system, lungs, and brain. Since carbon dioxide cannot be removed with an air purifier, the MH-Z19B sensor should check the carbon dioxide level 4, and if it is bad or very bad, open a window and ventilate the indoor air.

     

     

     

     


     

    References

    References for the [MH-Z19B Arduino sensor] are as follows.

     

    [11] Jacobson, T. A. et al. Direct human health risks of increased atmospheric carbon dioxide. Nat. Sustain. 2, 691–701 (2019).

    [12] Korean Indoor Air-Oxygen Research Society, Indoor Air and Health, Shinkwang Cultural History, 2004 / Cha-won Cha, Environment Story in the House, Jiseongsa, 2007
    [13] Ahn Soonbo, A Study on the Effects of Air Pollution on the Human Body, Korean Master's Thesis Kwangwoon University School, 2005
    [14] Indoor Air Quality Management Act, [Attachment 2] Indoor air quality maintenance standards (related to Article 3) [Enforcement 2020. 4. 3.] 
    [15] Yun-gyu Lee, International Research Trend of Indoor Air Environment Related Standards, Construction Technology Information, 1996

    [16] ASHRAE Standard, Ventilation for Acceptable Indoor Air Quality, 2016
    [17] MH-Z19B-Datasheet, 
    [18] S8-0053-Datasheet,
    [19] CM1106-Datasheet,
    [20] T6703-Datasheet, 

    [21] AliExpress, MH-Z19B CO2 Sensor,
    [22] AliExpress, S8-0053 CO2 Sensor,
    [23] AliExpress, CM1106  CO2  Sensor
    [24] AliExpress, T6703 CO2 Sensor, 

    [25] MH-Z19B Datasheet, “Main Parameters”, p5
    [26] MH-Z19B Datasheet, “Terminal Connection type”, p4

    [27] HUMA-I (HI-150A) 
    [28] KoaFine S4, 
    [29] KoaFine B36
    [30] Lisa Home IAQM3000, 
    [31] Sun Air Care SAC-02, 
    [32] Airam SAP-500H, 

     

     

     

     


    Purchasing a book

    [Arduino Sensors for Everyone] The book is available for purchase on Google Book and Apple Books.

    In this book, you will learn how to use the PMS7003, GP2Y1010AU0F, PPD42NS, SDS011 Fine Dust Sensor, DHT22 temperature/humidity sensor, MH-Z19B carbon dioxide sensor, ZE08-CH2O formaldehyde sensor, CCS811 total volatile organic compound (TVOC) sensor , GDK101 radiation (gamma ray) sensor, MQ-131 ozone (O3) sensor, MQ-7 carbon monoxide sensor, MICS-4514 nitrogen dioxide sensor, MICS-6814 ammonia sensor, DGS-SO2 sulfur dioxide (SO2) sensor, BME280 atmospheric pressure sensor, GUVA-S12SD ultraviolet (UV) sensor, MD0550 airflow sensor, and QS-FS01 wind speed sensor.

     

    [Google play book]

     

    Arduino Sensors for Everyone, 저자: Ronnie Kim - Google Play 도서

    Arduino Sensors for Everyone - 저자가 Ronnie Kim인 eBook입니다. PC, Android, iOS 기기에서 Google Play 북 앱을 사용해 이 책을 읽어 보세요. 책을 다운로드하여 오프라인으로 읽거나 Arduino Sensors for Everyone을(를)

    play.google.com

     



    댓글