Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Based IoT Indoor Air Quality Monitoring System with OLED Display and RGB LED

View and Edit Project In Cirkit DesignerImage of ESP32-Based IoT Indoor Air Quality Monitoring System with OLED Display and RGB LED

IoT Indoor Air Quality Monitoring Circuit Documentation

Summary

This document provides a detailed overview of an IoT Indoor Air Quality Monitoring system. The system measures temperature, humidity, carbon monoxide (CO), and PM2.5 levels using various sensors and displays the readings on a 128x64 OLED display. The ESP32 microcontroller is used to read sensor data and update the display. Additionally, the data is sent to the serial monitor. The RGB LED and fan are controlled based on air quality: green LED and fan off for normal air quality, red LED and fan on for poor air quality.

Component List

  1. ESP32-WROOM-32UE

    • Description: Microcontroller
    • Pins: 3v3, EN, VP, VN, 34, 35, 32, 33, 25, 26, 27, 14, 12, GND, 13, D2, D3, 5V, 23, 22, TX, RX, 21, 19, 18, 5, 17, 16, 4, 0, 2, 15, D1, D0, CKL
  2. MQ-7 SENSOR CARBON MONOXIDE GAS

    • Description: CO Gas Sensor
    • Pins: VCC, GND, A0, D0
  3. 128x64 OLED Display (I2C IIC SPI Serial)

    • Description: OLED Display
    • Pins: GND, SDA, SCL, VCC
  4. DHT22

    • Description: Temperature and Humidity Sensor
    • Pins: +, Out, -
  5. Resistor

    • Description: Resistor
    • Pins: pin1, pin2
    • Properties: 10k Ohms
  6. Adafruit SGP30

    • Description: Air Quality Sensor
    • Pins: VCC, 3.3V, GND, SCL, SDA
  7. Gravity : PM2.5 Air Quality Sensor

    • Description: PM2.5 Air Quality Sensor
    • Pins: SDA/D, SCL/C, GND/-, VCC/+
  8. RGB Led module

    • Description: RGB LED
    • Pins: +VCC Red, +VCC Green, +VCC Blue, GND
  9. PWM fan

    • Description: Fan
    • Pins: VCC, GND, PWM

Wiring Details

ESP32-WROOM-32UE

MQ-7 SENSOR CARBON MONOXIDE GAS

128x64 OLED Display (I2C IIC SPI Serial)

DHT22

Resistor

Adafruit SGP30

Gravity : PM2.5 Air Quality Sensor

RGB Led module

PWM fan

Code Documentation

/*
 * IoT Indoor Air Quality Monitoring
 * This Arduino Sketch measures temperature, humidity, CO, and PM2.5 levels
 * using DHT22, MQ-7, and PMS5003 sensors, and displays the readings on a
 * 128x64 OLED display. The ESP32 microcontroller is used to read sensor data
 * and update the display. Additionally, the data is sent to the serial monitor.
 * The RGB LED and fan are controlled based on air quality: green LED and fan off
 * for normal air quality, red LED and fan on for poor air quality.
 */

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <DHT.h>

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

#define DHTPIN 26
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

#define MQ7PIN 34
#define PMS5003_SET_PIN 16
#define PMS5003_RX_PIN 3
#define PMS5003_TX_PIN 1
#define PMS5003_RST_PIN 17
#define RED_LED_PIN 13
#define GREEN_LED_PIN 12
#define BLUE_LED_PIN 14
#define FAN_RELAY_PIN 35

void setup() {
  Serial.begin(9600);
  dht.begin();
  pinMode(MQ7PIN, INPUT);
  pinMode(PMS5003_SET_PIN, OUTPUT);
  pinMode(PMS5003_RST_PIN, OUTPUT);
  pinMode(RED_LED_PIN, OUTPUT);
  pinMode(GREEN_LED_PIN, OUTPUT);
  pinMode(BLUE_LED_PIN, OUTPUT);
  pinMode(FAN_RELAY_PIN, OUTPUT);
  digitalWrite(PMS5003_SET_PIN, HIGH);
  digitalWrite(PMS5003_RST_PIN, HIGH);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.display();
  delay(2000);
  display.clearDisplay();
}

void loop() {
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  int co = analogRead(MQ7PIN);
  String pmData = readPMS5003();

  display.clearDisplay();
  display.setTextSize(1);
  display.setText