0% found this document useful (0 votes)
15 views63 pages

Project 2

This document outlines a project focused on developing a low-cost gas concentration monitoring system using an Arduino Nano and the MQ-135 gas sensor to measure CO₂ and other harmful gases. The system features real-time data display on an OLED screen and compares readings with an infrared CO₂ sensor for accuracy. Additionally, the document includes a literature survey on existing air quality monitoring systems and discusses the advantages of the proposed system over traditional methods.

Uploaded by

balabasker
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views63 pages

Project 2

This document outlines a project focused on developing a low-cost gas concentration monitoring system using an Arduino Nano and the MQ-135 gas sensor to measure CO₂ and other harmful gases. The system features real-time data display on an OLED screen and compares readings with an infrared CO₂ sensor for accuracy. Additionally, the document includes a literature survey on existing air quality monitoring systems and discusses the advantages of the proposed system over traditional methods.

Uploaded by

balabasker
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CHAPTER 1

INTRODUCTION

1.1 INTRODUCTION

Connecting a battery in parallel is when you connect two or more batteries to


increase the amp-hour capacity, with a parallel battery connection the capacity
will increase, Rapid industrialization, urbanization, and the increasing use of
fossil fuels have led to a significant rise in atmospheric carbon dioxide (CO₂)
levels over the past few decades. CO₂ is one of the primary greenhouse gases
and plays a major role in global warming and climate change. According to
global observations, the average atmospheric CO₂ concentration has crossed
400 ppm and continues to increase steadily each year. Monitoring CO₂ levels
has therefore become crucial for environmental assessment, indoor air quality
monitoring, and public health awareness.
In addition to CO₂, the presence of harmful gases such as liquefied petroleum
gas (LPG), ammonia (NH₃), and smoke in the air poses serious risks to human
health and safety. Exposure to elevated concentrations of these gases can lead to
respiratory problems, reduced air quality, and hazardous living conditions,
especially in enclosed or industrial environments. Hence, the development of
low-cost and efficient gas monitoring systems is essential.
This project focuses on measuring the concentration of CO₂ and other gases
using an Arduino Nano and the MQ-135 gas sensor. The MQ-135 sensor is
capable of detecting multiple gases including CO₂, LPG, smoke, and ammonia,
making it suitable for air quality monitoring applications. The measured gas
concentration values are displayed in real time on a 0.96-inch OLED display for
easy visualization. Furthermore, the CO₂ readings obtained from the MQ-135
sensor are compared with readings from an infrared (IR) CO₂ sensor to evaluate
accuracy and reliability.

1
2
1.2 METHOD

The methodology of this project involves designing and implementing a gas


concentration measurement system using an Arduino Nano and an MQ-135 gas
sensor. The system is developed to detect and measure the concentration of carbon
dioxide (CO₂) along with other gases such as LPG, smoke, and ammonia present in
the surrounding air. The overall method is divided into hardware setup, sensor
calibration, data acquisition, display, and comparison analysis.

Initially, the required hardware components are assembled. The MQ-135 gas
sensor is interfaced with the Arduino Nano using appropriate jumper wires. A 22 kΩ
load resistor is connected to the sensor to ensure proper voltage division and stable
sensor output. The 0.96-inch OLED display module is connected to the Arduino using
the SPI communication protocol to display real-time gas concentration values.

Before measurement, the MQ-135 sensor is preheated to stabilize its sensing


element, as gas sensors require a warm-up period for accurate readings. The sensor
output voltage varies according to the concentration of gases present in the air. This
analog voltage is read by the Arduino’s analog input pin and converted into a digital
value using the built-in analog-to-digital converter (ADC).

The Arduino processes the sensor data using predefined calibration constants to
estimate gas concentration values in parts per million (ppm). Separate mathematical
models and sensitivity curves are used to calculate the concentrations of CO₂, LPG,
smoke, and ammonia. The processed values are then displayed on the OLED screen in
real time.

To validate the accuracy of the MQ-135 sensor, the measured CO₂ concentration
values are compared with readings obtained from an infrared (IR) CO₂ sensor under
the same environmental conditions. The comparison helps in analyzing the
performance, accuracy, and limitations of the MQ-135 sensor for CO₂ measurement.
3
1.3 BLOCK DIAGRAM

Fig 1.3 Block Diagram

4
CHAPTER 2

LITEATURE SURVEY

2.1 Air Quality and Carbon Monoxide Monitoring Using IoT-based System

Authors: Muhammad Kamran, Humayun Salahuddin, Ismail Kashif, Umair


Bashir, Afraz Danish, Attique Ur Rehman.
Abstract: This study proposes an IoT-based air quality monitoring system that
measures temperature, humidity, CO₂, and CO levels using a NodeMCU
ESP32 microcontroller combined with DHT-11 and MQ-135 sensors. Sensor
data is collected and processed in real time, with alerts generated when gas
concentrations exceed predefined thresholds. Additionally, the system can
automate environmental actions such as opening windows and doors. The
implementation demonstrates a low-cost and effective mechanism for indoor
and outdoor air quality monitoring.

2.2 Air Quality Monitoring Using MQ135 Gas Sensor and Arduino Uno
Authors: Manoj Kumar, Garvit Mishra, Ayush Sharma, Ashish Shaini, Sahil
Saxena
Abstract: This paper presents an Arduino Uno-based air quality monitoring
device using the MQ-135 gas sensor to detect pollutants including CO₂, NH₃,
benzene, and smoke. Sensor outputs are calibrated and converted into ppm
levels to assess air quality. Real-time readings are displayed on an LCD and
alerts are triggered when pollutant thresholds are exceeded. The authors discuss
system performance, practical limitations, and potential improvements such as
future IoT integration and advanced data analytics.

5
2.3 Air Quality Monitoring System Based on Internet of Things:
Authors: Muhammad Ghozi Arkhan, Zulhipni Reno Saputra Elsi

Abstract: This research develops an IoT-enabled air quality monitoring system


utilizing the ESP8266 Wi-Fi module with DHT11 and MQ-135 sensors to track
temperature, humidity, and harmful gas concentrations, including CO₂ and
ammonia. Sensor data is transmitted to a smartphone application via the Blynk
platform for real-time remote monitoring. The prototype follows a structured
prototype model with planning, hardware design, and validation stages,
demonstrating an effective IoT approach for environmental tracking.

2.4 Smart Air Monitoring with IoT-based Multiple Gas Sensors using NodeMCU
ESP32:
Authors: (Publication in Procedia Computer Science, 2024)

Abstract: This work integrates multiple gas sensors (MQ-2, MQ-7, MQ-8,
MQ-135) with a NodeMCU ESP32 microcontroller to develop a smart air
quality monitoring system where collected data is transmitted to a cloud
platform for analysis and visualization. The project demonstrates the capability
of low-cost IoT sensors to provide continuous monitoring of CO₂, CO,
hydrogen gases, and environmental parameters like temperature and humidity.
Experimental results reveal effective detection and data communication for
practical air.

6
CHAPTER 3

SYSTEM ANALYSIS

3.1 EXISTING SYSTEM


Traditional air quality and gas monitoring systems mainly rely on manual
inspection or expensive industrial-grade sensors. In many cases, CO₂
concentration and other harmful gases are monitored using standalone infrared
(IR) gas analyzers or laboratory-based equipment. These systems provide
accurate measurements but are costly, bulky, and require skilled personnel to
operate. In residential and small-scale environments, gas detection is often
limited to basic alarms that only indicate the presence of gas leakage without
providing quantitative concentration values.

