The MH-Z19B is an infrared carbon dioxide sensor module capable of measuring CO2 concentrations in the air. This sensor is widely used in HVAC (Heating, Ventilation, and Air Conditioning) systems, indoor air quality monitoring, and other applications where monitoring of CO2 levels is necessary for environmental control or health standards.
Pin Number | Name | Description |
---|---|---|
1 | V_in | Power supply (4.5 - 5.5 V DC) |
2 | GND | Ground |
3 | TX | UART Transmit (connect to RX of MCU) |
4 | RX | UART Receive (connect to TX of MCU) |
5 | HD | PWM/HD (selectable output) |
6 | NC | Not connected |
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
}
void loop() {
if (mySerial.available() > 0) {
int high = mySerial.read();
int low = mySerial.read();
if (high == 0xFF) {
int ppm = (256 * high) + low;
Serial.print("CO2 Concentration: ");
Serial.print(ppm);
Serial.println("ppm");
}
}
}
Note: This example assumes that the MH-Z19B is connected via UART using pins 10 and 11 on the Arduino UNO for software serial communication. Adjust the pin numbers as needed for your specific setup.
Q: How often should the sensor be calibrated? A: The manufacturer recommends calibrating the sensor every six months or whenever there is a significant change in the operating environment.
Q: Can the sensor measure CO2 levels outdoors? A: While the MH-Z19B can measure CO2 levels outdoors, it is designed primarily for indoor use and may not perform optimally in outdoor conditions.
Q: Is the sensor resistant to humidity? A: The sensor can operate in 0 - 95% RH non-condensing environments. High humidity levels may affect the sensor's performance over time.
For further assistance, consult the manufacturer's datasheet and user manual.