You can easily wire this breakout to any microcontroller; we'll be using an Arduino.

Start by soldering the headers to the SGP30 breakout board.  Check out the Adafruit guide to excellent soldering if you're new to soldering.  Then continue on below to learn how to wire it to a Metro.

The sensor uses I2C address 0x58 and cannot be changed.


Connect the SGP30 breakout to your board using an I2C connection.  Here's an example with an Arduino-compatible Metro:

  • Board 5V to Sensor Vin (red wire on STEMMA QT version). (Metro is a 5V logic chip)
  • Board ground / GND to sensor ground / GND (black wire on STEMMA QT version).
  • Board SCL to sensor SCL (yellow wire on STEMMA QT version).
  • Board SDA to sensor SDA (blue wire on STEMMA QT version).

Install Adafruit_SGP30 library

To begin reading sensor data, you will need to install the Adafruit_SGP30 library (code on our github repository). It is available from the Arduino library manager so we recommend using that.

From the IDE open up the library manager...

And type in adafruit sgp30 to locate the library. Click Install

Load Demo

Open up File->Examples->Adafruit_SGP30->sgp30test and upload to your microcontroller wired up to the sensor

Then open up the serial console at 115200 baud, you'll see the serial number printed out - this is a unique 48-bit number burned into each chip. Since you may want to do per-chip calibration, this can help keep your calibration detail separate

The first 10-20 readings will always be TVOC 0 ppb eCO2 400 ppm. That's because the sensor is warming up, so it will have 'null' readings.

After a few seconds, you will see the TVOC and eCO2 readings fluctuate:

Every minute or so you'll also get a Baseline value printed out. More about that later!

You can take a bit of alcohol on a swap and swipe it nearby to get the readings to spike

That's it! The sensor pretty much only does that - all the calculations for the TVOC and eCO2 are done within the sensor itself, no other data is exposed beyond the 'baseline' values

Baseline Set & Get

All VOC/gas sensors use the same underlying technology: a tin oxide element that, when exposed to organic compounds, changes resistance. The 'problem' with these sensors is that the baseline changes, often with humidity, temperature, and other non-gas-related-events. To keep the values coming out reasonable, you'll need to calibrate the sensor.

If no stored baseline is available after initializing the baseline algorithm, the sensor has to run for 12 hours until the baseline can be stored. This will ensure an optimal behavior for the next time it starts up. Reading out the baseline prior should be avoided unless a valid baseline is restored first. Once the baseline is properly initialized or restored, the current baseline value should be stored approximately once per hour. While the sensor is off, baseline values are valid for a maximum of seven days.

Restarting the sensor without reading back a previously stored baseline will result in the sensor trying to determine a new baseline. The adjustement algorithm will be accelerated for 12hrs which is the Maximum time required to find a new baseline.
The sensor adjusts to the best value it has been exposed to. So keeping it indoors the sensor thinks this is the best value and sets it to ~0ppb tVOC and 400ppm CO2eq. As soon as you expose the sensor to outside air it can adjust to the global H2 Background Signal. For normal Operation exposing the sensor to outside air for 10min cumulative time should be sufficient.

If you're experienced with sensors that don't have a baseline, you either won't be able to measure absolute values or you'll have to implement your own baseline algorithm.
The sensor to sensor variation of SGP30 in terms of sensitivity is very good as each of them is calibrated. But the baseline has to be determined for each sensor individually during the first Operation.

To make that easy, SGP lets you query the 'baseline calibration readings' from the sensor with code like this:

uint16_t TVOC_base, eCO2_base;
sgp.getIAQBaseline(&eCO2_base, &TVOC_base);

This will grab the two 16-bit sensor calibration words and place them in the variables so-named.

You should store these in EEPROM, FLASH or hard-coded. Then, next time you start up the sensor, you can pre-fill the calibration words with sgp.setIAQBaseline(eCO2_baseline, TVOC_baseline);

This guide was first published on Jan 17, 2018. It was last updated on Jan 17, 2018.

This page (Arduino Test) was last updated on Jan 12, 2018.

Text editor powered by tinymce.