Some existing low-cost systems use single-gas detectors that are not capable of
monitoring multiple gases simultaneously. Additionally, most conventional
systems do not offer real-time data visualization or comparative analysis for
validation of sensor readings. a parallel connection, you connect all the
positive terminals together and all the negative terminals together.

Disadvantages of Existing System

 High cost of infrared and industrial-grade gas sensors

 Bulky and non-portable equipment

 Requires skilled operators and regular maintenance

 Limited to detecting only one type of gas

 No real-time concentration display in ppm

 Lack of comparative analysis and data validation

 Not suitable for continuous monitoring in low-budget applications

7
3.2 PROPOSED SYSTEM

The proposed system introduces a low-cost, Arduino-based gas concentration


monitoring solution using the MQ-135 gas sensor. The system is designed to
measure CO₂ concentration along with LPG, smoke, and ammonia gases
present in the air. An Arduino Nano processes the sensor output and displays
real-time gas concentration values on a 0.96-inch OLED display.
To improve reliability, the CO₂ readings obtained from the MQ-135 sensor are
compared with those from an infrared CO₂ sensor under the same
environmental conditions. This comparative approach helps evaluate the
performance and limitations of the MQ-135 sensor. The system is compact,
portable, and suitable for continuous indoor air quality monitoring.
Advantages of Proposed System
 Low-cost and easily available components
 Compact and portable design
 Ability to detect multiple gases using a single sensor
 Real-time display of gas concentration values
 Easy implementation using Arduino platform
 Suitable for residential, educational, and small industrial applications
 Enables comparative analysis with IR CO₂ sensor for validation
 Expandable for IoT integration and data logging

8
CHAPTER - 4

SYSTEM ARCHITECTURE

4.1 HARDWARE REQUIREMENTS

 Arduino Nano

 MQ-135 Sensor

 0.96’ SPI OLED Display Module

 Buzzer

 Multi Output Power Module

 Jumper Wires

 Adapter

4.2 SOFTWARE REQUIREMENTS

 Embedded C

 Arduino IDE

9
CHAPTER 5

SOFTWARE ANALYSIS

5.1 EMBEDDED C
Embedded C is a programming language that is used in the development of
Embedded Systems. Embedded Systems are specialized systems designed to
perform very specific functions or tasks. Embedded System is the combination
of hardware and software, and the software is generally known as firmware
which is embedded into the system hardware.

Embedded C is used to program a wide range of microcontrollers and


microprocessors. Embedded C requires less number of resources to execute in
comparison with high-level languages such as Python or Java. However, it is
still easier to work with than assembly language, which is a lower-level
programming language that interacts more directly with the hardware.

 Embedded C has some additional data types and keywords. There are some
special datatypes in Embedded C like sbit, sfr which are used for addressing
special function registers in memory.

 Embedded C allows us to work with hardware devices like sensors, and


input-output devices.

 There are various Embedded C compilers to compile the embedded C


program such as Keil Compiler, SPJ Compiler, Embedded GNU C Compiler,
etc.

 Embedded Systems can be classified into small-scale, medium-scale, and


sophisticated embedded systems.

 The devices like air conditioners, printers, and mobile phones that we use in
our daily lives are programmed by embedded C.

10
5.1.1. INTRODUCTION OF ARDUINO C

The Arduino C programming language is based on the standard C and


C++ programming languages and is specifically designed for programming
microcontrollers. Arduino uses a variant of the C++ programming language.
It provides a simple, flexible, and user-friendly environment that allows
developers to write, compile, and upload programs to Arduino-based
microcontroller boards. The Arduino Integrated Development Environment
(Arduino IDE) serves as the primary platform for writing and uploading C-
based programs to microcontrollers such as ATmega328P (used in Arduino
Uno) and ESP32-CAM (used in this project).
Arduino C offers a structured programming approach with high efficiency,
modularity, and portability, making it a popular choice for embedded systems
and IoT applications. It provides built-in functions, pre-defined libraries, and
a simplified syntax, which reduces development time and makes it easy for
beginners and professionals to work on microcontroller-based projects.

Key Characteristics of Embedded C

 Efficiency: In Embedded C we can create an efficient code to optimize the


limited resources available in embedded systems. It aims to minimize memory
usage and maximize performance.
 Direct Hardware Interaction: Embedded C allows programmers to
interact directly with hardware components, such as microcontrollers, sensors,
actuators, and other peripherals. This direct interaction facilitates precise
control over the hardware, critical in embedded applications.
 Low-level Programming: Embedded C involves low-level programming,
which deals with hardware-specific details like memory addresses, I/O ports,
and register manipulation. This level of control is essential for efficiently
11
managing hardware resources.
 Real-time Operations: Embedded systems often operate in real-time
environments, requiring precise timing and response to events. Embedded C
allows programmers to handle real-time tasks efficiently.

Structure of Embedded C Program


 Comments: Comments are readable text written to help user understand
the code easily. They are ignored by compiler and do not take up any memory
in the final code. There are two types of comments, Single line comments and
Multiline comments.
 Preprocessor Directive: In Embedded C Preprocessor Directives are
represented using #include or #define. Preprocessor Directives are used to
indicate a header file specific to a microprocessor or microcontroller which
contains all the functions, SFR's and the bits in those SFR's. reg51 header file
is used in case of 8051 microcontroller.
 Global Variables: Global variables as the name suggests are global to
program that is they can be accessed anywhere in the program. Global
variables are static variables and are placed in RAM memory locations.
 Local Variables: Local variables in contrast to global variables are
confined to their respective functions. Normally these variables are placed in
stack or registers. It is only valid within the function in which it is declared.
 Function: Function is a group of statements that together performs a task.
A function declaration tells the compiler about the name, return type and
parameter of the function. A function definition provides actual body of the
function.
 Main Function: Every Embedded C program has one main function and
may contain one or more functions in the main functions. The program
execution starts from the main function, and it is a core of every execution. If
more than one main function is written in the code, then compiler will confuse

12
from where to start the program execution.
5.1.2 INTERFACING C PROGRAMS WITH ARDUINO IDE

To program an Arduino or ESP32-CAM, the Arduino Integrated


Development Environment (IDE) is used. It includes a text editor for writing
code, a message area, and a console for displaying output messages. The IDE
compiles the C-based source code and uploads it to the microcontroller.

Features of Arduino C Programming:


 Simple syntax, similar to traditional C and C++.
 Predefined libraries (e.g., Arduino.h, Wire.h, SPI.h, Servo.h, and
EEPROM.h).
 Supports hardware interfacing with sensors, actuators, and
communication modules (WiFi, Bluetooth, Serial, etc.).
 Compatible with various microcontroller families such as Atmega328P,
ESP32, ARM Cortex-M, and more.

5.1.3 FUNCTIONS OF ARDUINO C

 Digital & Analog I/O Control – Functions like digitalRead(),


digitalWrite(), analogRead(), and analogWrite() for interfacing with
sensors and actuators.
 Serial Communication – Uses [Link](), [Link](), and
[Link]() to send and receive data from external devices.
 Timers and Interrupts – Supports timer functions (millis(), delay()) and
