100% found this document useful (1 vote)
205 views16 pages

Air Quality Monitoring System Using NodeMCU With I

This document describes how to build an air quality monitoring system using NodeMCU with IoT. It connects DHT22 and MQ135 sensors to NodeMCU to measure temperature, humidity, and air quality. The sensor data is sent to a web server via WiFi and displayed on an LCD screen. The system provides real-time air quality monitoring and alerts users to pollution levels through a mobile app.

Uploaded by

m2005anojr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
205 views16 pages

Air Quality Monitoring System Using NodeMCU With I

This document describes how to build an air quality monitoring system using NodeMCU with IoT. It connects DHT22 and MQ135 sensors to NodeMCU to measure temperature, humidity, and air quality. The sensor data is sent to a web server via WiFi and displayed on an LCD screen. The system provides real-time air quality monitoring and alerts users to pollution levels through a mobile app.

Uploaded by

m2005anojr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

instructables

Air Quality Monitoring System Using NodeMCU With IoT

by Group_7_iot

IoT is the technology of the future that is impacting industrial growth in the most signi cant way possible. Any industry
that integrates cutting-edge Internet of Things features and improves their overall work ow, including the eet, supply
chain, chemical, oil and gas, and other sectors, bene ts hugely.
Real-time monitoring of the environment is made possible by IoT-based solutions when combined with environmental
assets. This, one of the main advantages of IoT integration with the environment, guarantees a more e ective strategy
for enhancing the environmental conditions.
The implementation of this device helps in solving this kind of problem by showing the results of air quality level not just
on LCD screen but also on a web server. Thus, an air quality monitoring system using IoT has been developed to share the
air quality level to the public continuously in order to be aware of the unhealthy environment.
Features:
E ective air quality monitoring
Temperature and humidity measurement
Built-in Wi-Fi connectivity
Suitable for indoor or outdoor area

In this tutorial we will learn how to use the DHT22 sensor for measuring temperature and humidity and MQ 135 air
quality sensor on Thinger.io using NodeMCU. In this program, the NodeMCU to read and store the data into a variable
and then upload it to Thinger.io using its channel name and API key.
Additionally, both the serial monitor and the LCD display will display the value output by the DHT sensor and air quality
sensor. The LCD display element is optional. You may print on a serial monitor using this instruction as well. Within
sensors, code and circuit diagram are compatible.
Supplies:

DHT22
LCD 1602A
MQ135
Jumper Wires

Air Quality Monitoring System Using NodeMCU With IoT: Page 1


Step 1: Components Required

Hardware Required:
1. DHT 22 (Humidity and Temperature Sensors)
2. MQ 135 (Air Quality Sensor)
3. NodeMCU
4. LCD 1602A (Optional)
5. Jumper Wires
6. Breadboard

DHT22 : The DHT22 is the more expensive version which obviously has better speci cations. Its temperature measuring
range is from -40 to +125 degrees Celsius with +-0.5 degrees accuracy.
MQ 135 : An air quality sensor for detecting a wide range of gases, including NH3, NOx, alcohol, benzene, smoke and
CO2. Ideal for use in o ce or factory. MQ135 gas sensor has high sensitivity to Ammonia, Sul de and Benzene steam.
NodeMCU Internet ESP8266 : The NodeMCU (Node MicroController Unit) is an open-source software and hardware
development environment built around an inexpensive System-on-a-Chip (SoC) called the ESP8266. The ESP8266,
designed and manufactured by Espressif Systems, contains the crucial elements of a computer: CPU, RAM, networking

Air Quality Monitoring System Using NodeMCU With IoT: Page 2


(WiFi), and even a modern operating system and SDK. That makes it an excellent choice for Internet of Things (IoT)
projects of all kinds.
LCD 1620A : A sort of dot matrix module used to display characters, numerals, and letters is called a character-type
liquid crystal display.
Jumper Wires : Jumper wires are wires with connector pins at either end that can be used to connect two places without
soldering.
Breadboard : A breadboard is a solderless instrument used to build temporary electrical prototypes and test circuit
designs. Most electronic components in electronic circuits can be linked together by inserting their leads or terminals
into the proper holes, and then, if necessary, making connections through wires.

Step 2: Connecting Components (DHT 22)

Although DHT 22 (temperature and humidity) sensors are quite sluggish and simple, they are perfect for hobbyists who
want to log some simple data. The capacitive humidity and temperature sensors are the two components that make up
the DHT sensors.
The DHT sensor have four pins, VCC, GND, data pin and a not connected pin which has no usage.
From left to right
VCC
Air Quality Monitoring System Using NodeMCU With IoT: Page 3
Signal
NC Not connected
GND

Air Quality Monitoring System Using NodeMCU With IoT: Page 4


Step 3: Connecting Components (LCD 1602A)

How to connect LCD Pin to ESP32 Pins:


The LCD has 16 pins :
PIN01-VSS to GND
PIN02-VDD to 5V
PIN03 V0 to 10K Pot (Middle pin)
PIN04 RS to GPIO19
PIN05 RW to GND
Air Quality Monitoring System Using NodeMCU With IoT: Page 5
PIN06 E to GPIO23
PIN07 D0 to NOT USED
PIN08 D1 to NOT USED
PIN09 D2 to NOT USED
PIN10 D3 to NOT USED
PIN11 D4 to GPIO18
PIN12 D5 to GPIO17
PIN13 D6 to GPIO16
PIN14 D7 to GPIO15
PIN15 A to 5V
PIN16 K to GND

Air Quality Monitoring System Using NodeMCU With IoT: Page 6


