Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Weather & Environmental Monitoring

VOC Gas Sensor SGP30: Air Quality Monitoring with ESP32

VOC Gas Sensor SGP30: Air Quality Monitoring with ESP32

March 11, 2026 /Posted byJayesh Jain / 0

The SGP30 VOC gas sensor paired with ESP32 is an excellent combination for monitoring indoor air quality in Indian homes, offices, and schools. The SGP30 from Sensirion measures Total Volatile Organic Compounds (TVOC) and equivalent CO2 (eCO2), providing actionable data about air pollution sources like paints, cleaning products, adhesives, and cooking fumes that are common in Indian households. This tutorial covers everything you need to set up SGP30 VOC gas sensor air quality monitoring with an ESP32.

Table of Contents

  • What is the SGP30 Sensor?
  • Air Quality Concerns in Indian Homes
  • Wiring SGP30 to ESP32
  • Installing Required Libraries
  • Complete Arduino Code
  • Baseline Calibration
  • Adding an OLED Display
  • Frequently Asked Questions

What is the SGP30 Sensor?

The SGP30 is a fully calibrated, multi-pixel gas sensor platform manufactured by Sensirion AG. It uses a metal oxide sensing element to detect a broad range of VOCs and outputs eCO2 (equivalent CO2 concentration in ppm) and TVOC (total volatile organic compounds in ppb) readings. The sensor communicates over I2C, making it easy to interface with any microcontroller including the ESP32.

Key specifications of the SGP30:

  • Operating voltage: 1.8V (I2C logic level)
  • Supply current: 48mA (max)
  • TVOC output range: 0–60,000 ppb
  • eCO2 output range: 400–60,000 ppm
  • Response time: <1 second
  • I2C address: 0x58 (fixed)
  • Operating temperature: -40°C to +85°C

The SGP30 module boards available in India typically include a 3.3V regulator and I2C level shifter, allowing direct connection to both 3.3V ESP32 and 5V Arduino boards.

Recommended: GY-BME280-3.3 Precision Atmospheric Pressure Sensor — Combine BME280 with SGP30 to get temperature, humidity, and pressure data alongside VOC readings for comprehensive air quality monitoring.

Air Quality Concerns in Indian Homes

Indoor air quality is a significant concern in India. Several factors make Indian homes particularly susceptible to elevated VOC levels:

  • Cooking with biomass or LPG: Traditional cooking releases acrolein, benzene, and formaldehyde
  • Incense and dhoop burning: Common in Indian households; releases significant TVOC
  • New furniture and paints: Formaldehyde off-gassing from MDF and water-based paints
  • Cleaning products: Phenol-based disinfectants widely used post-COVID
  • Seasonal factors: Summer heat accelerates off-gassing from building materials

WHO guidelines suggest TVOC levels below 300 ppb are acceptable, 300–500 ppb is marginal, and above 500 ppb requires action. An SGP30-based monitor helps you identify when and where VOC levels spike in your home.

Wiring SGP30 to ESP32

The SGP30 uses I2C communication. Here is the wiring for an ESP32 development board:

SGP30 Pin ESP32 Pin
VCC 3.3V
GND GND
SDA GPIO 21
SCL GPIO 22

Note: The SGP30’s I2C address is hardcoded at 0x58 and cannot be changed. Ensure no other I2C device on your bus uses this address. The BME280 (0x76 or 0x77) and SSD1306 OLED (0x3C) are safe to use alongside the SGP30.

Installing Required Libraries

In Arduino IDE, go to Sketch → Include Library → Manage Libraries and install:

  • Adafruit SGP30 Sensor — by Adafruit Industries
  • Adafruit Unified Sensor — dependency for Adafruit libraries

For PlatformIO users, add to platformio.ini:

lib_deps =
  adafruit/Adafruit SGP30 Sensor@^2.0.1
  adafruit/Adafruit Unified Sensor@^1.1.9

Complete Arduino Code

#include <Wire.h>
#include "Adafruit_SGP30.h"

Adafruit_SGP30 sgp;

uint32_t getAbsoluteHumidity(float temperature, float humidity) {
  // Use this with SGP30's setHumidity() for better accuracy
  const float absoluteHumidity = 216.7f * ((humidity / 100.0f) * 6.112f *
    exp((17.62f * temperature) / (243.12f + temperature)) / (273.15f + temperature));
  const uint32_t absoluteHumidityScaled = static_cast<uint32_t>(1000.0f * absoluteHumidity);
  return absoluteHumidityScaled;
}

void setup() {
  Serial.begin(115200);
  Wire.begin();
  
  if (!sgp.begin()) {
    Serial.println("SGP30 not found!");
    while (1);
  }
  
  Serial.print("SGP30 serial #");
  Serial.print(sgp.serialnumber[0], HEX);
  Serial.print(",");
  Serial.print(sgp.serialnumber[1], HEX);
  Serial.print(",");
  Serial.println(sgp.serialnumber[2], HEX);
}

void loop() {
  if (!sgp.IAQmeasure()) {
    Serial.println("Measurement failed");
    return;
  }
  
  Serial.print("TVOC: "); Serial.print(sgp.TVOC); Serial.print(" ppbt");
  Serial.print("eCO2: "); Serial.print(sgp.eCO2); Serial.println(" ppm");
  
  // Air quality classification
  String quality;
  if (sgp.TVOC < 300) quality = "Good";
  else if (sgp.TVOC < 500) quality = "Moderate";
  else if (sgp.TVOC < 1000) quality = "Unhealthy for Sensitive Groups";
  else quality = "Unhealthy";
  
  Serial.print("Air Quality: "); Serial.println(quality);
  delay(1000);
}
Recommended: Waveshare BME280 Environmental Sensor — Use BME280 humidity readings to set SGP30’s absolute humidity compensation for up to 15% more accurate VOC readings.

