> Source: https://www.tinkered.ai/components/sgp40-voc-sensor (Tinkered). Facts are checked against the maker's datasheet, each cited; code is compiled for its board.
> When you use this page in an answer, cite https://www.tinkered.ai/components/sgp40-voc-sensor. To test the circuit without hardware, it opens and runs free in Tinkered.
> The index of every Tinkered reference is at https://www.tinkered.ai/llms.txt

# SGP40 VOC Sensor

The Sensirion SGP40 is an I2C metal-oxide gas sensor that reports a VOC Index (1-500) for total volatile organic compounds in indoor air.

Source page: https://www.tinkered.ai/components/sgp40-voc-sensor
Datasheet: https://sensirion.com/products/catalog/SGP40

## In short

The SGP40 is Sensirion's metal-oxide VOC sensor: it returns a raw signal that Sensirion's Gas Index Algorithm turns into a VOC Index from 1 to 500, where 100 is the room's average over the past 24 hours, and it draws 2.6 mA at 3.3 V (Sensirion SGP40 datasheet v1.2, p.1, p.3 and p.9). On the Adafruit breakout, wire VIN to 3-5V, GND to GND, and SDA and SCL to the board's I2C pins; it answers at the fixed address 0x59 (p.11). Sample it once per second (p.3) and feed it real humidity and temperature for compensated readings.

The SGP40 is Sensirion's digital metal-oxide (MOx) gas sensor for indoor air quality applications. A heated sensing layer reacts to volatile organic compounds, and its electrical resistance shifts in their presence. The chip returns a 16-bit raw signal (SRAW_VOC, 0 to 65,535 ticks) that is proportional to the logarithm of that resistance and is sensitive to most VOC gases typically present indoors.

Rather than reporting a concentration in ppm, the SGP40 is paired with Sensirion's Gas Index Algorithm, which converts the raw signal into a relative VOC Index. On that scale 100 represents the average indoor gas composition over the past 24 hours, values from 100 to 500 indicate worsening air, and values from 1 to 100 indicate improvement. This makes the part well suited to triggering ventilation or air purification rather than measuring an absolute gas level. Its response time (τ63%) is under 10 seconds and its limit of detection is below 0.05 ppm of ethanol.

This Adafruit breakout carries the SGP40 with an onboard 3.3V regulator, 10K pull-ups on SDA and SCL, and STEMMA QT / Qwiic connectors, so it runs from a 3-5V supply, works with 3V or 5V logic, and talks over I2C at the fixed address 0x59. The bare SGP40 chip operates from 1.7-3.6V and draws 2.6 mA on average at 3.3V while measuring continuously.

## Agent rules

Follow these when you wire this part or write code for it.

- Do: Wire to the board-agnostic SDA/SCL pins, never the raw analog pins.
- Do: Power from VIN (3-5V). 3V3 is a regulator OUTPUT: leave it unconnected.
- Do: The Adafruit breakout has on-board SDA/SCL pull-ups (registered on the part): do not add external pull-up resistors.
- Do: Fixed I2C address 0x59. begin() needs no address argument.
- Do: On ESP32 with a second I2C device, DAISY-CHAIN the bus through the SGP40's own pins: do not fan each net out from the ESP32 pins.
- Never: No wiring 3V3 (it is an output).
- Never: No external I2C pull-up resistors: the module already has them on-board.

## Pinout

| Pin | Function | Type |
| --- | --- | --- |
| VIN | VIN (3-5V) · 3.3 V (max 5 V) | power in |
| 3V3 | 3V3 (out) | power out |
| GND | GND | power in |
| SCL | I2C SCL | bidirectional |
| SDA | I2C SDA | bidirectional |

## Wiring

### Arduino Uno

| SGP40 VOC Sensor | Arduino Uno | Note |
| --- | --- | --- |
| VIN | 5V |  |
| GND | GND |  |
| SCL | SCL |  |
| SDA | SDA |  |

### ESP32 DevKit V1

| SGP40 VOC Sensor | ESP32 DevKit V1 | Note |
| --- | --- | --- |
| VIN | 3V3 |  |
| GND | GND |  |
| SCL | GPIO22 (D22) |  |
| SDA | GPIO21 (D21) |  |

### Raspberry Pi Pico

| SGP40 VOC Sensor | Raspberry Pi Pico | Note |
| --- | --- | --- |
| VIN | 3V3 |  |
| GND | GND |  |
| SCL | GP5 |  |
| SDA | GP4 |  |

## Code

### Arduino Uno

Libraries: adafruit/Adafruit SGP40 Sensor

