ESP32 AGS10 Volatile Organic Compound (VOC) Sensor
The AGS10 is a gas sensor known for detecting a range of gases, including methane, propane, and hydrogen. Designed with stability and sensitivity, it’s suitable for industrial safety and environmental monitoring. The sensor offers a rapid response time, high sensitivity, and low power consumption, often used in applications like leak detection and air quality monitoring systems.
Jump to Code Examples
Price
AGS10 Sensor Technical Sepcifications
- Interface: I2C
- Measuring range: 0~99999 ppb
- Accuracy: 25% reading
- Operating Range: 0~50 ℃, 0~95%RH
- Voltage: 3.0 ± 0.1V DC
AGS10 Sensor Pinout
AGS10 Wiring with ESP32
ESP32 AGS10 Arduino IDE Code Example
#include <Wire.h>
#define I2C_ADDRESS 0xXX // Replace with the AGS10 I2C address
#define SDA_PIN 21 // I2C SDA pin for ESP32
#define SCL_PIN 22 // I2C SCL pin for ESP32
void setup() {
Wire.begin(SDA_PIN, SCL_PIN);
Serial.begin(115200);
Serial.println("AGS10 I2C Test");
}
void loop() {
Wire.beginTransmission(I2C_ADDRESS);
Wire.write(0x00); // Example register or command
Wire.endTransmission();
Wire.requestFrom(I2C_ADDRESS, 2);
if (Wire.available() == 2) {
int highByte = Wire.read();
int lowByte = Wire.read();
int sensorValue = (highByte << 8) | lowByte;
Serial.print("Sensor Value: ");
Serial.println(sensorValue);
}
delay(1000);
}
ESP32 AGS10 ESP-IDF Code Example
#include <stdio.h>
#include "driver/i2c.h"
#define I2C_MASTER_SCL_IO 22 // GPIO for SCL
#define I2C_MASTER_SDA_IO 21 // GPIO for SDA
#define I2C_MASTER_NUM I2C_NUM_1
#define I2C_MASTER_FREQ_HZ 100000
void app_main() {
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = I2C_MASTER_SDA_IO;
conf.scl_io_num = I2C_MASTER_SCL_IO;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = I2C_MASTER_FREQ_HZ;
i2c_param_config(I2C_MASTER_NUM, &conf);
i2c_driver_install(I2C_MASTER_NUM, conf.mode, 0, 0, 0);
// Add code to read from AGS10 via I2C
}
ESP32 AGS10 ESPHome Code Example
sensor:
- platform: ags10
tvoc:
name: TVOC
ESP32 AGS10 PlatformIO Code Example
Configure platformio.ini
[env:esp32]
platform = espressif32
board = esp32dev
framework = espidf
monitor_speed = 115200
ESP32 AGS10 PlatformIO Example Code
#include <Wire.h>
#define I2C_ADDRESS 0xXX // Replace with the AGS10 I2C address
#define SDA_PIN 21 // I2C SDA pin for ESP32
#define SCL_PIN 22 // I2C SCL pin for ESP32
void setup() {
Wire.begin(SDA_PIN, SCL_PIN);
Serial.begin(115200);
Serial.println("AGS10 I2C Test");
}
void loop() {
Wire.beginTransmission(I2C_ADDRESS);
Wire.write(0x00); // Example register or command
Wire.endTransmission();
Wire.requestFrom(I2C_ADDRESS, 2);
if (Wire.available() == 2) {
int highByte = Wire.read();
int lowByte = Wire.read();
int sensorValue = (highByte << 8) | lowByte;
Serial.print("Sensor Value: ");
Serial.println(sensorValue);
}
delay(1000);
}
Conclusion
We went through technical specifications of AGS10 Volatile Organic Compound (VOC) Sensor, its pinout, connection with ESP32 and AGS10 Volatile Organic Compound (VOC) Sensor code examples with Arduino IDE, ESP-IDF, ESPHome and PlatformIO.