Product

What does a CO2 sensor do?

The biggest contributor to indoor air pollution is not formaldehyde or PM2.5 but the often-overlooked carbon dioxide. Once carbon dioxide reaches a certain level, it can pose a serious health risk, and no air purifier can effectively filter it. It is crucial to understand the health hazards, normal ranges, and solutions regarding indoor carbon dioxide concentrations.

What are the typical indoor and outdoor carbon dioxide concentrations? Within the normal range, carbon dioxide is harmless to the human body. In the natural environment, the concentration of carbon dioxide is approximately 0.04% (400 PPM), which may reach around 500 PPM in urban areas. In unoccupied indoor environments, the carbon dioxide concentration usually ranges from 500 to 700 PPM.

At what PPM level does carbon dioxide become harmful to health? The human body is highly sensitive to increases in carbon dioxide, with every 0.5% increase noticeably affecting the body. When the concentration reaches 1% (1000 PPM), individuals may experience stuffiness, lack of concentration, and palpitations. At 1500-2000 PPM, symptoms such as breathlessness, headaches, and dizziness may occur. Concentrations exceeding 5000 PPM can lead to cognitive impairment and confusion.

In real-life scenarios, carbon dioxide concentrations often exceed safe levels. For instance, when two individuals sleep overnight in a sealed bedroom, carbon dioxide concentrations can easily reach 2000 PPM. When the carbon dioxide concentration in an office space reaches 2000 PPM, employees may experience fatigue, lack of concentration, and mental exhaustion. Beyond 2000 PPM, individuals may even feel disinclined to continue working, and their cognitive abilities can significantly decline.

Maintaining good ventilation, regularly opening windows for fresh air and using air purifiers are effective methods of reducing indoor carbon dioxide levels. Among these methods, the carbon dioxide sensor is an important tool.

Today, we are introducing two CO2 measuring sensors for detecting carbon dioxide concentrations: CO2L Unit and TVOC/eCO2 Unit.

CO2L Unit is a digital CO2 concentration detection unit with a low-power mode designed for single-shot measurements. It features the Sensirion SCD41 sensor and a voltage regulator circuit, and communicates via I2C. This unit is suitable for measuring environmental conditions, with a typical accuracy of ±(40 ppm + 5% of the reading) for CO2 measurements. The measurement range for CO2 is 400 ppm to 5000 ppm, and it can also measure ambient temperature and humidity simultaneously.

TVOC/eCO2 mini Unit is a digital multi-pixel gas sensor unit that integrates the SGP30 sensor internally. It is primarily designed for measuring the concentrations of various volatile organic compounds (VOCs) and H2 in the air. Through programming, it allows for the measurement of TVOC (Total Volatile Organic Compounds) and eCO2 (Equivalent Carbon Dioxide) concentrations. The typical measurement accuracy within the measurement range is 15%. The SGP30 sensor communicates using the I2C protocol and has an on-chip humidity compensation feature that can be enabled with an external humidity sensor. The SGP30 also has a built-in calibration function, allowing users to calibrate it based on known measurement sources. Once internally calibrated, the SGP30 provides stable long-term output. Additionally, it's important to note that eCO2 is derived from H2 concentration, so the TVOC/eCO2 mini Unit cannot fully replace a CO2 sensor.

CO2 Monitoring Solution:

Here, we will introduce three methods to monitor the CO2 levels in the environment using the CO2L Unit and TVOC/eCO2 Unit and display the data on M5Stack Basic.

Method one: Use EasyLoader to get started.

This is the simplest and fastest way, let’s get it started!

Steps:

1. Open the documentation for the CO2L Unit  and  TVOC/eCO2 Unit .

2. Download the Easyloader program for each unit, which is a quick verification program.

3. Click to install when the download is complete. 