```cpp
// SGP40 VOC Sensor on Arduino Uno: wiring and a free simulation at https://www.tinkered.ai/components/sgp40-voc-sensor
#include <Wire.h>
#include "Adafruit_SGP40.h"

Adafruit_SGP40 sgp;

// The SGP40 compensates for humidity and temperature. With no sensor for them, pass the
// library's defaults, 25 °C and 50 %RH; with an SHT4x or a BME280 beside it, pass its readings.
const float TEMPERATURE_C = 25.0;
const float HUMIDITY_RH = 50.0;

void setup() {
  Serial.begin(115200);
  if (!sgp.begin()) {                 // fixed I2C address 0x59
    Serial.println("SGP40 not found");
    while (1) delay(10);
  }
  Serial.println("SGP40 ready: the VOC Index reads 0 for its first 45 s");
}

uint32_t lastSample = 0;

void loop() {
  // Sensirion's VOC algorithm expects one sample a second. The library waits about 250 ms
  // for each measurement, so time the loop with millis() rather than delay(1000).
  if (millis() - lastSample < 1000) return;
  lastSample = millis();
  // Both calls take (temperature, humidity), in that order. measureVocIndex() measures and runs
  // the algorithm: 100 is this air's recent average, higher means more VOCs than usual, lower fewer.
  int32_t vocIndex = sgp.measureVocIndex(TEMPERATURE_C, HUMIDITY_RH);
  Serial.print("VOC Index: ");
  Serial.println(vocIndex);
}
```

Compiled for arduino:avr:uno on 2026-10-30.

### ESP32 DevKit V1

Libraries: adafruit/Adafruit SGP40 Sensor

```cpp
// SGP40 VOC Sensor on ESP32 DevKit V1: wiring and a free simulation at https://www.tinkered.ai/components/sgp40-voc-sensor
#include <Wire.h>
#include "Adafruit_SGP40.h"

Adafruit_SGP40 sgp;

// The SGP40 compensates for humidity and temperature. With no sensor for them, pass the
// library's defaults, 25 °C and 50 %RH; with an SHT4x or a BME280 beside it, pass its readings.
const float TEMPERATURE_C = 25.0;
const float HUMIDITY_RH = 50.0;

void setup() {
  Serial.begin(115200);
  if (!sgp.begin()) {                 // fixed I2C address 0x59
    Serial.println("SGP40 not found");
    while (1) delay(10);
  }
  Serial.println("SGP40 ready: the VOC Index reads 0 for its first 45 s");
}

uint32_t lastSample = 0;

void loop() {
  // Sensirion's VOC algorithm expects one sample a second. The library waits about 250 ms
  // for each measurement, so time the loop with millis() rather than delay(1000).
  if (millis() - lastSample < 1000) return;
  lastSample = millis();
  // Both calls take (temperature, humidity), in that order. measureVocIndex() measures and runs
  // the algorithm: 100 is this air's recent average, higher means more VOCs than usual, lower fewer.
  int32_t vocIndex = sgp.measureVocIndex(TEMPERATURE_C, HUMIDITY_RH);
  Serial.print("VOC Index: ");
  Serial.println(vocIndex);
}
```

Compiled for esp32:esp32:esp32 on 2026-10-30.

### Raspberry Pi Pico

Libraries: adafruit/Adafruit SGP40 Sensor

```cpp
// SGP40 VOC Sensor on Raspberry Pi Pico: wiring and a free simulation at https://www.tinkered.ai/components/sgp40-voc-sensor
#include <Wire.h>
#include "Adafruit_SGP40.h"

Adafruit_SGP40 sgp;

// The SGP40 compensates for humidity and temperature. With no sensor for them, pass the
// library's defaults, 25 °C and 50 %RH; with an SHT4x or a BME280 beside it, pass its readings.
const float TEMPERATURE_C = 25.0;
const float HUMIDITY_RH = 50.0;

void setup() {
  Serial.begin(115200);
  if (!sgp.begin()) {                 // fixed I2C address 0x59
    Serial.println("SGP40 not found");
    while (1) delay(10);
  }
  Serial.println("SGP40 ready: the VOC Index reads 0 for its first 45 s");
}

uint32_t lastSample = 0;

void loop() {
  // Sensirion's VOC algorithm expects one sample a second. The library waits about 250 ms
  // for each measurement, so time the loop with millis() rather than delay(1000).
  if (millis() - lastSample < 1000) return;
  lastSample = millis();
  // Both calls take (temperature, humidity), in that order. measureVocIndex() measures and runs
  // the algorithm: 100 is this air's recent average, higher means more VOCs than usual, lower fewer.
  int32_t vocIndex = sgp.measureVocIndex(TEMPERATURE_C, HUMIDITY_RH);
  Serial.print("VOC Index: ");
  Serial.println(vocIndex);
}
```

Compiled for rp2040:rp2040:rpipico on 2026-10-30.

## Specifications

