esp8266 arduino

ESP8266 Based Air Pollution Detector

In this Blog, we propose a solution to air quality monitoring using the Internet of Things (IoT).

Air pollution has become an important health issue with the increase of industrialization, urbanization and vehicular emissions. To know how air quality affects human health and to take steps to reduce our exposure to harmful air pollutants, it’s important to monitor air quality. An ESP8266 based air pollution detector is an easy and low cost way to create an air quality monitoring solution that is real time.

In this comprehensive guide, we will go through step-by-step how to build a reliable air pollution detector using the ESP8266 Arduino NodeMCU and popular air quality sensors. We’ll also answer a key question: Let’s delve into NodeMCU what is its significance and using in this project?

What is NodeMCU ESP8266 Arduino?

To start off with the project, let’s first look at ‘NodeMCU what is’. The ESP8266 Wi-Fi SoC based open-source IoT development board is known as NodeMCU. Built in support for Wi-Fi makes it a perfect fit for any IoT projects. The Arduino IDE simplifies the programming of the module and communication over Wi-Fi is possible with the ESP8266 module.

Key Features of NodeMCU ESP8266:

With built in WiF for real time data transmission.

We will connect different sensors and modules using a voltage divider on few of the GPIO pins.

A cost effective way to create something connected.

Support for programming the Inks with the Arduino IDE for ease of use and debugging.

Air Pollution and Its Effects

Air pollution is the contamination of air for humans or other organisms by the presence of particles and many gases. PM2.5, PM10, carbon monoxide (CO), nitrogen dioxide (NO2), ozone (O3) and volatile organic compounds (VOCs) are all common air pollutants. High level of these pollutants can cause respiratory problems including cardiovascular diseases and other health problems if exposed for long period.

Project Overview: This is a Air Pollution detector using an ESP8266.

This paper seeks to construct a smart air pollution detection system that detects and records particulate matter (PM) level, temperature and humidity. The central controller for the project is the NodeMCU ESP8266 and is interfaced with air quality sensors such as the MQ-135 (CO2, ammonia & benzene detection) and the PMS5003 (PM2.5 & PM10 measurement). The uploaded data is related to the OLED screen and sent to a cloud service of real time monitoring. }

esp8266 arduino

Components Required

    • PMS5003 air quality sensor (PM2.5 & PM10)

    • The CO2, NH3, benzene, etc. detection sensor: MQ-135 Sensor

    • We are using DHT22 Sensor for temperature and humidity measurements.

    • OLED Display (optional; used to display local data)

    • Jumper wires

    • Breadboard

Step-by-Step Instructions

1. Setting Up the Hardware

First connect the sensors with the NodeMCU board. The following connections are suggested:

MQ-135 Sensor:

VCC to 3.3V or 5V of NodeMCU

GND to GND of NodeMCU

NodeMCU has an analog output A0 to A0.

PMS5003 Sensor:

VCC to 5V of NodeMCU

GND to GND of NodeMCU

TX to D5 of NodeMCU

DHT22 Sensor:

VCC to 3.3V

GND to GND

Data Pin to D4

OLED Display:

SDA to D2

SCL to D1

2. NodeMCU ESP8266 Programming

To program, we will use the Arduino IDE and make sure they have the required libraries, DHT22, Adafruit SSD1306, and SoftwareSerial for PMS5003.

Code Explanation

Sensor Setup: The dht22 sensor code initiates to read temperature and humidity from the container. We can also set two sensors, PMS5003 and MQ-135, up for measuring the PM values as well as CO2 and other air quality parameters.

Wi-Fi Connection: It allows the ESP8266 to connect to the Wi-Fi network, that is necessary for the realtime data transmission.

OLED Display: For local reference, it also displays sensor readings on the OLED screen.

Cloud Integration: Remote monitoring can send data through cloud server using HTTP or MQTT protocols.

How It Works

Now power the NodeMCU and make sure all the sensors are connected right.

Use the Arduino IDE and Upload Code.

After being connected to Wi-Fi, the system will begin to read data from MQ-135 and PMS5003 sensors.

The real time data collected is displayed on the OLED and sent to the cloud for remote access.

Enhancements: Advanced Features

1. And I added GPS for location based monitoring.

Adding a GPS module will allow air quality to be tracked in certain locations which is really useful for mobile air quality monitoring.

2. Creating a Mobile App for Real Time Alerts

Create a mobile app that will get realtime notifications depending on the air quality level. The functionality of this feature includes sounding an alert to the users, when pollutant levels exceed the safety thresholds.

The Air Pollution Detectors also show us various applications and benefits.

Personal Air Quality Monitoring: If elderly or children susceptible to pollution live with you, then keep track of air quality at home.

Industrial Monitoring: Air quality devises must be used to measure air quality in industrial areas.

Environmental Research: The device is used to collect data for research projects in the areas of the environment.

On NodeMCU and Air Pollution Detection Conclusion

Summarily, the air pollution detector based on ESP8266 is an efficient and very inexpensive air quality monitors able to monitor it in real time. With the NodeMCU ESP8266 we have the necessary features and flexibility to craft a connected device to enable insights into air pollution levels. Now you know if someone asks “NodeMCU what is?” then it’s an IoT development board that makes practical and impactful solution using NodeMCU like Air Pollution Detector.

Following this guide can help you build a useful system to measure and monitor air quality around you enabling you to stay informed of your surrounding air quality and take precautionary measures to protect your health.

CODE :

//Provided by ElectroGlobal
#include <WiFiManager.h>
#include "FirebaseESP8266.h"
#include <ESP8266WiFi.h>

#define nameofdevice "Device 1"

FirebaseData firedb;
int status;

void setup()
{
  status = 1;
  pinMode(D2, OUTPUT);
  pinMode(A0, INPUT);
  WiFi.mode(WIFI_STA);
  Serial.begin(115200);
  WiFiManager wm;

  bool res;

  res = wm.autoConnect("Air Pollution Detector", "pollution");
  if (!res) {
    Serial.println("Failed to connect");
  }
  else {
    Serial.println("connected...yeey :)");
    Firebase.begin( "smart-9b2ba-default-rtdb.firebaseio.com", "0CgaJ1CmWwsiNqAymhQnLHgqwXEbwkDvL9zXuFG6");
    Serial.println("Firebase Connected");
  }

}

void loop()
{

  int value = analogRead(A0);
  Serial.println(value);

    if (status == 1)    {
        if (value > 700)
        {
          Firebase.setString(firedb, "/database/Device 1/Pollution Level", "Device1" );
          Firebase.setString(firedb, "/database/alerts", "Device1" );
          digitalWrite(D2,HIGH);
          status = 0;
        }
    }
else{
    if (value < 700 )
    {

        status = 1;
                  digitalWrite(D2,LOW);

     }
}
delay(1000);
Handling Persistent Data on Flash Memory using LittleFS with ESP8266
Voice Connection based Security system with ESP8266 and Arduino for IoT in Home Automation

Leave a Reply

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

WhatsApp
My Cart
Wishlist
Recently Viewed
Categories
Wait! before you leave…
Get 30% off for your first order
CODE30OFFCopy to clipboard
Use above code to get 30% off for your first order when checkout