DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
                              Experiment 5
Student Name: Kartik singh                         UID:22BCS13392
Branch: BE-CSE                                     Section/Group: 22BCS_FL_IOT_602(A)
Semester: 5                                        Date of Performance: 22-08-24
Subject Name: IOT LAB                              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:
   The objective of this experiment is to use the MQ-135 sensor to detect and monitor the
   concentration of harmful gases in the air. By analyzing the sensor's analog output, the
   experiment aims to assess air quality and identify potential contamination.
   This helps in determining environmental safety and necessary precautions
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. Theory:
  About Air Quality Sensor:
  MQ-135 sensor belongs to the MQ series that are used to detect different gasses present in the
  air. The MQ-135 sensor is used to detect gases such as NH3, NOx, alcohol, Benzene, smoke,
  CO2 , etc. steel exoskeleton houses a sensing device within the gas sensor module.
  This sensor has 4 pins:
  • 5V: Module power supply – 5 V
  • GND: Ground
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
    • DOUT: Digital output
    • AOUT: Analog output
  5. Procedure:
    •   Connect MQ-135 VCC to Arduino 5V.
    •   Connect MQ-135 GND to Arduino GND.
    •   Connect MQ-135 AOUT to Arduino analog pin (e.g., A0).
    •   Connect MQ-135 DOUT to Arduino digital pin.
    •   Upload code to Arduino and monitor sensor data via Serial Monitor.
  6. Circuit diagram:
  7. Connections:
   o VCC to 5V: Connect the MQ-135 VCC pin to the Arduino 5V pin to power the
     sensor.
   o GND to GND: Connect the MQ-135 GND pin to the Arduino GND pin for a common
     ground.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
 o AO to A0: Connect the MQ-135 AO (Analog Output) pin to the Arduino analog
    pin A0 to read analog sensor values.
 o DO to Pin 2: Connect the MQ-135 DO (Digital Output) pin to Arduino digital pin 2 to
    use the digital output if needed.
 o Common Ground: Ensure that both the MQ-135 sensor and Arduino share a
   common ground connection.
  8. CODE:
    int sensorValue;
    int digitalValue;
    void setup()
    {
    Serial.begin(9600);
    pinMode(13, OUTPUT);
    pinMode(2, INPUT);
    }
    void loop()
    {
    sensorValue = analogRead(0);
    digitalValue = digitalRead(2);
    if (sensorValue > 400)
    {
    digitalWrite(13, HIGH);
    }
    else
    {
    digitalWrite(13, LOW);
    }
    Serial.println(sensorValue, DEC);
    Serial.println(digitalValue, DEC);
    delay(5000); // wait 5000ms for next
    reading
    }
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
  9. RESULT:
  10. Conclusion:
  The MQ-135 air quality sensor is a versatile device used for detecting a range of gases in the
  environment, including ammonia (NH3), nitrogen oxides (NOx), alcohol, benzene, smoke,
  and carbon dioxide (CO2). The sensor provides an analog output that corresponds to the
  concentration of these gases in the air. This output can be read by a microcontroller, like an
  Arduino, to assess air quality.
  If the sensor readings stay within the normal range, the air quality can be considered safe.
  However, if the readings rise significantly, it suggests the presence of potentially harmful
  substances, and appropriate actions should be taken to ensure safety. This makes the MQ-
  135sensor a useful tool for monitoring air quality in various settings.