external/internal interrupts.
 PWM (Pulse Width Modulation) Support – Enables simulation of
analog signals using digital pins.
 I2C and SPI Communication – Built-in functions for interfacing with
external devices like sensors and displays.

13
 EEPROM Support – Provides non-volatile memory for data storage.
 Low-Power Mode Support – Optimized for embedded applications with
power-efficient features.

5.1.4 DIFFERENCES FROM STANDARD ANSI C


While Arduino C is based on ANSI C, it has several differences to adapt it for
embedded development:
1. Predefined Functions:
o Arduino C provides built-in functions such as digitalWrite(),
digitalRead(), and delay(), which are not part of standard C.
2. No main() Function:
o Instead of the traditional main() function in ANSI C, Arduino uses two
main functions:
 void setup(): Runs once at startup.
 void loop(): Continuously executes after setup() is done.
3. Memory Allocation Differences:
o In standard C, dynamic memory allocation is done using malloc() and
free(). However, in embedded systems, excessive memory allocation can
lead to system crashes. Arduino C provides a more optimized memory
management strategy for microcontrollers.
4. Data Types and Registers:
o Some standard C data types like double are limited in precision on
microcontrollers due to memory constraints.
o Direct register manipulation is supported for microcontroller-specific
functionalities, unlike standard C.

14
5.2 ARDUINO IDE

The Arduino Integrated Development Environment (IDE) is an open-source


software application used for writing, compiling, and uploading code to
Arduino and other microcontroller-based development boards. It provides a
user-friendly interface with built-in libraries and tools that simplify embedded
programming. The software supports the C and C++ programming languages
and is widely used in IoT, robotics, and embedded systems development. The
new major release of the Arduino IDE is faster and even more powerful! In
addition to a more modern editor and a more responsive interface it features
autocompletion, code navigation, and even a live debugger.

✔ Cross-Platform Compatibility: Works on Windows, macOS, and Linux.


✔ Simple and Easy-to-Use Interface: Designed for beginners and advanced
users.
✔ Built-in Code Editor: Syntax highlighting, auto-indentation, and code
suggestions.
✔ Pre-installed Libraries: Includes libraries for communication protocols,
sensors, motors, and display control.
✔ Pre-Configured for Arduino Boards: Supports multiple Arduino-compatible
boards (ATmega328P, ESP32, ESP8266, etc.).
✔ One-Click Compilation & Uploading: Easily compiles code and uploads it
to the connected microcontroller.
✔ Serial Monitor: Displays real-time data received from the microcontroller
via UART communication.
✔ Board Manager & Library Manager: Allows easy installation of additional
board definitions and third-party libraries.
✔ Open-Source and Extensible: Programmers can modify the core libraries or
develop custom libraries for new hardware components.

15
5.2.1 INSTALLING ARDUINO IDE

The Arduino IDE 2 is an open-source project. It is a big step from its sturdy
predecessor, Arduino IDE 1.x, and comes with revamped UI, improved board
& library manager, debugger, autocomplete feature and much more.
To run Arduino IDE, go to the following website to download and install the
latest version:

Fig.5.1 Arduino IDE download page

 Download the latest release (The download will start after you click this
link. Check your browser’s download manager or the Downloads folder on your
computer to find the downloaded file)
 Double-click the executable (.exe) file.
 Follow the instructions in the installation guide.
 When completing the setup, leave Run Arduino IDE ticked to launch the
application, or launch it later from the Start Menu.

16
Fig.5.2 Installation steps

Fig.5.3 Installation done

17
CHAPTER 6

HARDWARE ANALYSIS

6.1 ARDUINO NANO


The Arduino Nano is Arduino's classic breadboard friendly designed
board with the smallest dimensions. The Arduino Nano comes with pin headers
that allow for an easy attachment onto a breadboard and features a Mini-B
USB connector.
The classic Nano is the oldest member of the Arduino Nano family
boards. It is similar to the Arduino Duemilanove but made for the use of a
breadboard and has no dedicated power jack. Successors of the classic Nano
are for example the Nano 33 IoT featuring a WiFi module or the Nano 33 BLE
Sense featuring Bluetooth® Low Energy and several environment sensors.
Taking this pin-out diagram below as reference, we shall discuss all the
functionalities of each and every pin.

Fig.6.1.1 Arduino Nano

18
The Arduino Nano may be small in size, but don’t let that fool you—it
packs nearly all the functionality of the larger Arduino Uno into a
compact, breadboard-friendly package. This makes it perfect for
projects where space is tight but capability still matters.
To harness the full power of the Nano, you’ll need to understand its pinout. In
this guide, we’ll walk you through the different types of pins on the
Arduino Nano so you can make the most of this compact board.

6.1.1 SPECIFICATIONS
Table.6.1 Specifications
Arduino Nano Specifications
Microcontroller ATmega328P
Architecture AVR
Operating Voltage 5 Volts
Flash Memory 32 KB of which 2 KB used
by Bootloader
SRAM 2KB
Clock Speed 16 MHz
Analog I/O Pins 8
EEPROM 1 KB
DC Current per I/O 40 milliAmps
Pins
Input Voltage (7-12) Volts
Digital I/O Pins 22
PWM Output 6
Power 19 milliAmps
Consumption

6.1.2 PIN DESCRIPTION

19
Fig.6.1.2 Arduino Nano Pin description

Digital Pins
Arduino Nano has 14 digital I/O pins that can be used either as digital
input or output. The pins work with 5V voltage as maximum, i.e., digital high is
5V and digital low is 0V. Each pin can provide or receive a current of 40mA,
and has a pull-up resistance of about 20-50k ohms. Each of the 14 digital pins
on the Nano pinout can be used as an input or output, using pinMode(),
digitalWrite(), and digitalRead() functions.
Other than the digital input and output functions, the digital pins have some
additional functionality as well.

Serial Communication Pins


These two pins (1,2) RX- receive and TX- transmit are used for TTL serial
data communication. The pins RX and TX are connected to the corresponding
20
pins of the USB-to-TTL Serial chip.

PWM Pins
Each of these digital pins provide a Pulse Width Modulation signal of 8-
bit resolution. The PWM signal can be generated using analogWrite () function.

External Interrupts
When we need to provide an external interrupt to other processor or
controller we can make use of these pins. These pins can be used to enable
interrupts INT0 and INT1 respectively by using the attachInterrupt () function.
These pins can be used to trigger three types of interrupts such as interrupt on a
low value, a rising or falling edge interrupt and a change in value interrupt.

SPI Pins
When you want the data to be transmitted asynchronously you can use
these Serial Peripheral Interface pins. These pins support synchronous
communication with SCK as the synchronizing clock. Even though the
hardware has this feature, the Arduino software doesn’t have this by default.
So you have to include a library called SPI Library for using this feature.

LED
If you remember your first Arduino code, blinking LED, then you’ll
definitely came across this Pin16. The pin 16 is being connected to the blinking
LED on the board.

Arduino Nano Analog Pins


As mentioned earlier UNO got 6 analog input pins but Arduino Nano has
8 analog inputs (19 to 26), marked A0 through A7. This means you can connect
*8 channel analog sensor inputs for processing. Each of these analog pins has a

21
inbuilt ADC of resolution of 1024 bits (so it will give 1024 values). By default,
the pins are measured from ground to 5V. If you want the reference voltage to
be 0V to 3.3V, we can give 3.3V to AREF pin (18 th Pin) by using the
analogReference () function.

