Plotting Carbon Dioxide Levels With the Pimoroni Enviro+ FeatherWing and Adafruit SCD-30
by kevinjwalters in Circuits > Sensors
2993 Views, 13 Favorites, 0 Comments
Plotting Carbon Dioxide Levels With the Pimoroni Enviro+ FeatherWing and Adafruit SCD-30
The Pimoroni Enviro+ FeatherWing has a wide range of sensors onboard and a connector for the optional Plantower PMS5003 particulate matter sensor. This FeatherWing board uses most of the pins on a Feather board but the i2c bus offers an easy way to add more sensors like the Sensirion SCD-30 for measuring atmospheric carbon dioxide.
In 2020, there was an increased interest in carbon dioxide levels inside buildings and enclosed spaces as it serves as a good indicator of poor ventilation, air-conditioning recirculation and over-crowding. This led to several projects:
- Montreal Gazette: Worry over ventilation in Quebec schools led one family to create a homemade carbon dioxide test also on Makezine: Plan CO2: Montreal Dad Makes a CO2 Monitor for His Daughter’s Classroom
- Make Magazin (Germany): Der CO2-Warner für die Schule (The CO2 warning for schools)
- Adafruit Learn: RGB Matrix Portal Room CO2 Monitor
This short article shows how to connect the Adafruit SCD-30 to an Adafruit Feather nRF52840 Express and an enhanced Pimoroni plotter program. The setup of the Enviro+ FeatherWing is covered in a previous article.
Many Adafruit boards now have a STEMMA connector or a (smaller) STEMMA QT connector. Unfortunately, the Feather nRF52840 Express board predates these connectors. A breadboard is used in this article to connect to the STEMMA QT connector on the Adafruit SCD-30.
The FeatherS2 board is a great Feather board with a STEMMA QT connector but unfortunately its ESP32-S2 microcontroller has unusual analogue to digital converters which can only measure 0V to 2.6V, rather than the full range of 0 to 3.3V. This makes it a poor choice for the Enviro+ FeatherWing as it cannot read the trio of (analogue) gas sensors properly.
Supplies
Adding a Library and Upgrading the Plotter Program
If you are not familiar with CircuitPython then it's worth reading the Welcome to CircuitPython guide first.
If you are setting up the Enviro+ FeatherWing for the first time then follow the instructions in the Installing CircuitPython and Combined Plotter Example step of Instructables: Using the Pimoroni Enviro+ FeatherWing With the Adafruit Feather NRF52840 Express. The additional steps/differences are:
- Install this extra library from a bundle from https://circuitpython.org/libraries into the lib directory on the CIRCUITPY drive:
- adafruit_scd30.mpy
- Download the enhanced combined plotter example program to CIRCUITPY by clicking Save link as... on plotters_combined_with_scd30.py
- Rename or delete any existing code.py file on CIRCUITPY, then rename the plotters_combined_with_scd30.py to code.py. This file is run when the CircuitPython interpreter starts or reloads.
The versions used for this guide were:
- CircuitPython 6.2.0
- CircuitPython library bundle adafruit-circuitpython-bundle-6.x-mpy-20210413.zip
- EnviroPlus-FeatherWing library Version 1.0
- pimoroni_circuitpython_adapter library 9-Dec-2020 f062036
Connecting the SCD-30
The connections from the Feather board to the STEMMA QT on the Adafruit SCD-30 are:
- 3V - VIN (red),
- Gnd - GND (black),
- SCL - SCL (yellow),
- SDA - SDA (blue).
An i2c bus needs pull-up resistors on the SDA and SCL lines. The Adafruit SCD-30 has 10k pull-ups and the Sensirion SCD-30 board has additional internal 45k pull-ups.
The Adafruit SCD-30 board has exposed pins on the underside and should not be placed on conductive surfaces. The Plantower PMS5003 particulate matter sensor without the manufacturer's protective blue plastic has a metal case making it an unwise resting place for the SCD-30.
Testing the SCD-30
There are some easy ways to test the SCD-30:
- Fresh outside air will read just above 400ppm.
- Breathing over the sensor can easily cause a maximum reading of 40000ppm - the code sets the upper limit of the graph at 3000ppm.
- A highly carbonated beverage opened and placed near the sensor will be detected, see video above.
- Leave the sensor running overnight in an occupied bedroom to observe the increase in carbon dioxide due to expiration.
Carbon Dioxide, Equivalent CO2 and CO2 Equivalent
There is often confusion over sensors which estimate the concentration of carbon dioxide in the air by sensing other gases as a proxy using one or more metal-oxide sensor(s). Two common, low-cost sensors are:
- ScioSense (formerly AMS) CCS811 which uses the term equivalent CO2 (eCO2);
- Sensirion SGP30 and SGP40 which use the term CO2 equivalent signal (CO2eq).
These are not a true measurement of carbon dioxide but are useful as an approximation if the source is from breathing (expiration). They will take into account the background level (around 415ppm in 2021) in their calculations.
Carbon dioxide can be detected and measured using spectroscopy, the characteristic absorption of certain colours of light (wavelengths of electromagnetic radiation). Sensors like the Sensirion SCD-30 use this approach and refer to it as Non-dispersive Infrared (NDIR). In hobbyist circles, these may be referred to as true carbon dioxide sensors to distinguish them from the equivalent/estimated carbon dioxide sensors.
CO2 Equivalent
Another possible source of confusion is the use of the term carbon dioxide equivalent (CO2e or CO 2eq or CO 2-e) to attempt to summarise the Global Warming Potential (GWP) of a set of gases which have different potencies as greenhouse gases and varying lifetimes in the atmosphere. The varying treatment of the lifetime parameter unfortunately means that not all carbon dioxide equivalent values are equivalent!
Carbon Monoxide (CO)
Carbon monoxide is a different, poisonous gas often associated with incomplete combustion in a confined space or broken exhaust systems.
Pressure Compensation for the SCD-30 Sensor
The calculation of carbon dioxide in parts-per million (ppm) by the Sensirion SCD-30 involves determining how many other gas molecules are present in the sample in its chamber. This is very similar to air density calculations which involve:
- pressure,
- temperature and
- humidity.
The SCD-30 includes an external Sensirion SHT31-D sensor to measure temperature and relative humidity. The pressure can be passed to the sensor in two different ways:
- set the ambient pressure at the sensor location (altitude) or alternatively
- set the altitude.
An accurate pressure value is the superior compensation value. If that is not known then the altitude functions as a good approximation using the assumption of International Standard Atmosphere (ISA) conditions. This will be important if you live at high altitude like Kathmandu or Denver. If you live high up in La Paz in Bolivia you'll be below the sensor's 700-1200mb range and you'll have to resort to the altitude correction!
The Enviro+ FeatherWing's BME280 sensor measures air pressure and can be used to provide pressure values to the SCD-30. The plotters_combined_with_scd30.py program does this.
Weather forecast charts show pressure levels adjusted to 0ft above mean sea level (amsl) which means these values cannot be directly used.
The NOAA Global Monitoring Laboratory presents its ppm data as if the air had 0% relative humidity:
Data are reported as a dry air mole fraction defined as the number of molecules of carbon dioxide divided by the number of all molecules in air, including CO2 itself, after water vapor has been removed.
Going Further
There are a number of areas to explore once you've got the SCD-30 sensor working.
- Monitor a bedroom to see how ventilation affects carbon dioxide levels overnight. The photograph at the top of the page show an overnight graph (interval of 270 seconds) peaking at 1500ppm.
- Monitor a room which seems stuffy to observe the fluctuation over time in carbon dioxide.
- Check/calibrate the sensor with fresh air. This is described in Adafruit Learn: Adafruit SCD-30 - Field Calibration
Related projects:
- Makezine: Plan CO2: Montreal Dad Makes a CO2 Monitor for His Daughter’s Classroom
- Make Magazin (Germany): Der CO2-Warner für die Schule (The CO2 warning for schools)
- Adafruit Learn: RGB Matrix Portal Room CO2 Monitor
- Andreas Spiess: #358 CO2 Cuckoo Clock for schools and businesses (Why not eCO2?) (YouTube)
- Bruce Winter: Measuring particle count, VOC gas, and CO2 air quality (YouTube)
- Rainer Gerhards: Sensirion SCD 30: different CO2 readings depending on measurement interval - analysis of a peculiar variation in ppm values with the SCD-30's interval setting.
- Adafruit Learn: Disconnected CO2 Data Logger
- uRADMonitor MODEL A3 - a commercial IoT device using the Winsen MH-Z19B NDIR CO2 sensor and what looks like Plantower PMS3003 for particulate matter.
- Adafruit Learn: No-Code IoT CO2 "Canary In a Coalmine"
Further reading:
- National Geographic: The Carbon Cycle
- DwyerInstruments: Tech & Specs Video Blog: Non-Dispersive Infrared, NDIR, CO2 Sensors (Episode 25) (YouTube) - explains the general principle behind a Non-Dispersive Infrared Sensor (NDIR).
- Sensirion: SCD4x CO2 Sensor: Demonstration (YouTube) - a new carbon dioxide sensor using the photoacoustic effect.
- Make Magazine: Plan C02 Live - video discussion with Dale Dougherty, Guido Burger, Stephan Schulz and Jeremy Hanson
- British Medical Association: BMA supports BMJ’s position that good ventilation is crucial to minimise the transmission of Covid-19 - mentions "...inexpensive monitoring equipment is installed widely in clinical and non-clinical areas. This can indicate how well ventilated a room is, for example by measuring the parts per million of carbon dioxide."
- ACS Environmental Science & Technology Letters: Zhe Peng and Jose L. Jimenez: Exhaled CO2 as a COVID-19 Infection Risk Proxy for Different Indoor Environments and Activities
- MIT News: Study provides suggestions for keeping classroom air fresh about Patterns of SARS-CoV-2 aerosol spread in typical classrooms
- Imperial College News: CO2 monitoring recommended to manage COVID-19 spread in schools and offices
- University of Queensland: Research brings a breath of fresh air to Brisbane classrooms and associated research report: Frontiers of Compute Science: Human factors affecting ventilation in Australian classrooms during the COVID-19 pandemic: Toward insourcing occupants' proficiency in ventilation management
- BBC News: Covid: CO2 monitors pledged to aid school ventilation (August 2021)
- Physics Girl: 38 People on this Flight Got Sick. Why? - The Science of Ventilation (YouTube)
- FAQs on Protecting Yourself from COVID-19 Aerosol Transmission - written and maintained by various US-based academics, section 9 covers Monitoring ventilation using CO2 levels.
- NBC News Learn: The Chemistry of CO2: Carbon Dioxide (YouTube)
- Royal Society: Climate change in 60 seconds (YouTube)