Baseline Calibration

The SGP30 uses an on-chip baseline algorithm that automatically adjusts to ambient conditions. However, for best accuracy, save and restore the baseline values periodically. This prevents the sensor from “drifting” after a power cycle:

// Save baseline (run periodically, e.g., every hour)
uint16_t eco2_base, tvoc_base;
if (sgp.getIAQBaseline(&eco2_base, &tvoc_base)) {
  // Save to EEPROM or SPIFFS
  preferences.putUShort("eco2_base", eco2_base);
  preferences.putUShort("tvoc_base", tvoc_base);
}

// Restore baseline on startup (after 12+ hours of initial learning)
eco2_base = preferences.getUShort("eco2_base", 0);
tvoc_base = preferences.getUShort("tvoc_base", 0);
if (eco2_base && tvoc_base) {
  sgp.setIAQBaseline(eco2_base, tvoc_base);
}

Allow at least 12 hours of continuous operation before relying on baseline values. The SGP30’s algorithm improves continuously with exposure to your environment’s typical air composition.

Adding an OLED Display

For a standalone air quality monitor, add an SSD1306 OLED display. Install the Adafruit SSD1306 and Adafruit GFX libraries, then connect the OLED SDA/SCL to GPIO 21/22 (shared I2C bus):

#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

// In setup():
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();

// In loop(), after SGP30 reading:
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.println("Air Quality Monitor");
display.print("TVOC: "); display.print(sgp.TVOC); display.println(" ppb");
display.print("eCO2: "); display.print(sgp.eCO2); display.println(" ppm");
display.display();

Frequently Asked Questions

Why does the SGP30 always show 400 ppm eCO2 and 0 ppb TVOC initially?

These are the default startup values while the sensor’s algorithm initialises. The SGP30 requires approximately 15 seconds of warm-up after power-on before reporting meaningful values. Additionally, the baseline algorithm needs 12–24 hours of continuous operation to fully calibrate to your environment. The initial 400 ppm eCO2 represents clean outdoor air baseline, which is correct.

How accurate is the SGP30 for detecting cooking fumes?

The SGP30 is highly sensitive to alcohols, aldehydes, and ketones produced during cooking. It will detect elevated TVOC levels within seconds of starting to cook. However, it is a broad-spectrum sensor and cannot identify specific VOCs like formaldehyde individually. For specific gas identification, you would need electrochemical or photoionisation sensors.

Can I use SGP30 for monitoring air quality near traffic in Indian cities?

The SGP30 detects combustion-related VOCs from vehicle exhaust, making it useful for outdoor monitoring near busy roads in cities like Delhi, Mumbai, and Bangalore. However, for outdoor use, protect the sensor from direct rain and dust. The BME280’s humidity reading is essential here to apply humidity compensation and improve accuracy.

What is the difference between SGP30 and MQ135 for air quality?

The SGP30 is far superior to the MQ135. The SGP30 provides calibrated digital readings in standard units (ppb/ppm), has integrated baseline compensation, and uses I2C for noise-free communication. The MQ135 provides only an uncalibrated analog voltage that varies with temperature and humidity, requiring extensive external calibration. The SGP30 costs slightly more (₹500–₹800 vs ₹50–₹100) but delivers professional-grade results.

How do I integrate SGP30 readings with a home automation system in India?

The ESP32’s Wi-Fi allows direct integration with Home Assistant via MQTT, ESPHome, or the HTTPClient library. You can set up automation rules that turn on an exhaust fan when TVOC exceeds 500 ppb, or send WhatsApp notifications via Twilio API when air quality degrades. Home Assistant is free and runs on a Raspberry Pi—a popular choice for smart home enthusiasts in India.

Shop Air Quality Sensors at Zbotic →

Tags: air quality, eCO2, ESP32, SGP30, TVOC, VOC sensor
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Smart Curtain Motor with ESP32...
blog smart curtain motor with esp32 and home assistant india 597986
blog diy pcb etching at home toner transfer and fecl3 method 597995
DIY PCB Etching at Home: Toner...

Related posts

Svg%3E
Read more

Climate Education Kit: Build and Learn About Weather

April 1, 2026 0
Table of Contents Weather Education in Indian Schools Designing a STEM Weather Kit Sensor Experiments for Students Curriculum-Aligned Activities Arduino... Continue reading
Svg%3E
Read more

Citizen Science Weather: Contribute Data to IITM Pune

April 1, 2026 0
Table of Contents Citizen Science Weather in India Data Quality Standards for Contribution Setting Up a WMO-Compatible Station Calibration and... Continue reading
Svg%3E
Read more

Weather Station Network: Multiple Stations with Gateway

April 1, 2026 0
Table of Contents Why Build a Weather Station Network LoRa Communication for Sensor Nodes Gateway Design with Raspberry Pi Sensor... Continue reading
Svg%3E
Read more

Cyclone Tracker Display: Real-Time IMD Data on Screen

April 1, 2026 0
Table of Contents Cyclone Tracking in India IMD Cyclone Data Sources ESP32 and TFT Display Setup Fetching and Parsing Cyclone... Continue reading
Svg%3E
Read more

Monsoon Onset Predictor: Historical Data Analysis India

April 1, 2026 0
Table of Contents Understanding Monsoon Onset in India Key Indicators for Monsoon Prediction Sensor Package for Monsoon Monitoring Collecting Baseline... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now