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

Arduino UNO Based Air Quality Monitor with DHT11 and MQ-135 Sensors

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Air Quality Monitor with DHT11 and MQ-135 Sensors

Circuit Documentation

Summary

This circuit is designed to monitor air quality by measuring temperature, humidity, and air composition. It utilizes an Arduino UNO as the central microcontroller to interface with a DHT11 temperature and humidity sensor (KY-015), an MQ-135 air quality sensor, and an I2C LCD 16x2 screen for displaying the measurements. The Arduino UNO reads the sensor data and outputs the information to both the LCD screen and the Serial Monitor for real-time monitoring.

Component List

Arduino UNO

KY-015 DHT11 Temperature and Humidity Sensor

MQ-135 Air Quality Sensor

I2C LCD 16x2 Screen

Wiring Details

Arduino UNO

KY-015 DHT11 Temperature and Humidity Sensor

MQ-135 Air Quality Sensor

I2C LCD 16x2 Screen

Documented Code

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

#define DHTPIN 2        // DHT11 data pin
#define DHTTYPE DHT11   // DHT 11
DHT dht(DHTPIN, DHTTYPE);

LiquidCrystal_I2C lcd(0x27, 16, 2); // Change address if necessary
const int MQ135_PIN = A0; // MQ135 analog pin

void setup() {
  Serial.begin(9600);
  dht.begin();
  lcd.begin();
  lcd.backlight();
  lcd.print("Air Quality Monitor");
  delay(2000);
  lcd.clear();
}

void loop() {
  // Read humidity and temperature
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // Temperature in Celsius

  // Read air quality from MQ135
  int airQuality = analogRead(MQ135_PIN);

  // Display data on LCD
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(t);
  lcd.print("C");

  lcd.setCursor(0, 1);
  lcd.print("Air Q: ");
  lcd.print(airQuality); // Raw value, consider calibrating it for real values

  // Print to Serial Monitor for debugging
  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print("%  Temperature: ");
  Serial.print(t);
  Serial.print("C  Air Quality: ");
  Serial.println(airQuality);

  delay(2000); // Update every 2 seconds
}

This code is responsible for initializing the sensors and the LCD screen, reading the sensor data, and displaying the information on the LCD as well as outputting it to the Serial Monitor. The DHT11 sensor is read using the DHT library, and the MQ-135 sensor's analog value is read directly from the analog pin. The I2C LCD screen is controlled using the LiquidCrystal_I2C library. The code includes a delay to update the readings every two seconds.