Skip to Content

Interfacing Arduino and SGP30 Versatile Air Quality Sensor

Interfacing Arduino and SGP30 Versatile Air Quality Sensor

Are you looking to build an air quality monitoring system using an Arduino? If so, the SGP30 sensor is a great choice.

In this article, we’ll focus on the SGP30 sensor, a smart digital air quality sensor that can measure the concentration of volatile organic compounds (VOCs) and carbon dioxide (CO2) in the air.

The SGP30 (from Sensirion) is a popular choice for indoor air quality monitoring applications, and with the help of an Arduino, you can build your air quality monitoring system. 

In this article, we’ll provide you with a comprehensive guide to connecting the SGP30 sensor to an Arduino microcontroller, including step-by-step instructions and example code.

We’ll also address some of the most commonly asked questions about the SGP30 sensor, providing you with all the information you need to get started on your air quality monitoring project. 

So grab your Arduino board and the SGP30 sensor, and let’s get started!

Components Needed To Build Arduino And SGP30 Sensor Project

Hardware Components

Software

Makerguides.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to products on Amazon.com.

Basics of The SGP30 Air Quality Sensor

In this section, we will understand the basics of the SGP30 sensor. The SGP30 is a digital air quality sensor that can measure the concentration of volatile organic compounds and carbon dioxide in the air. 

The sensor is designed for indoor air quality monitoring applications and has a measurement range of 0-60,000 ppb for VOCs and 0-40,000 ppb for CO2.

Here is the functional block diagram:

The SGP30 Air Quality Sensor

The SGP30 sensor uses advanced metal oxide gas sensor technology, which allows it to achieve a fast response time of fewer than 10 seconds. 

This means that the sensor can provide real-time air quality data, which can be used to detect and monitor changes in air quality.

One of the key features of the SGP30 sensor is its small size, measuring only 5mm x 5mm x 1.5mm.

This makes it easy to integrate into small devices and applications, such as portable air quality monitors, smart home devices, and wearable technology.

The SGP30 sensor operates over a wide temperature range of -40°C to 85°C, making it suitable for use in a range of different environments.

It is also capable of detecting a wide range of VOCs, including formaldehyde, acetone, and benzene.

To ensure accurate and reliable measurements, the SGP30 sensor requires a calibration process, which can be performed using an integrated calibration feature. 

The SGP30 sensor communicates with a microcontroller using an I2C interface, which allows for easy integration into a range of different applications.

A typical connection diagram is shown in the image below:

SGP30 sensor communicates with a microcontroller

It can be powered using a 1.8V DC power supply. 

One of the advantages of the SGP30 sensor is its low power consumption, which makes it suitable for battery-powered applications.

The sensor has a power consumption of less than 10 µA during idle mode.

Typical current consumption information of the SGP30 sensor:

  • Measurement current  – 48 mA (though the current is high, the actual measurement duration is less than 20 ms) 
  • Sleep current – 10 µA

The default I2C address of the Sensirion SGP30 gas sensor is 0x58 (7-bit address) or 0xB0 (8-bit address).

Features of the SGP30 Air Quality module

Here are the features of the Arduino-compatible SGP30 air quality sensor

Parameterrange
TVOC signal0 ppb to 60000 ppb
CO2400 ppm to 60000 ppm
Sampling rate1 Hz
Supply voltage1.62 V to 1.98 V
Communication interfaceI2C fast mode
Power up time0.4 to 0.6 ms
Soft reset time0.4 to 0.6 ms

Hot plate feature

The hot plate in the SGP30 sensor is a crucial component that enables the sensor to detect and measure the concentration of certain gases in the surrounding air.

The hot plate is an integral part of the sensor that heats the sensing material to a high temperature, typically around 400 degrees Celsius, in order to increase its sensitivity and responsiveness to gas molecules.

When the hot plate is heated up, the SnO2 sensing material is able to interact more easily with the gas molecules in the surrounding air, allowing the sensor to detect changes in gas concentration more quickly and accurately.

As gas molecules come into contact with the hot plate, they are oxidized on the surface of the sensing material, causing a change in its electrical conductivity. 

This change in conductivity is then measured by the sensor and converted into a corresponding gas concentration value.

Pin Details Of The SGP30 sensor IC

Let’s have a closer look at the SGP30 IC pins:

the SGP30 IC pins
Pin numberPin namePin function
1VDDSupply voltage
2VSSGround
3SDASerial data, bidirectional
4RConnect to the ground ( No function)
5VDDHSupply voltage (hot plate)
6SCLSerial clock, bidirectional

Step-By-Step Instructions To Connect The Sensor SGP30 With Arduino UNO

In this section, we will build a project using Arduino UNO and the SGP30 sensor. The connections are easy and take very little time to complete. 

The Sensor module and the Arduino communicate with each other via I2C serial interface. 

Let’s get started with the hardware connections.

How To Connect The Air Quality Sensor SGP30 To The Arduino UNO?

