Ire 212 Lab5

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

শিক্ষা শিয়ে গড়য় া দেি তথ্য-প্রযুক্তির াাংলায়েি

LAB REPORT: 05
COURSE NO.-IRE 212
IoT Architecture and Technologies
04-11-2024

SUBMITTED TO:
Suman Saha
Assistant Professor
Department of IRE, SUBMITTED BY:
BDU
Koushik Biswas
ID: 2101029
Department of IRE,
BDU
Session: 2021-2022
Page: 01

LAB INTRODUCTION

OBJECTIVE:
The primary objective of this project is to develop a low-cost, reliable air quality
monitoring device using Arduino that can measure and display air quality
indicators, including gas concentration, temperature, and humidity levels. This
device aims to make air quality data accessible and understandable to the general
public.

Software Tool:
 Arduino IDE

Hardware:

 Arduino Uno – Main microcontroller board for processing data.


 MQ135 Gas Sensor – Measures various gaseous pollutants and provides
analog readings based on air quality.
 DHT11 Temperature and Humidity Sensor – Reads temperature and
humidity of the environment.
 OLED Display (128x64) – Provides visual output of air quality data.
 Breadboard and Jumper Wires – For connecting components.

List of Programs:

 Arduino Air Quality Monitoring System


Page: 02

Problem NO: 01

Theory:
The Air Quality Monitoring System (AQMS) is an Arduino-based project designed to
assess environmental air quality and display key information such as temperature,
humidity, and pollution levels. This system provides real-time monitoring of air
quality, which is crucial for raising public awareness about pollution levels and
helping people make informed health decisions. The project uses the Air Quality
Index (AQI), a standardized metric that simplifies understanding of air quality and
its potential health impacts.

Interfacing Arduino uno with MQ135 Gas Sensor

To interface the Arduino Uno with the MQ135 gas sensor for the Air Quality
Monitoring System, follow these steps. The MQ135 sensor will allow the Arduino
to read and analyze the concentration of various gases in the air, which will be used
to assess the air quality.
Page: 03

Connection Diagram

The MQ135 gas sensor has four pins:

 VCC – Power supply input (connected to 5V)


 GND – Ground
 DO (Digital Output) – Not used in this setup
 AO (Analog Output) – Provides analog data based on the concentration of
gases in the air

Pin Connections:

1. Connect the VCC pin of the MQ135 to the 5V pin on the Arduino.
2. Connect the GND pin of the MQ135 to the GND pin on the Arduino.
3. Connect the AO pin of the MQ135 to the A0 analog input pin on the
Arduino.

Circuit Diagram
Page: 04

Interfacing Temperature Sensor With Arduino UNO

This experimental study's goal is to use the DHT22 sensor to measure and evaluate
the temperature and humidity in a given space. The purpose of the experiment is
to assess the DHT22 sensor's response time, accuracy, and dependability in
recording environmental conditions. This study also aims to show how DHT21
sensor data can be gathered, analyzed, and displayed for real-world uses like IoT
devices and climate control systems.

Humidity Sensing: The DHT22 uses a capacitive sensor element that detects
moisture by measuring changes in capacitance. This data is then converted to a
humidity percentage.
• Temperature Sensing: The DHT22 uses a thermistor to measure temperature. The
thermistor's resistance varies with temperature, which is converted into a
temperature reading.

Key Features of DHT22


• Humidity Range: 0% to 100% RH with ±2% accuracy.
• Temperature Range: -40°C to 80°C (-40°F to 176°F) with ±0.5°C accuracy.
• Operating Voltage: 3.3V to 5.5V, making it compatible with most microcontrollers.
• Response Time: Typically, 2 seconds.

Refer the circuit diagram for better understanding:


Page: 05
Page: 06

Code in C++:
#include <SPI.h>
#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 4
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define sensor A0
#define DHT11PIN 2
#define DHTTYPE DHT11 // Specify the DHT sensor type

int gasLevel = 0;
String quality = "";
DHT dht(DHT11PIN, DHTTYPE); // Create an instance of DHT

void sendSensor() {
float h = dht.readHumidity();
float t = dht.readTemperature();

if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}

// Display on OLED
display.setTextColor(WHITE);
display.setTextSize(1);
display.setFont();
display.setCursor(0, 43);
display.println("Temp :");
display.setCursor(80, 43);
display.println(t);
display.setCursor(114, 43);
display.println("C");
display.setCursor(0, 56);
display.println("RH :");
display.setCursor(80, 56);
display.println(h);
display.setCursor(114, 56);
display.println("%");
Page: 07

// Print to Serial Monitor


Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(h);
Serial.println(" %");
}

void air_sensor() {
gasLevel = analogRead(sensor);

if (gasLevel < 151) {


quality = " GOOD!";
} else if (gasLevel > 151 && gasLevel < 200) {
quality = " Poor!";
} else if (gasLevel > 200 && gasLevel < 300) {
quality = "Very bad!";
} else if (gasLevel > 300 && gasLevel < 500) {
quality = "Toxic!";
} else {
quality = " Toxic";
}

// Display on OLED
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(1, 5);
display.setFont();
display.println("Air Quality:");
display.setTextSize(1);
display.setCursor(5, 23);
display.println(gasLevel);
display.setCursor(20, 23);
display.println(quality);

// Print to Serial Monitor


Serial.print("Gas Level: ");
Serial.println(gasLevel);
Serial.print("Air Quality: ");
Serial.println(quality);
}

void setup() {
Page: 08

Serial.begin(9600);
pinMode(sensor, INPUT);
dht.begin(); // Initialize the DHT sensor
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3c)) {
Serial.println(F("SSD1306 allocation failed"));
}
display.clearDisplay();
display.setTextColor(WHITE);

display.setTextSize(2);
display.setCursor(50, 0);
display.println("Air");
display.setTextSize(1);
display.setCursor(23, 20);
display.println("Quality monitor");
display.display();
delay(1200);
display.clearDisplay();

display.setTextSize(1.5);
display.setCursor(20, 20);
display.println("BY Circuit");
display.setCursor(20, 40);
display.println("Digest");
display.display();
delay(1000);
display.clearDisplay();
}

void loop() {
display.clearDisplay();
air_sensor();
sendSensor();
display.display();
delay(2000);
}
Page: 09

Output:

Conclusion:
The Arduino-based Air Quality Monitoring System is a practical and effective
solution for monitoring environmental conditions in real-time. By providing
accessible and understandable air quality data, it enables users to respond to adverse
air quality conditions, contributing to public health and environmental awareness.

You might also like