Air Quality Monitoring System Using NodeMCU With IoT: Page 7
Step 4: Connecting Components (MQ 135)

The VCC pin of the MQ135 Gas Sensor is connected to the 3.3 volts pin of the NodeMCU Module.
A0 pin of the NodeMCU Module is connected to AOUT pin.
The ground of the Gas Sensor is connected to the ground of the NodeMCU ESP8266 Wi Module.

Air Quality Monitoring System Using NodeMCU With IoT: Page 8


Step 5: Procedure With Platform Thinger.io

Step 1: Go to thinger.io and create your Thinger.io account if you don’t have. Login to Your Account.
Step 2: Device setup to de ne username, device id and device credential in Thinger.io account and project declaration in
Arduino IDE.
Step 3: Dashboard setup to add and set widgets in Thinger.io account. You may add as many widgets depending on your
project on Thinger.io platform.
Step 4: Open Arduino IDE to setup Thinger.io library .To do this go to Sketch>Include Library>Manage Libraries. Search
for thinger.io and install the latest in the library.
Step 5: Mobile application setup in Thinger.io, scan QR code generated from Device Token and the device to checked
our 'Air Status' can be view or control.

Air Quality Monitoring System Using NodeMCU With IoT: Page 9


Step 6: The Source Code in Arduino IDE

// Include Libraries
#de ne THINGER_SERIAL_DEBUG
Air Quality Monitoring System Using NodeMCU With IoT: Page 10
#include<LiquidCrystal.h>
#include<DHT.h>
#include<ThingerESP8266.h>
// Pin De nitions
#de ne sensor A0
#de ne DHTPIN 4
#de ne DHTTYPE DHT22
// MCU Internet Connection
#de ne USERNAME "AlishaNajwa"
#de ne DEVICE_ID "Group7"
#de ne DEVICE_CREDENTIAL "nodemcuGroup7_credentials"
#de ne SSID "UniSZA-WiFi"
#de ne SSID_PASSWORD "unisza2016"
ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
// De ne vars for testing menu
int gasLevel = 0;
String quality ="";
// Object initialization
DHT dht(DHTPIN, DHTTYPE);
const int RS = 5, EN = 2, d4 = 14, d5 = 12, d6 = 13, d7 = 15;
LiquidCrystal lcd(RS, EN, d4, d5, d6, d7);
void setup() {
thing.add_wi (SSID, SSID_PASSWORD);
thing["dht22"] >> [] (pson & out){
out["humidity"] = dht.readHumidity();
out["temperature"] = dht.readTemperature();
};
thing["Air_Quality"] >> outputValue(analogRead(A0));
pinMode(sensor,INPUT); dht.begin();
lcd.begin(16, 2); Serial.begin(115200);
}
void sendSensor(){
//Temperature and Humidity Sensors
// Reading humidity in %
oat h = dht.readHumidity();
// Read temperature in Celsius, for Fahrenheit use .readTempF()
oat t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity:");
Serial.println(h);
Serial.print("Temperature:");
Serial.println(t);
delay(2000);
Air Quality Monitoring System Using NodeMCU With IoT: Page 11
lcd.setCursor(0,2);
lcd.print("Temp:");
lcd.print(t);
lcd.setCursor(7,2);
lcd.print("Hum:");
lcd.print(h);
}
void air_sensor(){
//Air Quality Sensor
// Read data from serial monitor if received
gasLevel = analogRead(sensor);
if(gasLevel<181){
quality = "GOOD!";
thing["Status"] >> outputValue(quality);
}
else if (gasLevel >181 && gasLevel <225){
quality = "POOR!";
thing["Status"] >> outputValue(quality);
}
else if (gasLevel >225 && gasLevel <300){
quality = "BAD AIR!";
thing["Status"] >> outputValue(quality);
}
else if (gasLevel >300 && gasLevel <350){
quality = "WARNING!";
thing["Status"] >> outputValue(quality);
}
else{
quality = "TOXIC";
thing["Status"] >> outputValue(quality);
}
Serial.println(quality);
lcd.setCursor(0,1);
lcd.print("Air:");
lcd.print(quality);
}
// Main logic of your circuit
void loop() {
sendSensor();
air_sensor();
thing.handle();
}

Air Quality Monitoring System Using NodeMCU With IoT: Page 12


Air Quality Monitoring System Using NodeMCU With IoT: Page 13
Step 7: Output and Summary

As a conclusion, the Air Quality Monitoring System with IoT has achieved the objective that able to detect air quality and
pollution or harmful gases by using MQ135 gas sensor. It is also capable of spreading awareness of how important to
know the e ects of air quality that we breathe towards health and environment. The following objective which is to
Air Quality Monitoring System Using NodeMCU With IoT: Page 14
develop the monitoring system of air pollution for environmental sensing application using Internet of Things (IoT), has
also been ful lled. The entire system includes the hardware components such as the NodeMCU (ESP8266) , MQ135
sensor, DHT 22 sensor, and LCD. These features are designed in order to work hand-in-hand in order to provide an ideal
system for user. The last objective is to verify the function of the system in a di erent level of air quality level which also
been accomplished. Thus, this ensures that the system is capable of performing the required safety and monitoring
purposes using Thinger.io.
Hope this made it easier for you. Be sure to subscribe if you like this article and found it useful, and if you have any
questions or need help with anything, just leave a comment below. Thank you.

Video Reference of Project


https://youtu.be/Cz3bB28mES8

Air Quality Monitoring System Using NodeMCU With IoT: Page 15


Air Quality Monitoring System Using NodeMCU With IoT: Page 16

You might also like