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.
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
5V connected to:
GND connected to:
26 connected to:
22 connected to:
21 connected to:
34 connected to:
14 connected to:
12 connected to:
13 connected to:
2 connected to:
/*
* 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