Site icon Hackatronic

BME680 and ESP8266 Based Indoor Air Quality Monitoring System

BME680 and ESP8266 Air Quality Monitoring System

BME680 and ESP8266 Air Quality Monitoring System

Monitoring the air, we breathe indoors is becoming increasingly important, especially in urban environments where pollution levels can impact our health. In this project, we’ll build a smart Indoor Air Quality Monitoring System using the BME680 environmental sensor, ESP8266 Wi-Fi module, and Blynk IoT platform. This compact setup allows real-time tracking of temperature, humidity, barometric pressure, and indoor air quality (VOC levels) right on your smartphone.

BME680 Sensor Pinout
BME680 Sensor

🌐 Project Overview

This IoT-based project utilizes the BME680 sensor to measure environmental conditions and sends the data to the Blynk mobile app via the ESP8266 (NodeMCU or Wemos D1 Mini). With just a few components and minimal coding, you can monitor your room’s air quality from anywhere in the world.

🎯 Features

NodeMCU ESP8266 12E Wi-Fi
NodeMCU ESP8266 12E Wi-Fi

🔧 Required Components

Component Quantity
ESP8266 (NodeMCU / Wemos D1 Mini) 1
BME680 Environmental Sensor 1
Jumper Wires 1 set
Breadboard (optional) 1
Micro USB Cable 1
Smartphone with Blynk App 1

🔌 Circuit Diagram

BME680 with ESP8266
Interfacing BME680 with ESP8266

Connections Between BME680 and ESP8266 (I2C):

BME680 Pin ESP8266 Pin
VCC 3.3V
GND GND
SDA D2 (GPIO4)
SCL D1 (GPIO5)

Make sure your BME680 module is 3.3V compatible.

ESP8266 Pinout
ESP8266 Pinout

🧠 How It Works

IOT Based Air Quality Monitoring System with ESP32 & BME680 Sensor

📲 Blynk Setup

🖥️ Code for ESP8266 Microcontroller

Here’s the complete Arduino IDE sketch for the project:

// Tech Trends Shameer
// IoT-Based Pollution Monitoring System Using ESP8266 and BME680

#define BLYNK_TEMPLATE_ID "TMPL3Uj6HgZ6n"
#define BLYNK_TEMPLATE_NAME "Smart Pollution Monitoring"
#define BLYNK_AUTH_TOKEN "fZDiU5kBUuakFTxxdfhgvudl0IE55Vh0He_"

#define BLYNK_PRINT Serial
#include <Adafruit_Sensor.h>
#include <Adafruit_BME680.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = ""; // Enter your Wi-Fi name
char pass[] = ""; // Enter your Wi-Fi password

Adafruit_BME680 bme;
BlynkTimer timer;

void setup() {
    Serial.begin(115200);

    WiFi.begin(ssid, pass);
    while (WiFi.status() != WL_CONNECTED) {
        delay(1000);
        Serial.println("Connecting to WiFi...");
    }
    Serial.println("Connected to WiFi!");

    Blynk.begin(auth, ssid, pass);

    if (!bme.begin()) {
        Serial.println("Could not find a valid BME680 sensor!");
        while (1);
    }

    bme.setTemperatureOversampling(BME680_OS_8X);
    bme.setHumidityOversampling(BME680_OS_2X);
    bme.setPressureOversampling(BME680_OS_4X);
    bme.setGasHeater(320, 150); // Heater at 320°C for 150ms

    timer.setInterval(10000L, sendSensorData);
}

void sendSensorData() {
    if (!bme.performReading()) {
        Serial.println("Failed to read BME680 sensor!");
        return;
    }

    float temp = bme.temperature;
    float hum = bme.humidity;
    float press = bme.pressure / 100.0;
    float air_quality = bme.gas_resistance / 1000.0;

    Serial.print("Temperature: "); Serial.print(temp); Serial.println("°C");
    Serial.print("Humidity: "); Serial.print(hum); Serial.println("%");
    Serial.print("Pressure: "); Serial.print(press); Serial.println("hPa");
    Serial.print("Air Quality (VOC): "); Serial.print(air_quality); Serial.println(" kOhms");

    Blynk.virtualWrite(V0, temp);
    Blynk.virtualWrite(V1, hum);
    Blynk.virtualWrite(V2, press);
    Blynk.virtualWrite(V3, air_quality);
}