To complete the connection between your Arduino and the SGP30 sensor module, follow these step-by-step instructions. 

Note that there are many different sensor suppliers, and the sensor boards may come in various colors and shapes.

The instructions provided in this article are applicable to all types of SGP30 sensor modules.

all types of SGP30 sensor modules

Step 1: Start with the GND connections

Start with the GND connections

Connect the GND pin of the module to the GND of the Arduino. Choose any GND pins available on the Arduino for the connection.

Step 2: Connect the I2C SCL line.

Connect the I2C SCL line

Connect the SCL pin on the SGP30 to the SCL on the Arduino, as shown here in the diagram.

Step 3: Connect the I2C SDA line

Connect the I2C SDA line

Connect the SDA pin on the SGP30 module to the SDA pin on the Arduino UNO.

Step 4: Connect the Power line (Red wire)

Connect the Power line (Red wire)

Connect the VCC pin on the SGP30 module to the 5 V power pin on the Arduino.

Step 5: The basic connection

The basic connection

Congratulations! The hardware connections required are now complete.  In the next section, we will verify the functionality using some example code.

Arduino Code Example For The SGP30 Module Project

In this section, you can find the complete Arduino sketch and the information on installing the necessary libraries.

To install libraries related to SGP30, follow the steps below.

Arduino Code Example For The SGP30 Module Project
  1. Open Arduino IDe and click on Tools-> Library manager
  2. Search for SGP30
  3. Locate the Adafruit SGP30 sensor library in the results
  4. Click on Install

If it prompts you to install dependencies, say yes (install ALL).

Adafruit SGP30 sensor library

The complete Arduino Code For The SGP30 Arduino Project Example

#include "Wire.h"
#include "Adafruit_SGP30.h"

Adafruit_SGP30 sgp;

/* return absolute humidity [mg/m^3] with approximation formula
  @param temperature [°C]
  @param humidity [%RH]
*/
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(115200);
  while (!Serial) {
    delay(10);  // Wait for serial console to open!
  }

  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 humidity 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);
  }
}

In this code, we use the serial terminal to print the serial number of the sensor and the sensor readings.

You first calculate the baseline by taking the reading 30 times, then print the calculated baseline values. 

In the loop function, you print the readings from the sensor every 1 second.

Several parts from the Adafruit library Adafruit_SGP30 are used.

FAQs About The SGP30 Module And The Arduino UNO Projects

I have included a list of the most frequently asked questions about projects built using Arduino UNO and the air quality sensor SGP30.

If you have more questions, please post them in the comments section.

I will be happy to answer them.

1. What is the SGP30 sensor?

The SGP30 is a digital air quality sensor that measures the concentration of volatile organic compounds (VOCs) and carbon dioxide (CO2) in the air.

2. What is the measurement range of the SGP30 sensor?

The SGP30 can measure VOC concentrations from 0 to 60,000 parts per billion (ppb) and CO2 concentrations from 400 to 60,000 parts per million (ppm).

3. How does the SGP30 sensor work?

The SGP30 uses a metal oxide sensor technology that changes the resistance of the sensor when it is exposed to different gases.

The sensor then converts the resistance change into a digital output that can be read by a microcontroller.

4. What is the response time of the SGP30 sensor?

The response time of the SGP30 is typically less than 10 seconds for VOC measurements and less than 30 seconds for CO2 measurements. The sampling rate is 1 sample per second. 

5. How should the SGP30 sensor be calibrated?

The SGP30 sensor does not require calibration, but it does require a 20-minute “burn-in” period before the first use to stabilize the sensor readings.

So, you have to consider this in your application. 

6. What is the operating temperature range of the SGP30 sensor?

The SGP30 can operate in temperatures ranging from -20 to 70 degrees Celsius, but it is recommended to operate it in temperatures between 0 and 50 degrees Celsius for optimal performance.

7. Can the SGP30 sensor be used for outdoor air quality monitoring?

The SGP30 is primarily designed for indoor air quality monitoring and may not perform optimally in outdoor environments.

However, you can use it for outdoor air quality monitoring if the sensor is protected from direct exposure to sunlight and moisture.

It is recommended to use a weatherproof enclosure to protect the sensor in outdoor applications.

Conclusion

In this article, I have provided a comprehensive guide for connecting the SGP30 sensor to an Arduino UNO.

I have also included a detailed step-by-step guide to help you with the connection process, as well as an example Arduino code to verify that the connections are working correctly.

Additionally, I have addressed some of the most frequently asked questions about the SGP30 sensor, providing answers to help you better understand the capabilities and limitations of this air quality sensor.

With this information, you should be equipped to start using the SGP30 sensor in your air quality monitoring projects.

Whether you’re working on a DIY project or a commercial application, the SGP30 offers reliable and accurate air quality measurements.

If you have any questions or feedback, please let us know in the comments section.

I appreciate your support and encourage you to share this article with others who may find it useful.

Happy tinkering!