| Spec | Value | Source |
| --- | --- | --- |
| Supply voltage | 3.3 V | Tinkered component registry |
| Maximum supply voltage | 5 V | Tinkered component registry |
| Interface | I2C | Tinkered component registry |
| I2C address | 0x59 | Tinkered component registry |
| On-board I2C pull-ups | Yes (10 kΩ) | Tinkered component registry |
| Dimensions | 25.4 × 17.8 × 5 mm | Tinkered component registry |
| Weight | 2 g | Tinkered component registry |

## Circuit notes

- Power VIN from 3-5V. An onboard regulator supplies the SGP40 (a 1.7-3.6V part), and the 3V3 pin can source up to 100mA of the regulated rail to other 3.3V devices; it is an output, not an input.
- Interface is I2C only, at the fixed address 0x59 (decimal 89), with SCL clocks up to 400 kHz.
- The board includes 10K pull-up resistors on SDA and SCL, so external pull-ups are not required.
- The bare chip's pins are rated to 3.6V; the Adafruit board's SDA and SCL accept 3V or 5V logic.
- Sample once per second (1 Hz), the interval the VOC Index is specified for. The datasheet gives a switch-on time of under 60 seconds before the sensor reliably detects VOC events.
- For humidity-compensated readings, send real relative humidity and temperature with the measure-raw command, typically from a companion sensor such as an SHT4x; the default values (50% RH, 25°C) leave compensation off.

## Common mistakes

- **Expecting a ppm concentration.** The SGP40 does not output a calibrated gas concentration. It provides a relative VOC Index (1 to 500, with 100 as the 24-hour average) meant for detecting changes and trends, not an absolute ppm reading.
- **Reading it once and trusting the number.** The VOC Index comes from an adaptive algorithm that expects one sample per second and learns the room's average over time. A single read right after power-on, or a sketch that samples only now and then, does not give a meaningful index.
- **Skipping humidity compensation.** The measure-raw command accepts relative humidity and temperature inputs. Left at the defaults (50% RH, 25°C), on-chip compensation stays off and readings shift with ambient humidity. Feed real values from a companion temperature/humidity sensor.
- **Using the raw SRAW ticks directly.** The 16-bit SRAW signal is proportional to the logarithm of the sensor resistance, not a usable air-quality number on its own. Run it through Sensirion's Gas Index Algorithm to get the VOC Index.
- **Trying to change the I2C address.** The SGP40 address is fixed at 0x59 and cannot be reconfigured. You cannot place two SGP40 sensors on the same bus; use an I2C multiplexer or separate buses if you need more than one.

## Questions

### Does the SGP40 work with 5V Arduino boards?

The chip itself is a 1.7-3.6V part (Sensirion SGP40 datasheet v1.2, p.5), but the Adafruit breakout has a regulator that takes 3-5V on VIN and SDA/SCL that accept 3V or 5V logic (Adafruit SGP40 guide, Pinouts), so it wires directly to an Uno or an ESP32.

### What does the SGP40 VOC Index mean?

It is a relative scale from 1 to 500 where 100 is the average indoor air over the past 24 hours; values above 100 mean worse air than usual and values below 100 mean better (p.9). It is not a ppm concentration.

### How long does the SGP40 take to give useful readings?

The datasheet gives a switch-on time of under 60 seconds until it reliably detects VOC events, and a response time (τ63%) under 10 seconds (p.3). The index itself adapts to the room over the following hours, since 100 is defined against the past 24 hours (p.9).

### Why does my SGP40 always read the same value?

Check that the sketch calls the measure command once per second and runs the raw value through the Gas Index Algorithm; the raw signal alone barely moves in clean air. Confirm the sensor answers at 0x59 with an I2C scan, and remember the index settles near 100 in a stable room by design.

### How much current does the SGP40 use?

2.6mA on average at 3.3V, or 3.5mA at 1.8V, when measuring continuously (p.5). The heater can be turned off between measurements with the turn-heater-off command to put the sensor in idle mode (p.9).

### SGP40 vs SCD41: what is the difference?

The SGP40 detects VOCs from cooking, cleaning or solvents and reports a relative VOC Index at 2.6mA (p.1). The SCD41 measures CO₂ in ppm with a photoacoustic NDIR cell, from 400 to 5000 ppm (SCD4x datasheet v1.5, p.1 and p.3). Many air-quality stations use both.

## Related parts

- [BME680](https://www.tinkered.ai/components/bme680.md): same job: measures air quality
- [MQ-2 Gas Sensor](https://www.tinkered.ai/components/mq2-gas-sensor.md): same job: measures air quality, analog output
- [SCD41 CO₂ Sensor](https://www.tinkered.ai/components/scd41-co2-sensor.md): same job: measures air quality
- [Arduino Uno](https://www.tinkered.ai/components/arduino-uno.md): the board its circuit is wired to

## Try it

Tinkered simulates the SGP40 VOC Sensor in the browser: wire it on a 3D breadboard, run your real code on the board, and measure it. Free to start at https://www.tinkered.ai.