void loop() {
    Blynk.run();
    timer.run();
}

Let’s break down the air quality monitoring project code using BME680 sensor, ESP8266 board, and Blynk platform to explain everything clearly:

🔧 Code Overview

This project reads environmental data—temperature, humidity, pressure, and air quality (VOC levels)—using a BME680 sensor and sends it to the Blynk IoT app every 10 seconds over Wi-Fi using an ESP8266 microcontroller.

📦 Libraries and Definitions

#define BLYNK_TEMPLATE_ID ...
#define BLYNK_TEMPLATE_NAME ...
#define BLYNK_AUTH_TOKEN ...

These are Blynk-specific IDs that connect your device to the correct template in the Blynk app.

#define BLYNK_PRINT Serial
#include <Adafruit_Sensor.h>
#include <Adafruit_BME680.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

🔐 Credentials

char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Your SSID";
char pass[] = "Your Password";

🌡️ Sensor and Timer Initialization

Adafruit_BME680 bme;
BlynkTimer timer;

🔁 setup() Function

Serial.begin(115200);

Starts serial communication at 115200 baud rate for debugging.

🌐 Wi-Fi Connection

WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) { ... }

Loops until the ESP8266 connects to the internet.

📲 Blynk Initialization

Blynk.begin(auth, ssid, pass);

Starts the connection to the Blynk cloud using Wi-Fi and the authentication token.

📡 BME680 Sensor Setup

if (!bme.begin()) { ... }
bme.setTemperatureOversampling(BME680_OS_8X);
bme.setHumidityOversampling(BME680_OS_2X);
bme.setPressureOversampling(BME680_OS_4X);
bme.setGasHeater(320, 150);  // Heater temp = 320°C for 150ms

These settings improve measurement accuracy and enable the gas (VOC) sensor part of the BME680.

⏲️ Data Transmission Timer

timer.setInterval(10000L, sendSensorData);

Calls sendSensorData() every 10 seconds (10000 ms).

📤 sendSensorData() Function

if (!bme.performReading()) { ... }

Checks if the sensor is able to take a new reading.

float temp = bme.temperature;
float hum = bme.humidity;
float press = bme.pressure / 100.0;
float air_quality = bme.gas_resistance / 1000.0;

Reads:

🔄 Debug Output

Prints all readings to the serial monitor.

📱 Send to Blynk App

Blynk.virtualWrite(V0, temp);
Blynk.virtualWrite(V1, hum);
Blynk.virtualWrite(V2, press);
Blynk.virtualWrite(V3, air_quality);

Sends sensor values to virtual pins V0–V3. In the Blynk app, these can be linked to display widgets like Gauges or Graphs.

🔄 loop() Function

Blynk.run();
timer.run();

📲 Setting up ESP8266 Board

Smart Pollution Monitoring using BME680 & ESP8266 | IoT Air Quality Tracker with Blynk

📊 Sensor Output Interpretation

Note: BME680 does not output AQI directly. The gas resistance value can be used to estimate air quality with additional algorithms or libraries (e.g., Bosch BSEC).

Benefits of This Project

🚀 Possible Improvements

🏁 Conclusion

With this simple yet powerful setup, you can keep tabs on your indoor environment and take proactive steps to improve air quality. Whether you want to monitor a bedroom, lab, office, or workshop — this BME680 + ESP8266 IoT Air Quality Monitor is a smart addition to your living space.

IOT Based Air Quality Monitoring System with ESP32 & BME680 Sensor

ESP32 Weather Station with BMP280 / BME280 Sensor

Interfacing DHT11 + Soil Moisture Sensor with Arduino & ESP32

Water Quality Monitoring System: TDS Sensor + ESP32/Arduino

Exit mobile version