I2C
Since SPI communication also has its disadvantages such as 4 essential
pins and limited within a device. For long distance communication we use the
I2C protocol. I2C supports multi master and multi slave with only two wires.
One for clock (SCL) and another for data (SDA). For using this I2C feature we
need to import a library called Wire library.

AREF
As mentioned already the AREF- Analog Reference pin is used as a
reference voltage for analog input for the ADC conversion.

Reset
Reset pins in Arduino are active LOW pins which means if we make this
pin value as LOW i.e., 0v, it will reset the controller. Usually used to be
connected with switches to use as reset button.

Arduino Nano ICSP


ICSP stands for In Circuit Serial Programming, which represents one of
the several methods available for programming Arduino boards. Ordinarily, an
Arduino bootloader program is used to program an Arduino board, but if the
bootloader is missing or damaged, ICSP can be used instead. ICSP can be used
to restore a missing or damaged bootloader.
Each ICSP pin usually is cross-connected to another Arduino pin with the same
name or function. For example, MISO on Nano’s ICSP header is connected to

22
MISO / digital pin 12 (Pin 15); MOSI on the ISCP header is connected to MOSI
/ digital pin 11 (Pin 16); and so forth. Note, MISO, MOSI, and SCK pins taken
together make up most of an SPI interface.
The Arduino Nano is a compact, breadboard-friendly microcontroller board
based on the ATmega328P (or sometimes ATmega168). It’s part of the Arduino
family and is ideal for small-scale projects where space is limited.
The Arduino Nano is a small, breadboard-friendly microcontroller used
for compact DIY electronics, robotics, automation, and IoT projects, leveraging
its small size for embedded systems, wearables, and sensor-based applications
like home automation (smart lighting, monitors), custom game controllers,
RFID locks, and even medical instruments, functioning as the brain to read
sensors and control outputs like LEDs and motors.
The Arduino Uno supports a total of 14 digital I/O pins and 6 analog inputs.
The Nano has 14 digital I/O pins as well but only 8 analog inputs.
Therefore, the Uno is better for projects needing more analog input capability.

6.2 MQ-135 SENSOR (AIR QUALITY SENSOR)


A device that is used to detect or measure or monitor the gases like
ammonia, benzene, sulfur, carbon dioxide, smoke, and other harmful gases are
called as an air quality gas sensor. The MQ135 air quality sensor, which
belongs to the series of MQ gas sensors, is widely used to detect harmful gases,
and smoke in the fresh air. This article gives a brief description of how to
measure and detect gases by using an MQ135 air quality sensor.
MQ135 air quality sensor is one type of MQ gas sensor used to detect,
measure, and monitor a wide range of gases present in air like ammonia,
alcohol, benzene, smoke, carbon dioxide, etc. It operates at a 5V supply with
150mA consumption. Preheating of 20 seconds is required before the
operation, to obtain the accurate output.

23
Fig. 6.2.1 MQ135 Air Quality Sensor

It is a semiconductor air quality check sensor suitable for monitoring


applications of air quality. It is highly sensitive to NH3, Nox, CO2, benzene,
smoke, and other dangerous gases in the atmosphere. It is available at a low
cost for harmful gas detection and monitoring applications.
If the concentration of gases exceeds the threshold limit in the air, then the
digital output pin goes high. The threshold value can be varied by using the
potentiometer of the sensor. The analog output voltage is obtained from the
analog pin of the sensor, which gives the approximate value of the gas level
present in the air.

6.2.1 PIN CONFIGURATION


The MQ135 air quality sensor is a 4-pin sensor module that features both
analog and digital output from the corresponding pins. The MQ135 air quality
sensor pin configuration is shown below.

For MQ135 Air Quality Sensor Module:


The MQ135 air quality sensor module is shown below.

24
Fig.6.2.2 Pin Configuration

Pin 1: VCC: This pin refers to a positive power supply of 5V that power up the
MQ135 sensor module.

Pin 2: GND (Ground): This is a reference potential pin, which connects the
MQ135 sensor module to the ground.
Pin 3: Digital Out (Do): This pin refers to the digital output pin that gives the
digital output by adjusting the threshold value with the help of a potentiometer.
This pin is used to detect and measure any one particular gas and makes the
MQ135 sensor work without a microcontroller.

25
Pin 4: Analog Out (Ao): This pin generates the analog output signal of 0V to
5V and it depends on the gas intensity. This analog output signal is
proportional to the gas vapor concentration, which is measured by the MQ135
sensor module. This pin is used to measure the gases in PPM. It is driven by
TTL logic, operates with 5V, and is mostly interfaced with microcontrollers.

Fig.6.2.3 Air Quality Sensor


H-pins: There are 2 H-pins, where one is connected to the voltage supply and
the other is connected to the ground.
A-pins: Here A-pins and B-pins can be interchanged. These are connected to
the voltage supply.
B-pins: Here A-pins and B-pins can be interchanged. One pin is used to
generate output while the other pin is connected to the ground.

6.2.2 SPECIFICATION AND FEATURES

 It has a wide detection scope.


 High sensitivity and faster response.
 Long life and stability.
 The operating voltage: +5V.
 Measures and detects NH3, alcohol, Nox, Benzene, CO2, smoke etc.
26
 Range of analog output voltage: 0V-5V.
 Range of digital output voltage: 0V-5V (TTL logic).
 Duration of preheating: 20 seconds.
 Used as an analog or digital sensor.
 The potentiometer is used to vary the sensitivity of the digital pin.
 Heating Voltage: 5V±0.1.
 Load resistance is adjustable.
 Heater resistance: 33ohms±5%.
 Heating consumption:<800mW.
 Operating temperature: -10°C to -45°C.
 Storage temperature: -20°C to -70°C.
 Related humidity: <95%Rh.
 Oxygen concentration: 21% (affects the sensitivity).
 Sensing resistance: 30kiloohms to 200kiloohms.
 Concentration slope rate: ≤0.65.
 Preheat time: over 24 hrs.
 Simple drive circuit.

6.2.3 HOW IT DECTECT AND MESURES GAS

To measure or detect the gases, use analog pins or digital pins. Just apply
5V to the module and you can observe that the module’s power LED turns ON
(glows) and the output LED turns OFF when no gas is detected by the module.
This means that the output of the digital pin is 0V. Note that the sensor must be
kept for preheating time for 20seconds (as mentioned in the specifications)
before the actual operation.

Now, once when the MQ135 sensor is operated to detect, then the LED
output goes high along with the digital output pin. Otherwise, use the

27
potentiometer until the output increases. Whenever the sensor detects a certain
gas concentration, the digital pin goes high (5V), otherwise it stays low (0V).

We can also use analog pins to get the same result. The output analog
values (0-5V) are read from the microcontroller. This value is directly
proportional to the gas concentration detected by the sensor. By the
experimental values, we can observe the working and reaction of the MQ135
sensor with different gas concentrations and the programming developed
accordingly.

6.2.4 HOW TO MEASURE PPM

The MQ-135 gas sensor uses SnO2, a gas-sensitive material that has
higher resistance in clean air. An increase in the number of harmful gases
decreases the resistance of the gas MQ135 sensor. To measure PPM with the
MQ-135 air quality sensor, observe the graph between (Rs/Ro) and PPM
shown below.

