Arduino Projects

CO2 Sensor with Arduino, indoor air quality monitoring system, co2 ppm meter

CO2 Sensor Arduino:


NDIR CO2 Sensor, Carbon Dioxide Sensor for indoor air quality monitoring using Arduino- The concentration of carbon dioxide (CO2) in the Earth’s atmosphere has been increasing primarily due to human activities, such as the burning of fossil fuels (coal, oil, and natural gas), deforestation, and certain industrial processes. This increase in CO2 emissions has been linked to global warming and climate change.

Before the Industrial Revolution (mid-18th to mid-19th century), the atmospheric concentration of CO2 was relatively stable at around 280ppm (parts per million). However, since then, the concentration of CO2 has risen significantly. In September 2021, the concentration of CO2 in the atmosphere was about 415 ppm, which represents a significant increase of more than 45% compared to pre-industrial levels. But now in 2023 the concentration of CO2 in the atmosphere is around 424 ppm which is the highest value since 2.1 million years. The raise of atmospheric CO2 content to some extent results in global climate change. It’s important to note that the exact concentration of CO2 can vary slightly depending on the location and time of measurement.

How to accurately measure carbon dioxide gas concentration is becoming a universal research topic.

Gravity Infrared CO2 Sensor V2.0 measuring carbon dioxide (CO2) levels from 400ppm to 5000ppm.

DFRobot released its latest high-precision infrared CO2 sensor. The effectively measuring range is from 400 to 5000ppm. This sensor is based on non-dispersive infrared (NDIR) technology and has good selectivity and oxygen-free dependency. Besides, its service life could up to 5 years!

As usual, before trying something complex, first, I am going to start with a getting started tutorial, so that you guys can better understand how to use this beautiful piece of hardware. So, in this tutorial, I am going to make a simple indoor air quality monitoring system using the Gravity Infrared CO2 Sensor V2.0, Arduino, an i2c supported SSD1306 Oled display module, and a 5V buzzer.

An Arduino CO2 PPM monitor for measuring carbon dioxide levels.

I am going to use my latest Arduino and LoRa based development board, because it already has all the required components and I only need to connect this CO2 sensor.

According to the American Society of Heating, Refrigerating, and Air-Conditioning Engineers (ASHRAE) Standard 62.1, the recommend CO2 concentration for occupied spaces is below 1000 ppm. However, achieving lower level, such as below 800 ppm or even 600 ppm, is often desirable for improved air quality.

So, I am going to use this CO2 sensor for measuring the CO2 levels inside my room and studio. This can help me determine if the ventilation is adequate. As you might know, when the concentration of CO2 in the air exceeds 1000 ppm, it can have several effects; for example, reduced concentration, attention, and decision-making abilities. This can affect productivity and performance, particularly in environments such as offices, classrooms, and workplaces.

I want to keep the CO2 concentration in my workshop as low as possible. So, I am going to keep the CO2 ppm value below 600. And if it exceeds 600ppm the buzzer will turn ON. And then I can go ahead and open the windows or turn ON the exhaust fan, etc.

So, without any further delay, let’s get started!!!

Amazon Links:

Arduino Nano USB-C Type (Recommended)

Co2 sensor

SSD1306 Oled display Module

5V Buzzer

Other Tools and Components:

ESP32 WiFi + Bluetooth Module (Recommended)

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Gravity Infrared CO2 Sensor V2.0

Infrared CO2 sensor manufactured by DFRobot.

Technical Specifications:

Operating Voltage: 4.5 ~ 5.5V

Output: Analog (0.4 ~ 2V)

Measurement Principle: NDIR (non-dispersive infrared)

Measurement Range: 400 ~ 5000 ppm

Accuracy: ±100ppm + 6% readings

Response Time: <90s

Average Power: <430mW at 5V

Operation temperature: 00 C ~ 500 C

Operation Humidity: 0 ~ 95% RH (No condensation)

Life Span: >5 years


  1. High Accuracy
  2. Long Lifespan
  3. Auto Temperature Compensation
  4. Water Vapor Interference Resistance
  5. Analog Output

Zero Calibration

This sensor automatically calibrates itself, but you can also manually calibrate it.

Method 1: Manual zero calibration

Short circuit the HD and GND of the sensor to calibrate it. It always needs to last for over 7 seconds at a low level. Make sure that the sensor runs stably for over 20 minutes at a concentration of 400ppm before the calibration. But I don’t do it manually. I let the sensor calibrate itself automatically.

