014 - Brickcell CO2 SGP30 | MakeCode Microbit
Introduction
The SGP30 is a digital gas sensor from Sensirion that is designed to detect various gases in the ambient environment. It's commonly used to measure the concentration of Total Volatile Organic Compounds (TVOC) and equivalent carbon dioxide (eCO2) in the air.
TVOC (Total Volatile Organic Compounds): TVOC is a measure of the total concentration of volatile organic compounds present in the air. These compounds can include a wide range of organic chemicals and can come from various sources, including emissions from vehicles, industrial processes, and off-gassing from products and materials. High TVOC levels can indicate poor air quality or the presence of potentially harmful substances.
eCO2 (equivalent carbon dioxide): eCO2 is an estimate of the equivalent carbon dioxide concentration in the air. It's used as a proxy for assessing indoor air quality. The eCO2 value is calculated based on the sensor's response to various VOCs, and it provides an indication of how well-ventilated an indoor space is. High eCO2 levels may suggest inadequate ventilation, which can lead to discomfort and decreased indoor air quality.
The SGP30 sensor uses a metal-oxide semiconductor technology to detect these gases and provide a digital output that can be read by microcontrollers and other digital devices. It's often used in applications such as indoor air quality monitoring, air purifiers, and HVAC systems to assess and control air quality.
Hardware Instruction
Let's explore how to connect the Carbon Dioxide Sensor SGP30 module to a micro:bit microcontroller and utilize MakeCode for programming.
- Connect the SGP30 Sensor GND pin to microbit GND pin.
- Connect the SGP30 Sensor VCC pin to microbit 5V pin.
- Connect the SGP30 Sensor serial transmit pin (Tx) to microbit pin 0.
- Connect the SGP30 Sensor serial receive pin (Rx) to microbit pin 1.
Software Instruction
Now, let's start into programming the micro:bit to utilize the SGP30 sensor module.
- Login to https://makecode.microbit.org/ using your Microsoft account.
- Create a new project by clicking the "New Project" button. You may name it anything you want, I suggest to name it with descriptive name such as "co2-sgp30-test".
- Click the "Extensions" block just under the "Math" block.
- Type https://github.com/gbantique/brickcell-co2-sgp30/ on the search bar.
- Select the "brickcell-co2-sgp30" from the search results. The "co2 sgp30" block should appear under the "Brickcell" block.
- Copy the code provided below.
1serial.setBaudRate(BaudRate.BaudRate115200);
2Brickcell.iaqInit();
3basic.forever(function () {
4 serial.writeString("tvoc: " + Brickcell.tvoc());
5 serial.writeLine(" | co2eq: " + Brickcell.co2eq());
6 basic.pause(2000);
7});
- Open a Serial Monitor such as Termite terminal app https://www.compuphase.com/software_termite.htm/. Set the baud rate to 115200 bps.
Or you make a copy of my created project in your MakeCode workspace.
https://makecode.microbit.org/S21679-46211-50587-76754/
Expected Result
If you carefully follow the provided instruction above, you should be able to view the measured Total Volatile Organic Compounds (TVOC) in ppb unit and the Equivalent Carbon Dioxide in ppm unit in the serial terminal. Baud rate should be set to 115200 bps.
Posts in this series
- 016 - Brickcell 8x16 Dot Matrix Display | MakeCode Microbit
- 015 - Brickcell 8x8 Dot Matrix Display | MakeCode Microbit
- 013 - Brickcell Gesture APDS9960 | MakeCode Microbit
- 012 - Brickcell Rotary Encoder | MakeCode Microbit
- 011 - Brickcell RTC DS3231 | MakeCode Microbit
- 010 - Brickcell Gyro MPU6050 | MakeCode Microbit
- 009 - Brickcell TOF VL53L0X | MakeCode Microbit
- 008 - Brickcell Color TCS34725 | MakeCode Microbit
- 007 - Brickcell Pressure BMP280 | MakeCode Microbit
- 006 - Brickcell Weight HX711 | MakeCode Microbit
- 005 - Brickcell Fine Dust | MakeCode Microbit
- 004 - Brickcell Ultrasonic HCSR04 | MakeCode Microbit
- 003 - Brickcell NTC Temperature | MakeCode Microbit
- 002 - Brickcell DHT11 | MakeCode Microbit
- 001 - Brickcell LCD I2C | MakeCode Microbit
No comments yet!