Projects Hub, lesson 27 of 81

Gas Sensor-Based Air Freshener System with LCD Display

intermediate3 min read

Introduction

Indoor air quality is a critical factor in maintaining a healthy and pleasant living environment. Unpleasant odors and harmful gases can affect our comfort and well-being. To address this issue, we can create an intelligent gas sensor-based air freshener system that automatically sprays air freshener when it detects undesirable gases. In this article, we'll explore the construction, working principle, and code implementation of such a system using an Arduino and an LCD display.

Working Principle

The gas sensor-based air freshener system relies on a gas sensor to detect specific gases in the air, such as volatile organic compounds (VOCs) or noxious odors. When the sensor detects a concentration of the target gas above a certain threshold, it triggers an air freshener dispenser to release a burst of fragrance into the room.

Things We Need

To build this system, you will require the following components:

  1. Gas sensor (MQ series, for example)
  2. Arduino board (e.g., Arduino Uno)
  3. LCD display (16x2 or 20x4)
  4. Relay module
  5. Air freshener dispenser (with an electric trigger)
  6. Breadboard and jumper wires
  7. Power supply (5V)

Circuit Diagram

Circuit Diagram

Working of the System with Arduino

  1. Gas Sensor Interface: Connect the gas sensor to the Arduino using analog or digital pins, depending on the sensor type. Ensure you provide the necessary power supply and ground connections.
  2. LCD Display: Connect the LCD display to the Arduino using the I2C interface for easy communication. This makes displaying sensor readings and system status more convenient.
  3. Relay Module: Connect the relay module to the Arduino to control the air freshener dispenser. Ensure that the relay can handle the dispenser's voltage and current requirements.
  4. Air Freshener Dispenser: Attach the air freshener dispenser to the relay, allowing the Arduino to trigger it when needed.
  5. Coding: Write the Arduino code to perform the following tasks:
    • Initialize the gas sensor and LCD display.
    • Continuously monitor the gas sensor's output for the presence of unwanted gases.
    • When the gas concentration exceeds a predefined threshold, trigger the relay to activate the air freshener dispenser.
    • Display relevant information, such as gas concentration and system status, on the LCD display.

Arduino Code Example

Loading the circuit…Arduino Uno
Press Run to upload the code to the Arduino.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
 
LiquidCrystal_I2C lcd(0x27, 16, 2);  // Initialize LCD with I2C address
 
int gasSensorPin = A0;
int relayPin = 8;
int gasThreshold = 500; // Adjust this value based on your sensor's sensitivity
 
void setup() {
  lcd.init();
  lcd.backlight();
  pinMode(gasSensorPin, INPUT);
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, LOW); // Ensure the relay is initially off
}
 
void loop() {
  int gasValue = analogRead(gasSensorPin);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Gas Concentration:");
  lcd.setCursor(0, 1);
  lcd.print(gasValue);
  
  if (gasValue > gasThreshold) {
    digitalWrite(relayPin, HIGH); // Activate the air freshener
    delay(2000); // Spray air freshener for 2 seconds
    digitalWrite(relayPin, LOW); // Turn off the air freshener
  }
  
  delay(1000); // Delay for a second before rechecking
}

Conclusion

The gas sensor-based air freshener system with an LCD display is an effective way to maintain a pleasant indoor environment. It detects unwanted gases and responds by dispensing air freshener, all while providing real-time feedback on the gas concentration. With this system, you can ensure that your living space remains fresh and comfortable, contributing to better air quality and overall well-being. You can customize and expand upon this project to suit your specific needs, such as adding multiple sensors or integrating it into a home automation system.