Method 2: Automatic zero calibration

The automatic calibration function means that the sensor will intelligently determine the zero point according to the ambient CO2 concentration and automatically calibrate it after a period of continuous operation. The calibration starts from power-on and is performed once every 24 hours. The zero point for automatic calibration is 400 ppm. This calibration is suitable for office and home environment.

What should be the CO2 level inside a room?

The recommended CO2 concentration level inside a room depends on several factors, including the purpose of the room, occupancy levels, and ventilation systems in place. Generally, maintaining a lower CO2 concentration is desirable for good indoor air quality and occupant comfort.

The American Society of Heating, Refrigerating, and Air-Conditioning Engineers (ASHRAE) provides guidelines for acceptable indoor CO2 levels. According to ASHRAE Standard 62.1, the recommended CO2 concentration for occupied spaces is below 1,000 parts per million (ppm) above outdoor ambient levels. However, achieving lower levels, such as below 800 ppm or even 600 ppm, is often desirable for improved air quality.

It’s important to note that the CO2 concentration is not necessarily a direct measure of other indoor air pollutants. High CO2 levels can indicate inadequate ventilation, which can lead to a buildup of other contaminants such as volatile organic compounds (VOCs) and odors. Therefore, maintaining proper ventilation and air exchange rates is crucial for maintaining good indoor air quality.

Different organizations and countries may have their own guidelines and regulations regarding indoor CO2 levels, so it’s advisable to refer to local building codes or consult with relevant authorities for specific recommendations in your region.

Monitoring devices such as CO2 sensors can be used to measure and track the CO2 levels inside a room. These sensors can help determine if the ventilation is adequate and assist in maintaining a healthy indoor environment.

What happens when CO2 level inside a room increases above 1000 ppm?

When the concentration of CO2 in the air exceeds 1,000 parts per million (ppm), it can have several effects on both human health and indoor air quality. Here are some potential impacts:

Decreased Cognitive Function: High levels of CO2 can impair cognitive function and lead to reduced concentration, attention, and decision-making abilities. This can affect productivity and performance, particularly in environments such as offices, classrooms, and workplaces.

Discomfort and Fatigue: Elevated CO2 levels can cause discomfort, drowsiness, and fatigue among occupants. This can contribute to reduced comfort and well-being in indoor spaces.

Headaches and Dizziness: Breathing in high levels of CO2 may cause headaches, dizziness, and even shortness of breath in some individuals. These symptoms can further affect comfort and overall health.

Poor Indoor Air Quality: High CO2 levels often indicate insufficient ventilation in indoor spaces. Inadequate ventilation can result in the buildup of other indoor pollutants, such as volatile organic compounds (VOCs), odors, and airborne contaminants, which can further impact air quality and human health.

Potential Health Risks: Prolonged exposure to high levels of CO2 can potentially lead to more severe health effects, including respiratory issues, increased heart rate, elevated blood pressure, and in extreme cases, asphyxiation. However, it’s important to note that reaching such high CO2 concentrations in well-ventilated spaces is unlikely.

To maintain a healthy indoor environment, it is recommended to ensure adequate ventilation, monitor CO2 levels, and take corrective measures if the concentrations exceed acceptable thresholds. Proper ventilation systems, such as mechanical ventilation or opening windows for natural ventilation, can help remove stale air and replenish it with fresh outdoor air, effectively lowering CO2 levels and improving indoor air quality.

What is NDIR Technology?

NDIR stands for Non-Dispersive Infrared technology. It is a sensing technique used for the detection and measurement of gases in various applications.

NDIR technology relies on the principle that different gases absorb infrared light at specific wavelengths. By passing infrared light through a sample gas and measuring the amount of light absorbed, NDIR sensors can determine the concentration of the target gas in the sample.

Here’s a simplified explanation of how NDIR technology works:

Light Source: An infrared light source emits infrared radiation at specific wavelengths.

Sample Chamber: The sample gas, which may contain the target gas to be measured, is passed through a sample chamber.

Optical Filter: An optical filter is placed in front of a detector. This filter allows only the specific wavelength of infrared light that the target gas absorbs to pass through.

Detector: The detector measures the intensity of the infrared light that reaches it after passing through the sample chamber. The intensity is affected by the amount of infrared light absorbed by the target gas.