28
Fig.6.2.4 MQ135 PPM Graph

 The typical sensitivity characteristics of the MQ135 sensor are shown in the
above graph.
 Temperature is 20°C, humidity is 65%, the concentration of O2 is 21% and
load resistance RL is 20kilo ohms.
 Here Ro refers to the resistance value of the sensor at 100ppm of NH3 in
clean air or fresh air.
 Rs refers to the resistance of the sensor at several gas concentrations.
 We can calibrate the MQ135 sensor by determining the Rs value from the
below formula,
 Resistance of sensor Rs = (Vc/VRL-1)RL
 After calculating the Ro and Rs values, the ratio is found, and using the
above graph we can calculate the PPM value of the particular gas, which is
to be measured.

6.2.5 HOW TO INTERFACE SENSOR

The circuit diagram of interfacing the MQ135 air quality sensor with
Arduino is shown below. The components required are,

29
Fig.6.2.5 MQ135 Interface with Arduino

 MQ135 air quality sensor


 Arduino UNO
 The power supply of 5V
 Connecting wires.

Connections are made as per the circuit diagram shown above. The MQ135
sensor’s VCC pin is connected to the Arduino’s 5V pin. This power ups the
MQ135 sensor. The analog output pin Ao and digital output pin Do of the
MQ135 sensor are connected to the Ao and pin 2 of the Arduino. Finally, the
ground pins of the MQ135 and the Arduino are connected to a common
ground. This interfacing circuit gives both digital and analog outputs of the
MQ135 air quality sensor.

When the Ao (analog output) of the MQ135 is higher than the 400, then the
30
LED turns ON, which is connected to pin 2 of the Arduino board. Else the
LED turns OFF. Observe the readings of both digital and analog outputs of the
sensor on the LCD or monitor.
Upload the Arduino code as shown below for gas detection.

Int sensorValue; (int variable to read analogue output reading)


int digitalValue; (int variable to read digital output reading)

void setup()
{
[Link](9600); // sets the serial port to 9600 (sets the serial
communication to 9600 baud rate)
pinMode(13, OUTPUT); (pin 13 is connected to the anode terminal of the
LED as an output)
pinMode(2, INPUT); (pin 2 of Arduino is connected to the Do pin of the
MQ135 as an input)
}

void loop()
{
sensorValue = analogRead(0); // read analogue input pin 0 (to read the
analogue input on Ao)
digitalValue = digitalRead(2); (to read and save the digital output on pin 2
of Arduino)
if (sensorValue > 400)
{
digitalWrite(13, HIGH); (if the analogue reading is greater than
400, then the LED turns ON)
}

31
else
digitalWrite(13, LOW); (if the analogue reading is less than 400,
the LED turns OFF)
[Link](sensorValue, DEC); // prints the value read
[Link](digitalValue, DEC);
delay(1000); // wait 100ms for the next reading (analogue and
digital output readings are displayed on the monitor)
}

6.3 OLED DISPLAY MODULE

The organic light-emitting diode (OLED) display that we’ll use in this
tutorial is the SSD1306 model: a monocolor, 0.96-inch display with 128×64
pixels as shown in the following figure.

Fig.6.3.1 OLED Display 0.96 inch

The OLED display doesn’t require backlight, which results in a very nice
contrast in dark environments. Additionally, its pixels consume energy only
when they are on, so the OLED display consumes less power when compared
with other displays.

The model we’re using here has only four pins and communicates with the
Arduino using I2C communication protocol. There are models that come with
an extra RESET pin. There are also other OLED displays that communicate

32
using SPI communication.

6.3.1 FEATURES

 OLED Driver IC: SSD1306


 Resolution: 128 x 64
 Visual Angle: >160°
 Input Voltage: 3.3V ~ 6V
 Compatible I/O Level: 3.3V, 5V
 Only Need 2 I/O Port to Control
 Pixel Color: Yellow (128x16 pixels)
 Blue (128x48 pixels)
 Full Compatible with Arduino
 Working temperature: -30°C ~ 70°C
 Factory configured for SPI protocol (can be easily changed to IIC)

6.3.2 PIN DISCRPTION


Because the OLED display uses I2C communication protocol, wiring is very
simple. You just need to connect to the Arduino Uno I2C pins as shown in the
table below.
Table.6.2 OLED pinout

Wiring to
Pin Arduino
Uno

Vin 5V

GND GND

SCL A5

33
SDA A4

If you’re using a different Arduino board, make sure you check the correct I2C
pins:
 Nano: SDA (A4); SCL (A5);
 MEGA: SDA (20); SCL (21);
 Leonardo: SDA (20); SCL (21);

Fig.6.3.2 Arduino with OLED

6.3.3 LIBRARY INSTALLATION

To control the OLED display you need the adafruit_SSD1306.h and


the adafruit_GFX.h libraries. Follow the next instructions to install those
libraries.

1. Open your Arduino IDE and go to Sketch > Include Library > Manage

34
Libraries. The Library Manager should open.
2. Type “SSD1306” in the search box and install the SSD1306 library
from Adafruit.

Fig.6.3.3 Install SSD1306 from Library Manager

3. After installing the SSD1306 library from Adafruit, type “GFX” in the
search box and install the library.

35
Fig.6.3.4 Install DFX from Library Manager
4. After installing the libraries, restart your Arduino IDE.

6.3.4 TESTING THE OLED DISPLAY

After wiring the OLED display to the Arduino and installing all required
libraries, you can use one example from the library to see if everything is
working properly.

In your Arduino IDE, go to File > Examples > Adafruit SSD1306 and
select the example for the display you’re using.

36
Fig.6.3.5 Example program for OLED

If your OLED doesn’t have a RESET pin, you should set


the OLED_RESET variable to -1 as shown below:

Fig.6.3.6 OLED_RESET

If your OLED display is not showing anything:


37
 Check that the OLED display is properly wired to the Arduino
 Double-check the OLED display I2C address: with the OLED connected
to the Arduino, upload this code and check the I2C address in the Serial
Monitor
You should change the OLED address in the following line, if necessary. In
our case, the address is 0x3C.
Write Test:
The Adafruit library for the OLED display comes with several functions
to write text. In this section, you’ll learn how to write and scroll text using the
library functions.

1. Importing libraries
First, you need to import the necessary libraries. The Wire library to use I2C
and the Adafruit libraries to write to the
display: Adafruit_GFX and Adafruit_SSD1306.

2. Initialize the OLED display


Then, you define your OLED width and height. In this example, we’re
using a 128×64 OLED display. If you’re using other sizes, you can change that
in the SCREEN_WIDTH, and SCREEN_HEIGHT variables.
#define S
Then, initialize a display object with the width and height defined earlier
with I2C communication protocol (&Wire).
The (-1) parameter means that your OLED display doesn’t have a RESET
pin. If your OLED display does have a RESET pin, it should be connected to a
GPIO. In that case, you should pass the GPIO number as a parameter.
In the setup(), initialize the Serial Monitor at a baud raute of 115200 for
debugging purposes.
Initialize the OLED display with the begin() method as follows:

