Projects Hub, lesson 27 of 81
Gas Sensor-Based Air Freshener System with LCD Display
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:
- Gas sensor (MQ series, for example)
- Arduino board (e.g., Arduino Uno)
- LCD display (16x2 or 20x4)
- Relay module
- Air freshener dispenser (with an electric trigger)
- Breadboard and jumper wires
- Power supply (5V)
Circuit Diagram

Working of the System with Arduino
- 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.
- 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.
- 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.
- Air Freshener Dispenser: Attach the air freshener dispenser to the relay, allowing the Arduino to trigger it when needed.
- 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
#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.