Signal Processing: The detector sends the measured intensity to signal processing electronics, which calculate the gas concentration based on the known absorption characteristics of the target gas.

NDIR technology offers several advantages for gas detection and measurement, including:

Specificity: NDIR sensors can be designed to detect specific gases by selecting appropriate infrared wavelengths.

Sensitivity: NDIR sensors can achieve high sensitivity, allowing accurate measurements even at low gas concentrations.

Stability: NDIR sensors are known for their long-term stability and resistance to environmental factors, such as temperature and humidity.

Wide Range: NDIR technology can be applied to measure a wide range of gases, including carbon dioxide (CO2), carbon monoxide (CO), methane (CH4), and various hydrocarbons.

Due to its accuracy and reliability, NDIR technology finds applications in various industries, including environmental monitoring, industrial safety, indoor air quality monitoring, gas leak detection, and combustion analysis, among others.

Infrared CO2 Sensor interfacing with Arduino:

I am using my Arduino Nano development board but you can also do the same exact connections on a breadboard.

Infrared CO2 sensor interfaced with Arduino Nano.

Simply connect the RED and Black wires to the Arduino 5V and GND pins. And connect the Green wire to the Arduino pin 2.

The SSD1306 Oled display module VCC and GND pins are connected to the Arduino 3.3V and GND pins. Whereas the SCL and SDA pins of the Oled display module are connected to the Arduino Analog pins A5 and A4. A5 is the SCL and A4 is the SDA.

A circuit diagram of a 5V buzzer

The 5V buzzer is connected to the Arduino pin 8.

During the practical demonstration, when I was using the Arduino 5V the sensor would behave in an abnormal way. Then I switched to my 5V and 3A power supply.

A 5V power supply for Arduino projects

I have a detailed tutorial on how to make your own 5V and 3A power supply for your projects.

Altium Designer + Altium 365 + Octopart:

Arduino LoRa Free SMS

Altium 365 lets you hold the fastest design reviews ever. Share your designs from anywhere and with anyone with a single click. it’s easy, leave a comment tagging your teammate and they’ll instantly receive an email with a link to the design. Anyone you invite can open the design using a web browser. Using the browser interface, you’re able to comment, markup, cross probe, inspect, and more. Comments are attached directly to the project, making them viewable within Altium designer as well as through the browser interface. Design, share, and manufacture, all in the same space with nothing extra to install or configure. Connect to the platform directly from Altium Designer without changing how you already design electronics. Altium 365 requires no additional licenses and comes included with your subscription plan.

Get real-time component insights as you design with Octopart built into Altium 365. Octopart is the fastest search engine for electronic parts and gives you the most up-to-date part data like specs, datasheets, cad models, and how much the part costs at different amounts etc. Right in the design environment so you can focus on your designs. Start with Altium Designer and Activate Altium 365. Search for electronic parts on Octopart.

Download the Required Libraries:



Or if you want to install these libraries using the Arduino IDE, then you can follow these steps.

Go to the Sketch menu > then to Include Library, and click on the Manage Libraries. search for the Adafruit_GFX library and install it. Next, search for the Adafruit_SSD1306 library and install it. I have explained this in the video tutorial available at the end of this article.

Gravity Infrared CO2 Arduino Programming:

I downloaded this code from the DFrobot official website and of course I made a few changes. I added code for the Oled display module and for the 5V buzzer. So, when the CO2 ppm level inside a room increases above 600 ppm the buzzer is automatically turned ON and when the CO2 ppm level decreases below 600 ppm the buzzer is automatically turned OFF.

Along with the Buzzer you can also use a relay to control the Exhaust Fan, or to open the window. It depends on you, what exactly you want to control when the CO2 ppm value increases inside the room. Anyway, I have already uploaded this program and now let’s watch the Gravity Infrared CO2 Sensor V2.0 in action.

Arduino and CO2 Sensor Practical Demonstration:

I am going to use my 4S lithium Ion battery to power up the Arduino. So that I can freely move around and complete my testing.

Stable power supply setup for a CO2 sensor: 5V and 3A.

One more thing that I would like to talk about is, I am not using the Arduino 5V but I am using the 5V from my regulated power supply its 3A which is more than enough for its smooth operation.

CO2 sensor displaying inaccurate values during preheating.

When you power up the Arduino, wait for around 10 minutes. Because this sensor needs to be properly warmed up. During the preheating phase you may see unstable and inaccurate values and once the preheating phase is completed then the CO2 ppm value gets stable.

