Super Simple CO2 Sensor!

Introduction: Super Simple CO2 Sensor!

Step 1: Purpose

With the current COVID-19 pandemic underway, face masks have become the new normal. Because face masks have become an integral part of our lives, it is necessary to make sure the ones we use are efficient and capable of blocking out any unwanted particles. Carbon dioxide is not necessarily the particles of interest, but with the current pandemic, certain supplies and equipment are not accessible. With that being said, using a compressed can of gas used for cleaning electronics seemed like an easy way to get our hands on a controlled gas. Using the Arduino, we plan to create a carbon dioxide sensor using a customized Arduino sketch, while measuring the amount of carbon dioxide that each type of face mask, regular cotton, surgical cloth, and mesh cloth, is able to block out.

Supplies

1.

Step 2: Materials

· Electronics Duster – 4 pack $13.97

We chose to use an Electronics Duster from the onnTM brand from Walmart. You do not necessarily need 4 but the more cans we have, the more tests we can run!

· SGP30 Gas Sensor - $20

o The SGP Gas Sensor chip was purchased from Amazon.

· Regular Cotton Mask- Varies

o This regular cotton mask was handmade from fabric that can be purchased at an Arts and Crafts store.

· Surgical Cloth Mask-

· Mesh Mask- $8.79

o This mask was purchased from Walgreens and comes in a pack of 20.

· Elegoo Circuit Board- varies

o Arduino or Elegoo boards are available for purchase on Amazon.com at about $15.99 but can be found at various places online.

· Solderless breadboard-varies

o Solderless breadboards are available at various places online. A breadboard similar to the one used in this instructable is available for purchase on Walmart.com for $5.54.

· Arduino/Elegoo Starter Kit-$42.99 from Elegoo.com

o Arduino starter kits are available for purchase at various online websites. The starter kit must include the selected wires used to perform the experiments.

2. Step 3: Arduino Assembly and Circuitry

· The Arduino circuitry only consisted of four wires and the SPG gas sensor.

o Orange/Green wire – Voltage in to Vo(Vin)

Connects the Elegoo circuit board to the SPG gas sensor going Vin to Vin.

Step 1: Simple CO2 Sensor

1. Step 3: Arduino Assembly and Circuitry

· The Arduino circuitry only consisted of four wires and the SPG gas sensor.

o Orange/Green wire – Voltage in to Vo(Vin)

§ Connects the Elegoo circuit board to the SPG gas sensor going Vin to Vin.

o White wire- ground wire

§ Connects the Elegoo circuit board to the SPG gas sensor going GND to GND.

o Red wire- Analog 4 to SDA (serial data line)

§ The red wire connects the Analog 4 on the Elegoo circuit board to the SDA port on the SPG gas sensor. The SDA is used to carry the data from the circuit board to the gas sensor.

o Orange wire- Analog 5 to SCL (serial clock line)

§ The orange wire connects the analog 5 on the circuit board to the SCL port on the gas sensor. The SCL is the clock signal that synchronizes the data transfer between the Arduino and the SPG gas sensor.

Here is a video to help with the set up and instruction on how to run the data

Step 2: Arduino Code

·

The Elegoo sketch used for this experiment is provided below. Simply copy and paste this code into the program. Every single character, symbol, and number must be included.

#include

#include "Adafruit_SGP30.h"

//Declare Variables

Adafruit_SGP30 sgp;

/* return absolute humidity [mg/m^3] with approximation formula

@param temperature [°C]

@param humidity [%RH]

*

/ Gets Absolute Humidity

uint32_t getAbsoluteHumidity(float temperature, float humidity) {

// approximation formula from Sensirion SGP30 Driver Integration chapter 3.15

const float absoluteHumidity = 216.7f * ((humidity / 100.0f) * 6.112f * exp((17.62f * temperature) / (243.12f + temperature)) / (273.15f + temperature)); // [g/m^3]

const uint32_t absoluteHumidityScaled = static_cast(1000.0f * absoluteHumidity); // [mg/m^3]

return absoluteHumidityScaled;

}

void setup() {

Serial.begin(9600);

Serial.println("SGP30 test");

if (! sgp.begin()){

Serial.println("Sensor not found :(");

while (1);

}

Serial.print("Found SGP30 serial #");

Serial.print(sgp.serialnumber[0], HEX);

Serial.print(sgp.serialnumber[1], HEX);

Serial.println(sgp.serialnumber[2], HEX);

// If you have a baseline measurement from before you can assign it to start, to 'self-calibrate'

//sgp.setIAQBaseline(0x8E68, 0x8F41); // Will vary for each sensor!

}

int counter = 0;

void loop() {

// If you have a temperature / humidity sensor, you can set the absolute humidity to enable the humditiy compensation for the air quality signals

//float temperature = 22.1; // [°C]

//float humidity = 45.2; // [%RH]

//sgp.setHumidity(getAbsoluteHumidity(temperature, humidity));

if (! sgp.IAQmeasure()) {

Serial.println("Measurement failed");

return;

}

Serial.print("TVOC "); Serial.print(sgp.TVOC); Serial.print(" ppb\t");

Serial.print("eCO2 "); Serial.print(sgp.eCO2); Serial.println(" ppm");

if (! sgp.IAQmeasureRaw()) {

Serial.println("Raw Measurement failed");

return;

}

Serial.print("Raw H2 "); Serial.print(sgp.rawH2); Serial.print(" \t");

Serial.print("Raw Ethanol "); Serial.print(sgp.rawEthanol); Serial.println("");

delay(1000);

counter++;

if (counter == 30) {

counter = 0;

uint16_t TVOC_base, eCO2_base;

if (! sgp.getIAQBaseline(&eCO2_base, &TVOC_base)) {

Serial.println("Failed to get baseline readings");

return;

}

Serial.print("****Baseline values: eCO2: 0x"); Serial.print(eCO2_base, HEX);

Serial.print(" & TVOC: 0x"); Serial.println(TVOC_base, HEX);

}

}

After you verify and upload the sketch to the Arduino program you then need to click on Tools and click serial monitor which will send the information from the instrument to arduino program.

Here is the video link again if you need help with the setup as well as how to start running the program

Be the First to Share

    Recommendations

    • Big and Small Contest

      Big and Small Contest
    • For the Home Contest

      For the Home Contest
    • Make It Bridge

      Make It Bridge

    Comments

    0
    bepstein
    bepstein

    2 years ago

    Great project, although it is much more of a "human-made gas detector" than a CO2 meter. See Andreas Spiess's latest video here: https://www.youtube.com/watch?v=hcPdZlpaRTo for the difference between eCO2 meters and "real" CO2 meters.