38
In case you’re using a different OLED display, you may need to change
the OLED address. In our case, the address is 0x3C.
After initializing the display, add a two second delay, so that the OLED
has enough time to initialize before writing text:
Clear display, set font size, color and write text
After initializing the display, clear the display buffer with
the clearDisplay() method:
Before writing text, you need to set the text size, color and where the text
will be displayed in the OLED.
Set the font size using the setTextSize() method:
Set the font color with the setTextColor() method:
WHITE sets white font and black background.
Define the position where the text starts using the setCursor(x,y) method.
In this case, we’re setting the text to start at the (0,10) coordinates.
Finally, you can send the text to the display using the println() method, as
follows:
Then, you need to call the display() method to actually display the text on
the screen.

6.4 BUZZER

An audio signaling device like a beeper or buzzer symbol may be


electromechanical or piezoelectric or mechanical type. The main function of
this is to convert the signal from audio to sound. Generally, it is powered
through DC voltage , then produce sound and used in timers, alarm devices,
printers, alarms, computers, etc. Based on the various designs, it can generate
different sounds like alarm, music, bell & [Link] sound pressure level is a
crucial parameter for the signal device. Piezo element material of metal plate
can be brass,nickel alloy,or stainless [Link] plate can cause different

39
piezoeletric effect.
Buzzer is a kind of voice device that converts audio model into sound
signal. It is mainly used to prompt or alarm. According to different design and
application, it can produce music sound, flute sound, buzzer, alarm sound,
electric bell and other different [Link] applications include siren,
alarm device, fire alarm, air defense alarm, burglar alarm, timer, etc. It is
widely used in household appliances, alarm system, automatic production line,
low-voltage electrical equipment, electronic toys, game machines and other
products and industries. An arduino buzzer is also called a piezo buzzer. It is
basically a tiny speaker that you can connect directly to an Arduino. You can
make it sound a tone at a frequency you set. The buzzer produces sound based
on reverse of the piezoelectric effect.
For this tutorial you will need:
 Breadboard

 Buzzer / piezo speaker

 100 Ohm resistor (optional)

Fig.6.4.1 Buzzer

40
The pin configuration of the buzzer is shown below. It includes two pins
namely positive and negative. The positive terminal of this is represented with
the ‘+’ symbol or a longer terminal. This terminal is powered through 6Volts
whereas the negative terminal is represented with the ‘-‘symbol or short
terminal and it is connected to the GND terminal.

6.5 MULTI OUTPUT POWER MODULE


A power supply is an electronic circuit that converts the voltage of an
alternating current (AC) into a direct current (DC) voltage. It basically consists
of the following elements: transformer, rectifier, filter and regulator circuits.
There are three subsets of regulated power supplies: linear, switched, and
battery-based. Of the three basic regulated power supply designs, linear is the
least complicated system, but switched and battery power have their
advantages
When the jumper is in place, the Arduino powers the relay’s
electromagnet directly. In this case, the relay module and the Arduino are not
physically isolated from each other, but this makes the device easier to use
because it only needs one power supply.
Voltage Regulator:

A voltage regulator is an electronic circuit that provides a stable DC


voltage independent of the load current, temperature and AC line voltage
variations. A voltage regulator may use a simple feed-forward design or may
include negative feedback. It may use an electromechanical mechanism, or
electronic components. Depending on the design, it may be used to regulate
one or more AC or DC voltages.

Electronic voltage regulators are found in devices such as computer power


supplies where they stabilize the DC voltages used by the processor and other

41
elements. In automobile alternators and central power station generator plants,
voltage regulators control the output of the plant. In an electric power
distribution system, voltage regulators may be installed at a substation or along
distribution lines so that all customers receive steady voltage independent of
how much power is drawn from the line.

The circuit consists of following four parts.

 Reference voltage circuit


 Error amplifier
 Series pass transistor
 Feedback network

Fig.6.5.1 Power Supply Module 3.3 V, 5V

This DC-DC 12V to 3.3V 5V 12V Power Module Multi Output Voltage
Conversion is also known as Buck Converter or also as Step-Down Voltage
Converter. The module is capable of altering the output of the power
source/supply before supplying it to the load so as to deliver the specified
power to your load.
The device is very flexible and easy to use. The module is powered by 6V
42
to 12V DC input, and provides three fixed DC outputs: 3.3V, 5.0V, and a third
output which is a direct connection to the DC input (input to the module).
Perfect for providing support power for your electronic design, every DIY
hobbyist should have a couple of these flexible power supplies on
their electronics workbench. They can also be used as a multi-output fixed
voltage DC power supply in electronic equipment designs.
 Output power on/off switch
 Two-row multiple pin outputs, easy to use and connect
 Red LED illuminates when input DC power is supplied and output is
turned ON.
 Outputs
o 3.3V DC at 800mA maximum current
o 5.0V DC at 800mA maximum current
o 12V DC (the 12V output is directly connected to the input, i.e. with
12VDC input, this output will be 12VDC; with 9VDC input, this
output will be 9VDC)
 Small and Handy Module.
 Dual-side plate design
 Easy to use.

6.6 JUMPER WIRES


Jumper wires are essential electrical connectors used in electronics for
creating temporary connections between components on breadboards or
microcontrollers without soldering. They come in various types, lengths, and
colors to facilitate easy prototyping and circuit testing.
A jumper wire is an electric wire that connects remote electric circuits
used for printed circuit boards. By attaching a jumper wire on the circuit, it can
be short-circuited and short-cut (jump) to the electric circuit. By placing the
jumper wire on the circuit, it becomes possible to control the electricity,

43
stopthe operation of the circuit, and operate a circuit that does not operate with
ordinary wiring
Types of Jumper Wires
Jumper wires are categorized by the connectors on their ends:
 Male-to-Male (M-M): These have pins on both ends, ideal for connecting
two female sockets, such as points on a breadboard or a breadboard to a
development board.
 Male-to-Female (M-F): These have a pin on one end and a socket on the
other, typically used for connecting male headers on sensors or modules to
the female GPIO pins on microcontrollers like Arduino or Raspberry Pi.
 Female-to-Female (F-F): These have sockets on both ends and are used
to connect two male pins or to extend existing male-to-female
connections.
 Alligator Clips: Some specialized wires have alligator clips for a more
secure, temporary grip on components or testing points, which is useful
for troubleshooting.

Fig.6.6.1 Flexible Breadboard Jumper Wires


Key Specifications
When selecting jumper wires, several technical aspects are important:
 Wire Gauge: This refers to the thickness of the conductor. A common
gauge for breadboarding is 22 AWG, which is suitable for typical low-
current, low-voltage applications (up to 1A).
44
 Core Type:
 Solid Core: Made of a single, solid strand of copper wire, these
wires hold their shape well once bent and are excellent for neat,
stationary breadboard layouts.
 Stranded Core: Made of multiple thin strands twisted together, these
are more flexible and better suited for applications requiring frequent
movement.
 Length: Wires come in various lengths (e.g., 10 cm, 20 cm, 30 cm),
which helps avoid tangled circuits and ensures proper reach between
components.
 Color-Coding: Though all colors conduct electricity the same way, the
various colors help organize connections and simplify debugging.
Common conventions include red for power and black for ground
Also, when specification change or design change is necessary on the printed
circuit board, reinforcement of the defective part, partial stop of the
unnecessary function, and change of the circuit configuration of the
unnecessary output part by attaching or detaching the jumper wire can do.
Jump wires at the end of a multi-colored ribbon cable are used to connect the
pin header at the left side of a blue USB2Serial board to a white breadboard
below. Another jumper cable ending in a USB micro male connector mates to
the right side of the USB2Serial board. Red and black tinned jump wires can be
seen on the breadboard. There are three types of jumper wires, they are male to
male jumper wires, male to female jumper wires, female to female jumper
wires.