4. Select the port (here we choose COM34, but it's worth noting that different computers may display different COM ports, so please select the appropriate port), then click "burn" to start the program burning process.

 

It’s downloading and burning now.  Once completed, the screen will display "Successfully".

Then, the sensor will begin collecting carbon dioxide data from the air and display it on the Basic. The display effect will be as shown in the following image.

Method two: using source code in Arduino IDE

Next, I’ll lead the way to burn the firmware using the source code. We will use Arduino IDE as the programming environment.

Program CO2L Unit in Arduino IDE

1. The first step is to install the M5Stack development board in the Arduino IDE, which has been covered in our previous article.

2. Open the official documentation for the CO2L Unit , where we provide information about CO2L Unit and its relative code.

3. At the bottom of the documentation page, there are links to download the Arduino sample code. Since we are using the Core series Basic host today, please click on the first link.

4. Open the link and go to the entire project file.

5. Please click on the "Code" here to download the compressed file.

6. Please extract the compressed file into the "libraries" folder within the Arduino installation directory.

7. Open Arduino IDE, and click File>Examples>M5Unit-ENV>Unit_CO2_M5Core

8. Select the board

Select M5Stack-Core-ESP32 and the corresponding port (in this case, it is COM34, but the COM port may differ on different computers). Click OK.

9. Click the right arrow icon to upload the code.

When the upload is complete, we can see that the M5Stack Basic host screen is already displaying the CO2 concentration, as shown in the picture.

ProgramTVOC/eCO2 Unit in Arduino IDE

Next, we will continue to use the TVOC/eCO2 Unit to display the CO2 concentration.

1. Similarly, the first step is to install the M5Stack development board in the Arduino IDE, which has been covered in our previous article .

2. Open the documentation for the TVOC/eCO2 Unit. You can find information about the product and related code. 

3. At the bottom of the documentation, there is a link to download the code.

4. Open the link and go to the entire project file.

5. Please click on the "Code" here to download the compressed file.

6. Please extract the downloaded installation package into the "libraries" folder within the Arduino installation directory.

7. Open Arduino IDE, and click File>Examples>M5Stack>Unit>TVOC-SGP30

8. Select the board

Select M5Stack-Core-ESP32 and the corresponding port (in this case, it is COM34, but the COM port may differ on different computers). Click OK.

9. Click the right arrow icon to upload the code.

When the upload is complete, we can see that the M5Stack Basic host screen is already displaying the CO2 concentration, as shown in the picture.

Method three: using EasyLoader to get started

Finally, we introduce M5Stack’s graphical programming software UIFlow. It is convenient for those who are not familiar with coding.

1.To begin with, you need to install the firmware burning tool "Burner".

Note that different operating systems require different versions of Burner to be downloaded.

M5Burner_Windows: https://m5burner.m5stack.com/app/M5Burner-v3-beta-win-x64.zip

M5Burner_MacOS: https://m5burner.m5stack.com/app/M5Burner-v3-beta-mac-x64.zip

M5Burner_Linux: https://m5burner.m5stack.com/app/M5Burner-v3-beta-linux-x64.zip

Note:

For macOS users, after installing Burner, please move the application to the "Applications" folder as shown in the following image.

For Linux users, navigate to the extracted file directory and run "./M5Burner" in the terminal to launch the application.

2. Firmware Burning

Double-click to open the Burner firmware burning tool. In the left-side menu, select the corresponding device category and choose the firmware that matches your device, and click the“Download”button.

Connect the device to your computer using a Type-C data cable. Burner will automatically select the corresponding COM port. You can use the default configuration for the baud rate in M5Burner. Click "Burn" to start the burning process.

During the firmware burning stage, you need to enter the WiFi information in the WiFi configuration box. The WiFi information will be burned and saved to your M5Stack device along with the firmware.

Then, click "Start" to begin the burning process. Note: If a timeout occurs during the burning process, you can try lowering the baud rate to 115200.

When the burning log displays "Burn Successfully," it indicates that the firmware has been successfully burned.

If this is the first time burning or if the firmware program is running abnormally, you can click on "Erase" in the top right corner to erase the flash memory. In subsequent firmware updates, there is no need to erase again. However, please note that erasing the flash memory will delete the saved Wi-Fi information and refresh the API key.

3. Obtaining API Key

Please connect your M5Stack device to the computer using a Type-C data cable and select the corresponding COM port.

1). Click on "Configuration" to view the API Key information, which will appear in the configuration box. (Please copy and save the API Key as it will be used as credentials for UIFlow communication going forward).

2). Set the "Start Mode" to "Internet Mode." After completing this configuration, the device will automatically restart and enter online programming mode.

3). For further explanation of other configuration options in the configuration box, please refer to the configuration instructions below.

4. M5Burner Configuration Instructions

If you need to modify the configuration file, please connect your M5 device to the computer using a Type-C data cable and select the corresponding COM port. Then, you can click on "Configuration" to make the modifications.

APIKEY: The communication credentials for M5Stack device when using UIFlow web programming.

Start Mode: Configurable startup mode after booting.

Quick Start: Option to enable quick start to skip the startup interface.

Server: Selection of the server.

WiFi: Configuration of WiFi SSID and password.

COMX: Option to enable COMX.LTE network (this feature requires stacking the COMX.LTE module, for detailed instructions, please refer to the "Network Over COM.LTE Tutorial").

APN: Configuration of APN access point for COMX.LTE module. 

5. After completing the above steps, you can now start using UIFlow for programming.

Enter the UIFlow website URL in your browser: https://flow.m5stack.com/

Here, we will choose UIFlow 1.0 for now, as the list of supported devices for UIFlow 2.0 is still being expanded.

① In Step 3, we have got an API Key, and here we enter it in the bottom-left corner of the screen.

Then the screen will display “Connected”.

② At the "Add Units" section, add the "CO2L Unit" and select "OK."

Click “Load Examples”

④ Click on "Run" or "Download" (running is for testing the code and you can see the results on the host, but the code will not be saved on the device if power is disconnected. Downloading, on the other hand, will save the code on the device, and it will be retained even if power is disconnected. Choose based on your needs. If you choose to modify the code and upload it again, you will need to re-burn the firmware, which is discussed in Step 2).

The device will now start working as shown in the following image.

For the TVOC/eCO2 mini Unit, just follow the same steps as mentioned above, with the difference being the sensor selection during the unit addition. After completing the addition, select the example code, click "Run," and the device will start functioning normally.

Today's tutorial is complete here.

For an introduction to UIFlow statements, you can refer to https://docs.m5stack.com/en/quick_start/m5core/uiflow.

In the future, we will have a dedicated section specifically for explaining UIFlow statements. Stay tuned for that!

0 comments

  • There are no comments yet. Be the first one to post a comment on this article!

Leave a comment

Please note, comments must be approved before they are published

Liquid error (layout/theme line 209): Could not find asset snippets/pe-disco-countdown-timer.liquid