IOT-5 Aditya

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

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

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. Set Up the Breadboard and Arduino:

• Place the Arduino Uno on your workspace.


• Connect the GND (Ground) pin from the Arduino to the GND rail
on the breadboard using a jumper wire.
• Connect the 5V pin from the Arduino to the power rail on the
breadboard using another jumper wire.
2. Connect the MQ2 Gas Sensor:

• Insert the MQ2 gas sensor onto the breadboard.

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:

• Place the buzzer on the breadboard.


• Connect the positive (longer leg) of the buzzer to digital pin 12 on
the Arduino.
• Connect the negative (shorter leg) of the buzzer to the GND rail on
the breadboard.
5. Power and Test the Circuit:

• Once all connections are made, connect the Arduino to your


computer using a USB cable.
• Upload the provided code to the Arduino using the Arduino IDE.
• Observe the LED and buzzer operation based on the gas sensor
readings. If the sensor value exceeds the threshold, the LED will
light up and the buzzer will sound.

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:

1. Sensor Calibration and Detection


2. Buzzer and LED Interfacing
3. Analog Signal Reading
4. Threshold Value Setting
5. Serial Communication Debugging

4|22BCS13550

You might also like