6.7 ADAPTER
An adapter is a device that connects otherwise incompatible electrical or
physical interfaces, enabling them to work together. Primarily used for power
conversion (AC to DC) for laptops and phones, they also adapt physical

45
connector shapes, such as in travel plugs or USB-C to HDMI converters. They
ensure compatibility without losing functionality.

6.7.1 Types of Adapters


 AC Adapter (Power Adapter/Charger): Converts alternating current
(AC) from wall outlets into lower-voltage direct current (DC) for
electronics like laptops and phones.
 Physical/Plug Adapter: Modifies the shape of a plug to fit different
international wall sockets, though it does not change the voltage
.
 Signal/Data Adapter: Connects different hardware interfaces, such as
USB-C to HDMI, DisplayPort, or Ethernet.
 Software Adapter: In programming, a design pattern that allows
incompatible software interfaces to work together.

6.7.2 Key Considerations


 Voltage/Wattage: When using power adapters, it is crucial to match the
required voltage and wattage to prevent device damage or overheating.
 Travel Adapters: These only change the plug shape; they are not the
same as voltage converters.
 Components: AC adapters contain transformers, filters, and rectifiers to
manage power conversion.

46
Fig.6.7.1 Adapter

6.8 BREADBOARD

A breadboard, solderless breadboard, or protoboard is a construction base


used to build semi-permanent prototypes of electronic circuits. Unlike a perf
board or stripboard, breadboards do not require soldering or destruction of
tracks and are hence reusable.

47
Fig.6.8.1 Medium Size Bread board

An electronics breadboard (as opposed to the type on which sandwiches


are made) is actually referring to a solderless breadboard. These are great
units for making temporary circuits and prototyping, and they require
absolutely no soldering.

Prototyping is the process of testing out an idea by creating a preliminary


model from which other forms are developed or copied, and it is one of the
most common uses for breadboards. If you aren’t sure how a circuit will react
under a given set of parameters, it’s best to build a prototype and test it out.

For those new to electronics and circuits, breadboards are often the best
place to start. That is the real beauty of breadboards--they can house both the
simplest circuit as well as very complex circuits. As you'll see later in this
tutorial, if your circuit outgrows its current breadboard, others can be be
attached to accommodate circuits of all sizes and complexities.
48
Another common use of breadboards is testing out new parts, such as
Integrated circuits (ICs). When you are trying to figure out how a part works
and constantly rewiring things, you don’t want to have to solder your
connections each time.

As mentioned, you don’t always want the circuit you build to be


permanent. When trying to duplicate a customer’s problem, SparkFun’s
Technical Support team will often use breadboards to build, test, and analyze
the circuit. They can connect the parts the customer has, and once they’ve
gotten the circuit setup and figured out the problem, they can take everything
apart and put it aside for the next time they need to do some troubleshooting.
Now that we’ve seen how the connections in a breadboard are made, let’s
look at a larger, more typical breadboard. Aside from horizontal rows,
breadboards usually have what are called power rails that run vertically along the
sides.
It is important to be aware that the power rails on either side are not
connected, so if you want the same power source on both sides, you will need to
connect the two sides with some jumper wires. Keep in mind that the markings
are there just as a reference. There is no rule that says you have to plug power
into the '+' rail and ground into the '-'rail, though it's good practice to keep
everything in order.

49
CHAPTER 7

KIT AND CIRCUIT DIAGRAM

7.1 PROJECT IMAGE

Fig.7.1 Air Quality Monitoring

50
Fig.7.2 Maximum Acceptable

51
Fig.7.3 Normal Condition

7.2 WORKING PRINCIPLE

The Air Quality Monitoring System is designed to measure the


concentration of harmful gases in the surrounding environment using an
MQ135 gas sensor, process the data using an Arduino microcontroller, and
display the air quality status on an SH1106 OLED display, along with an
audible alert using a buzzer.

1. Gas Sensing Operation (MQ135 Sensor)


The MQ135 gas sensor is a semiconductor-based sensor that detects
gases such as CO₂, NH₃, NOx, alcohol, benzene, and smoke.
 The sensing element inside the MQ135 changes its resistance when
exposed to different gas concentrations.
 As the gas concentration increases, the sensor resistance decreases,
52
resulting in a change in output voltage.
 This voltage change is read by the Arduino through its analog input
pin (A0) as an ADC value.

2. Signal Processing and Calibration


 The Arduino continuously reads the analog output of the MQ135
sensor.
 A baseline ADC value is first established by calibrating the sensor
in clean air.
 The difference between the real-time ADC value and the baseline
value is used to estimate the equivalent CO₂ concentration (PPM).
 The system applies a simple mathematical relation to convert the
sensor reading into approximate PPM values.

3. Air Quality Classification


Based on the calculated PPM value, the air quality is classified into
four levels:
 Good – Safe air quality
 Acceptable – Slight pollution
 Warning – Harmful concentration
 Dangerous – Highly polluted air
These thresholds help in quick identification of air conditions and
enable timely response.

4. Visual Display Using OLED


 The SH1106 OLED display shows:
o The CO₂ concentration in PPM with a large, centered font.
o A label indicating the unit of measurement.
o The air quality status (GOOD / ACCEPTABLE / WARNING /

53
DANGEROUS).
 The display is updated every few seconds to reflect real-time air
quality changes.

5. Alert Mechanism Using Buzzer


 When the air quality enters Warning or Dangerous levels, the
Arduino activates the buzzer.
 The buzzer provides an audible alert, warning people nearby about
unsafe air conditions.
 For Good and Acceptable air quality levels, the buzzer remains
OFF.

6. Continuous Monitoring
 The entire process runs continuously in a loop.
 Sensor data is updated at regular intervals, ensuring real-time air
quality monitoring.
 Debug information is also sent to the serial monitor for analysis and
calibration.

Commonly Accepted CO₂ Thresholds (Reference Values)

CO₂ (PPM) Air Quality Level Meaning


< 800 GOOD Fresh air
800 – 1000 ACCEPTABLE Slightly polluted
1000 – 2000 WARNING Health discomfort
> 2000 DANGEROUS Harmful

Table.7.1 CO₂ Thresholds

54
CHAPTER 8

CONCLUSION & FUTURE ENCHANCEMENT

8.1 CONCLUSION
In this project, a low-cost and efficient system for measuring CO₂
concentration and other harmful gases in air using an Arduino Nano and MQ-
135 gas sensor was successfully designed and implemented. The system is
capable of detecting carbon dioxide, LPG, smoke, and ammonia, providing
real-time gas concentration values that are displayed on a 0.96-inch OLED
display. This enables continuous monitoring of air quality in indoor and small-
scale environments.

The experimental results demonstrate that the MQ-135 sensor can


effectively indicate variations in gas concentration levels. The CO₂
measurements obtained from the MQ-135 sensor were compared with readings
from an infrared (IR) CO₂ sensor to evaluate accuracy and performance.
Although the MQ-135 sensor does not offer the same precision as an IR sensor,
it proves to be a reliable and economical alternative for general air quality
monitoring applications. The simplicity, portability, and affordability of the
proposed system make it suitable for educational, residential, and preliminary
environmental monitoring purposes.