Measurement of carbon dioxide (CO2) parts per million (ppm) level inside a room.

I have been testing this sensor for hours, and the CO2 ppm value is quite stable. The CO2 ppm value in my studio is high because all the windows are closed, and there is no ventilation. Since the CO2 ppm value is greater than 600 ppm, that’s why the buzzer is on.

This sensor has been ON for around 4 hours and is still functioning well. If your power supply is good, and you have properly warmed up this CO2 sensor, I don’t think you will face any issues in using it. The more time passes, the more stable this sensor becomes. The value is so high because there is no ventilation in this room, and on top of that, I have also smoked cigarettes.

Anyways, my sensor is stable because I am using a powerful regulated 5V and 3A power supply. So if you want your sensor to work stably, I recommend using a good power supply. If you power it up with Arduino, you might encounter some problems.

Next, I will take this sensor outside to see if the CO2 ppm level decreases or not.

Graph depicting outdoor CO2 ppm levels in 2023 and CO2 concentration in the atmosphere.

As soon as I took this sensor outside, the ppm value started to decrease, which means this sensor is working. You can see the final outdoor CO2 ppm value is around 430ppm. I have been testing this sensor for hours, and it’s working flawlessly. The values are pretty stable, and I’m sure it’s because of my 5V and 3A power supply.

Now again, I am going to my studio and let’s see if I can lower the co2 ppm level by opening the door and windows. And I have also turned ON the Fan. As you can see the co2 ppm level inside this room is reducing because of the fresh air. The value was further reducing.

Decreasing indoor CO2 ppm level after opening windows.

This is pretty amazing and now I can keep track of the co2 concentration in my studio.

Now, I am going to take it to my bed room. Right now, the co2 ppm level inside my bedroom is around 635.

Measurement of carbon dioxide (CO2) parts per million (ppm) value inside a closed room with doors and windows.

I Opened the door and now let’s see if the co2 ppm level is going to decrease below 600ppm.

 Monitoring carbon dioxide (CO2) ppm in a room with open doors and windows for air quality assessment.

The buzzer just turned OFF, because now the Co2 ppm value is below 600. So, I just built myself this super awesome indoor and outdoor air quality monitoring system or co2 meter.

Co2 meter uses:

My designed co2 meter can be used in various settings for different purposes, including:

Indoor Air Quality (IAQ) Monitoring: CO2 meters are employed in offices, schools, homes, and other indoor spaces to monitor and assess the level of CO2. Elevated CO2 levels can indicate inadequate ventilation, potentially leading to discomfort, decreased productivity, and poor air quality.

HVAC Systems: CO2 meters are often integrated into Heating, Ventilation, and Air Conditioning (HVAC) systems to regulate ventilation and ensure adequate fresh air supply. By measuring CO2 levels, the HVAC system can adjust the airflow accordingly, improving energy efficiency and occupant comfort.

Greenhouses: In agricultural applications, CO2 ppm meters are used to monitor and control CO2 levels in greenhouses. Supplementing CO2 in controlled environments can enhance plant growth and productivity.

Industrial Settings: CO2 meters are utilized in industrial facilities, factories, and manufacturing plants to monitor and maintain safe CO2 levels. In certain industries, such as breweries and beverage production, CO2 ppm meters are essential for quality control and process optimization.

Safety and Compliance: CO2 ppm meters can also serve as safety devices in environments where the buildup of CO2 can be hazardous, such as confined spaces or areas with potential leaks or emissions. They help ensure compliance with safety regulations and provide early warnings in case of CO2 accumulation.

CO2 ppm meters typically display the CO2 concentration in parts per million (ppm) on a digital screen. Some models may also include additional features like data logging, alarm systems, and connectivity options for remote monitoring or integration with building automation systems.

It’s worth noting that CO2 ppm meters should be calibrated periodically to maintain accurate measurements. The calibration process involves exposing the meter to a known CO2 concentration (usually outdoor air) and adjusting it accordingly.

Overall, CO2 ppm meters are valuable tools for monitoring and managing indoor air quality, ventilation, and ensuring safety in various applications.

Watch Video Tutorial:


Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

One Comment

  1. Hello, Electronic Clinic has my admiration for how you comprehensively approach solving various problems. You helped me a lot to understand the BLYNK application. Thank you. Bilik I.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button