IOT-5 Aditya
IOT-5 Aditya
IOT-5 Aditya
Experiment 2.1
Student Name: Aditya Kumar Singh UID: 22BCS13550
Branch: BE-CSE Section/Group: IOT_615/B
Semester: 05 Date of Performance: 22/08/24
Subject Name: IOT Subject Code: 22CSP-329
1. Aim:
To Design a weather station by checking Air quality of an environment with the
help of IoT.
2. Objective:
1. Learn about interfacing.
2. Learn about IoT programming.
3. Hardware Required:
1. Arduino Uno R3
2. MQ 135 Air Quality Sensor Module
3. Male to Female Jumper Wire
4. Software: Arduino IDE
4. Procedure:
1|22BCS13550
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
• Connect the VCC (Power) pin of the MQ2 sensor to the 5V power
rail on the breadboard.
• Connect the GND (Ground) pin of the MQ2 sensor to the GND rail
on the breadboard.
• Connect the AO (Analog Output) pin of the MQ2 sensor to the A0
pin on the Arduino using a jumper wire.
3. Connect the LED:
• Insert the LED onto the breadboard, with the anode (longer leg)
connected to one row and the cathode (shorter leg) to another.
• Place a 220Ω resistor between the anode of the LED and digital
pin 13 on the Arduino using a jumper wire.
• Connect the cathode of the LED to the GND rail on the
breadboard.
4. Connect the Buzzer:
2|22BCS13550
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
6. Code:
int LED = 6;
int MQ2pin = A0;
int buzzerPin = 7;
void setup() {
Serial.begin(9600);
pinMode(LED, OUTPUT);
pinMode(buzzerPin, OUTPUT);
digitalWrite(LED, LOW);
digitalWrite(buzzerPin, LOW);
}
void loop() {
float sensorValue = analogRead(MQ2pin);
if (sensorValue >= 100) {
digitalWrite(LED, HIGH);
digitalWrite(buzzerPin, HIGH);
} else {
digitalWrite(LED, LOW);
digitalWrite(buzzerPin, LOW);
}
Serial.print("Sensor Value: ");
Serial.println(sensorValue);
delay(100);
}
7. Result and Output:
3|22BCS13550
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
8. Learning Outcomes:
4|22BCS13550