8.2 FUTURE ENHANCEMENT

The proposed system can be further improved and expanded in several ways:
 Integration of IoT modules such as ESP8266 or ESP32 to enable remote
monitoring through mobile or web applications
 Cloud-based data logging and visualization for long-term air quality
analysis

55
 Implementation of automatic alert systems using SMS, email, or mobile
notifications when gas levels exceed safety thresholds
 Use of advanced calibration techniques or machine learning models to
improve gas concentration accuracy
 Addition of temperature and humidity sensors to compensate for
environmental variations affecting sensor readings
 Replacement or integration of high-precision infrared CO₂ sensors for
enhanced measurement accuracy
 Development of a portable battery-powered version for outdoor air
quality monitoring

8.3APPLICATION
 Indoor Air Quality Monitoring
The system can be used in homes, offices, classrooms, and
conference halls to continuously monitor indoor air quality and alert
occupants when harmful gas levels exceed safe limits.
 Industrial Safety Monitoring
In industries such as chemical plants, factories, and workshops, the
system helps detect the presence of hazardous gases and poor air
quality, ensuring worker safety through early warning alerts.
 Smart Building and Smart Home Systems
The air quality monitoring unit can be integrated into smart buildings
to automatically control ventilation systems, exhaust fans, or air
purifiers based on real-time pollution levels.
 Hospitals and Healthcare Facilities
Maintaining clean air is critical in hospitals, ICUs, and laboratories.
This system helps monitor air quality to reduce the risk of airborne
contamination and protect patients and staff.
56
 Educational Institutions
Schools and colleges can use the system to ensure a healthy learning
environment and also as a practical teaching tool for environmental
monitoring and IoT-based sensor applications.
 Public Places Monitoring
The device can be deployed in shopping malls, theaters, airports,
railway stations, and auditoriums to monitor crowd-induced air
pollution and trigger alerts when air quality deteriorates.
 Environmental Monitoring and Research
Researchers can use the system for studying air pollution trends in
different locations and for collecting environmental data for analysis
and awareness programs.
 Early Warning System for Gas Leakage
The buzzer alert feature makes the system suitable for detecting
abnormal gas concentration rises due to leakage or fire-related
emissions, providing immediate alerts.
 Portable Air Quality Analyzer
Due to its compact size and low power consumption, the system can
be used as a portable device for on-site air quality assessment.
 IoT-Based Monitoring Systems (Future Integration)
With the addition of Wi-Fi or GSM modules, the system can be
extended for remote monitoring, cloud data logging, and mobile
notifications.

57
REFERENCES

[1] A. Kumar, B. Singh, and C. Sharma, “Design and Implementation of an


IoT-Based LPG Gas Leakage Detection and Prevention System,” International
Journal of Engineering Research and Technology (IJERT), vol. 9, no. 6, pp.
112–116, 2020.
[2] M. Kumar, G. Mishra, A. Sharma, A. Shaini, and S. Saxena, “Air Quality
Monitoring Using MQ-135 Gas Sensor and Arduino Uno,” International
Journal of Latest Technology in Engineering, Management & Applied Science
(IJLTEMAS), vol. 10, no. 5, pp. 45–49, 2021.
[3] M. K. Kamran, H. Salahuddin, I. Kashif, U. Bashir, and A. D. Rehman,
“IoT-Based Smart Air Quality Monitoring System,” Journal of Computational
and Biomedical Informatics, vol. 4, no. 2, pp. 1–7, 2022.
[4] M. G. Arkhan and Z. R. S. Elsi, “Air Quality Monitoring System Based on
Internet of Things,” Brilliance: International Journal of Artificial Intelligence,
vol. 2, no. 1, pp. 10–18, 2023.
[5] S. Kumar, R. Verma, and P. Gupta, “Real-Time Air Pollution Monitoring
Using Arduino and Gas Sensors,” International Conference on Smart Systems
and Inventive Technology (ICSSIT), IEEE, pp. 624–629, 2019.
[6] M. Al-Kindi, A. Al-Rawahi, and S. Al-Bulushi, “Low-Cost CO₂
Monitoring System for Indoor Air Quality Using Gas Sensors,” IEEE Sensors
Journal, vol. 21, no. 8, pp. 10245–10252, 2021.
[7] Hanwei Electronics Co., Ltd., “MQ-135 Gas Sensor Datasheet,” 2018.
[8] Arduino, “Arduino Nano Technical Specifications,” Arduino Official
Documentation, 2022.

58
APPENDIX

/******************** MQ135 + SH1106 OLED + BUZZER


********************/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>

/******** OLED CONFIG ********/


#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_ADDR 0x3C

Adafruit_SH1106G display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -


1);

/******** MQ135 CONFIG ********/


#define MQ135_PIN A0

/******** BUZZER CONFIG ********/


#define BUZZER_PIN 2

/******** VARIABLES ********/


int rawADC;
float ppm;
String airQuality;

59
/******** BASELINE (CALIBRATE IN CLEAN AIR) ********/
int baselineADC = 265; // Adjust after observing clean-air ADC

void setup() {
[Link](9600);
[Link]();

pinMode(BUZZER_PIN, OUTPUT);
digitalWrite(BUZZER_PIN, LOW);

if (![Link](OLED_ADDR, true)) {
[Link]("SH1106 OLED not found");
while (1);
}

[Link]();
[Link]();
}

void loop() {
/******** READ MQ135 ********/
rawADC = analogRead(MQ135_PIN);

/*
MQ135 principle:
Gas ↑ → Resistance ↓ → ADC ↓ → PPM ↑

60
*/
ppm = (baselineADC - rawADC) * 10 + 400;

/******** AIR QUALITY LOGIC ********/


if (ppm < 800) {
airQuality = "GOOD";
digitalWrite(BUZZER_PIN, LOW);
}
else if (ppm < 1000) {
airQuality = "ACCEPTABLE";
digitalWrite(BUZZER_PIN, LOW);
}
else if (ppm < 2000) {
airQuality = "WARNING";
digitalWrite(BUZZER_PIN, HIGH);
}
else {
airQuality = "DANGEROUS";
digitalWrite(BUZZER_PIN, HIGH);
}

/******** OLED DISPLAY ********/


[Link]();
[Link](SH110X_WHITE);

int16_t x1, y1;

61
uint16_t w, h;

// BIG CO2 VALUE (CENTER)


[Link](3);
String ppmStr = String((int)ppm);
[Link](ppmStr, 0, 0, &x1, &y1, &w, &h);
[Link]((SCREEN_WIDTH - w) / 2, 0);
[Link](ppmStr);

// LABEL
[Link](2);
String label = "CO2 (PPM)";
[Link](label, 0, 0, &x1, &y1, &w, &h);
[Link]((SCREEN_WIDTH - w) / 2, 30);
[Link](label);

// AIR QUALITY STATUS


[Link](1);
[Link](airQuality, 0, 0, &x1, &y1, &w, &h);
[Link]((SCREEN_WIDTH - w) / 2, 54);
[Link](airQuality);

[Link]();

/******** SERIAL DEBUG ********/


[Link]("ADC: ");

62
[Link](rawADC);
[Link](" | CO2(eq): ");
[Link](ppm);
[Link](" ppm | AQ: ");
[Link](airQuality);

delay(2000);
}

63

You might also like