Introduction
This experiment shows how to use the MH-Z19 CO2 sensor with Arduino to monitor CO2 levels in the environment.

Components Needed
- MH-Z19 CO2 Sensor
- Arduino (e.g., Uno, Nano)
- Jumper wires
Circuit Setup
- Connect the MH-Z19 sensor to the Arduino using the TX/RX pins.
- Connect the GND and VCC pins of the sensor to the Arduino's GND and 5V pins.
Ensure that the sensor is properly powered and the connections are secure.

Code for CO2 Sensor Monitoring with MH-Z19
Upload the following code to your Arduino to read CO2 levels:
#include
SoftwareSerial mySerial(10, 11); // RX, TX
int CO2Value = 0;
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
}
void loop() {
if (mySerial.available()) {
CO2Value = mySerial.read();
Serial.print("CO2: ");
Serial.println(CO2Value);
}
delay(1000);
}
Explanation
The code reads data from the MH-Z19 sensor and displays the CO2 concentration value on the Serial Monitor.
Troubleshooting
- If no data is displayed, check the wiring and ensure the sensor is receiving proper power.
- If the sensor readings are erratic, try recalibrating the sensor.