Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Based Air Quality Monitoring System with MQ135 Sensor and Alert Indicators

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Air Quality Monitoring System with MQ135 Sensor and Alert Indicators

Circuit Documentation

Summary

This circuit is designed to interface with an MQ135 gas sensor, a piezo buzzer, an LED, and an I2C LCD screen using an Arduino UNO microcontroller. The primary function of the circuit is to monitor air quality through the MQ135 sensor and provide visual and audible alerts when the gas concentration exceeds a predefined threshold. The LED serves as a status indicator that remains on at all times, while the buzzer sounds an alarm when the threshold is crossed. The LCD screen displays the sensor readings and provides a user interface for monitoring the sensor's output.

Component List

Arduino UNO

MQ135 Gas Sensor

Piezo Buzzer

LED: Two Pin (red)

Resistor

LCD screen 16x2 I2C

Wiring Details

Arduino UNO

MQ135 Gas Sensor

Piezo Buzzer

LED: Two Pin (red)

Resistor

LCD screen 16x2 I2C

Documented Code

/*
 * This Arduino sketch interfaces with an MQ135 gas sensor, a piezo buzzer,
 * an LED, and an I2C LCD screen. The code reads the analog value from the
 * MQ135 sensor every 10 seconds. If the sensor value exceeds a threshold
 * of 200, the LED will blink for 3 seconds, and the buzzer will sound for
 * half a second at a high frequency. The LED remains on at all other times.
 */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Pin definitions
const int mq135Pin = A0;
const int buzzerPin = 2;
const int ledPin = 3;

// Threshold value
const int threshold = 200;

// LCD setup
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  pinMode(mq135Pin, INPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH); // Keep LED on
  lcd.begin();
  lcd.backlight();
  lcd.print("MQ135 Sensor");
}

void loop() {
  int sensorValue = analogRead(mq135Pin);
  lcd.setCursor(0, 1);
  lcd.print("Value: ");
  lcd.print(sensorValue);
  delay(10000); // Wait for 10 seconds

  if (sensorValue > threshold) {
    // Blink LED for 3 seconds
    for (int i = 0; i < 6; i++) {
      digitalWrite(ledPin, LOW);
      delay(250);
      digitalWrite(ledPin, HIGH);
      delay(250);
    }
    // Buzz buzzer for half a second
    tone(buzzerPin, 2000); // High frequency tone
    delay(500);
    noTone(buzzerPin);
  }
}

This code is designed to be uploaded to the Arduino UNO microcontroller. It initializes the connected devices and continuously monitors the MQ135 sensor's analog output. When the gas concentration exceeds the threshold, it activates the LED and buzzer to alert the user. The LCD screen displays the current sensor value for real-time monitoring.