SlideShare a Scribd company logo
Building A Gas Detection System
With Arduino Nano
 GAS DETECTION SYSTEM
• A fun electronics project to detect harmful gases!
• Learn how to use arduino, sensors, and display to
make a safety device.
 Introduction To The Project
Purpose : Detects harmful gases like CO (carbon monoxide) and NO2 (nitrogen
dioxide) in the air.
Components :
-Arduino Nano: The brain of the system.
-MQ-135 Sensor: Detects gas levels.
-OLED Display: Shows gas levels or “Gas Detect System” when safe.
-Buzzer : Beeps if gas levels are high.
 Why It’s Cool: Helps keep us safe by warning about dangerous gases!
 How The System Detects Gases?
MQ-135 Sensor: Measures gas in the air and sends a signal (0-1023) to the Nano.
Arduino Nano: Reads the signal, calculates gas levels (ppm), and decides what to do.
 OLED Display:
-Shows “Gas Detect System” when no harmful gas is detected.
-Shows CO and NO2 levels (e.g., “CO: 125.0 ppm”) and “WARNING: High Gas!” if
levels are high.
 Buzzer: Beeps loudly if gas levels are dangerous.
 Power: Uses a 7.4V battery with a 5V regulator or USB cable.
S.NO. IMAGE DISCRIPTION
Arduino Nano
It is a compact, breadboard-friendly
microcontroller board based on the
ATmega328, ideal for small-scale
projects requiring digital and analog
I/O.
MQ-135 Gas Sensor
It is an air quality sensor used to
detect a wide range of gases,
including ammonia, nitrogen oxides,
alcohol, benzene, smoke, and
carbon dioxide.
0.96” OLED Display (SSD1306)
It is a compact, low-power screen
with 128x64 pixel resolution,
commonly used to display text,
graphics, or sensor data in
embedded projects.
 Components Needed
SNO. IMAGE DESCRIPTION
Buzzer (Active)
It is a sound-producing device that
generates a tone when powered,
without needing an external signal.
7.4V LiPo Battery
It is a rechargeable power source
known for its high energy density,
lightweight, and ability to deliver high
current.
Breadboard
A breadboard is a reusable platform for
prototyping electronic circuits without
soldering.
S.NO. IMAGE DESCRIPTION
Jumper Wires
These are used to make quick and
flexible connections between
components on the breadboard.
USB Cable
It is used to connect devices for
data transfer and power supply,
commonly used to program and
power microcontrollers like the
Arduino Nano from a computer.
 Wiring The System
 Arduino Nano: Place on a breadboard.
 OLED Display:
-VCC → 5V rail (Nano 5V or LM7805 VOUT).
-GND → GND rail (Nano GND).
-SDA → Nano A4.
-SCL → Nano A5.
 MQ-135 Sensor:
-VCC → 5V rail.
-GND → GND rail.
-AOUT → Nano A0.
Buzzer:
-Positive → Nano D7.
-Negative → GND rail.
Power:
-LM7805: VIN to LiPo positive, GND to LiPo negative and GND rail, VOUT to 5V
rail.
-Or use USB for testing (Nano 5V to 5V rail, GND to GND rail).
 Complete Code
 Features:
-Displays “Gas Detect System” when CO < 500 ppm and NO2 < 50 ppm.
-Shows ppm and “WARNING: High Gas!” if thresholds are exceeded.
-Preheats sensor for 2 minutes to ensure accuracy.
-Prints debug data to Serial Monitor (open in Arduino IDE).
How to Use:
-Copy to Arduino IDE.
-Install libraries: Adafruit_GFX, Adafruit_SSD1306.
-Upload to Nano.
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET-1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const int mq135Pin = A0;
const int buzzerPin = 6;
int gasValue = 0;
int threshold = 300; // Adjust based on calibration/environment
void setup() {
pinMode(buzzerPin, OUTPUT);
digitalWrite(buzzerPin, LOW);
Serial.begin(9600);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("OLED failed"));
while (1);
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.println("Gas Detection System");
display.display();
delay(2000);
}
void loop() {
gasValue = analogRead(mq135Pin);
Serial.println(gasValue);
display.clearDisplay();
display.setCursor(0, 0);
display.print("Gas Value: ");
display.println(gasValue);
if (gasValue > threshold) {
display.println("Gas Detected!");
digitalWrite(buzzerPin, HIGH);
} else {
display.println("Air OK");
digitalWrite(buzzerPin, LOW);
}
display.display();
delay(1000);
}
 What the OLED Shows?
On Startup:
-“Gas Detection” (first screen).
-“Gas Detection” and “Preheating...” (for 2 minutes, LED blinks).-
When Safe (No Gas):
-“Gas Detect System” (CO < 500 ppm, NO2 < 50 ppm).
-Buzzer is silent.
When Gas Detected:
-“CO: X.X ppm” (e.g., “CO: 125.0 ppm”).
-“NO2: Y.Y ppm” (e.g., “NO2: 12.5 ppm”).
-“WARNING: High Gas!” if CO > 500 ppm or NO2 > 50 ppm. -
-Buzzer beeps.
-Updates every second.
 Getting Ready to Program
Step 1: Download Arduino IDE ([www.arduino.cc/en/software](https://www.arduino.cc/en/software))
Step 2: Install libraries:
-Go to *Sketch* > *Include Library* >*Manage Libraries*.
- Search and install: *Adafruit_GFX, *Adafruit_SSD1306*.
 Step 3: Connect Nano via USB.
 Step 4: Set up IDE:
-*Tools* > *Board* > *Arduino Nano*.
-*Tools* > *Processor* > *ATmega328P* (or *Old Bootloader*). -
-*Tools* > *Port*: Select COM port (e.g., COM3).
 Step 5: Copy code, click *Upload*.
 Fixing Problems
OLED Not Displaying:
-Check wiring: VCC to 5V, GND to GND, SDA to A4, SCL to A5.
-Test power: Measure 5V at OLED VCC-GND.
-Run I2C scanner to check address (should be 0x3C or 0x3D).
- Replace OLED (~$5) if faulty.
Buzzer Beeping Constantly:
-Check Serial Monitor (Tools > Serial Monitor, 9600 baud).
-If raw value >500, preheat sensor longer (20 minutes) or test outdoors.
-Test buzzer alone: Should beep for 1 second, silent for 1 second.
*Upload Error* (e.g., avrdude: stk500_paged_write(): (a) protocol error):
- Install CH340 driver ([www.wch.cn](https://www.wch.cn)).
- Use data-capable USB cable.
- Disconnect MQ-135, OLED, buzzer during upload.
- Try *Old Bootloader* or press *Reset* during upload.
 Key Takeaways
Electronics: How to connect sensors, displays, and buzzers on a breadboard.
Programming: Writing Arduino code to read sensors and control outputs.
Problem-Solving: Fixing issues like blank displays, beeping buzzers, and upload
errors.
Real-World Application: Building a device to detect harmful gases for safety.
Next Steps: Try adding more sensors or a Wi-Fi module to send alerts!
COMPONENTS
PIN ON
COMPONENT
CONNECTS TO
ARDUINO
DESCRIPTION
OLED Display VCC 5V Power supply
GND GND Ground
SCL A5 I2C Clock (for UNO)
SDA A4 I2C Data (for UNO)
Gas Sensor VCC 5V Power supply
GND GND Ground
COMPONENTS
PIN ON
COMPONENT
CONNECTS TO
ARDUINO
DESCRIPTION
AOUT A0
Analog output to Arduino
analog pin
Buzzer + (Positive) D6
Digital output to control
buzzer
- (Negative) GND Ground
LED (Built-in) - D13 (LED_BUILTIN) Preheat indicator
THANK YOU

More Related Content

PDF
Toxic Gas Detection-An Experiment with the Simulation Process
PPTX
Gas Detection Alarm system using Arduino
PPTX
My project intrumentation - CO2 Detector with Arduino Uno
PPTX
Arduino-Based Gas Detecting Alarm System: Ensuring Safety with Smart Sensor T...
PPTX
My project intrumentation - CO2 Detector wth Arduino Uno
PPTX
My project intrumentation
DOCX
Gas & smoke detector Report
PPTX
fire detection sensor project.pptx with main
Toxic Gas Detection-An Experiment with the Simulation Process
Gas Detection Alarm system using Arduino
My project intrumentation - CO2 Detector with Arduino Uno
Arduino-Based Gas Detecting Alarm System: Ensuring Safety with Smart Sensor T...
My project intrumentation - CO2 Detector wth Arduino Uno
My project intrumentation
Gas & smoke detector Report
fire detection sensor project.pptx with main

Similar to Building A Gas Detection System With Arduino Nano[1].pptx (20)

PDF
Design_and_Development_of_Fire_and_Gas_L.pdf
PDF
Design_and_Development_of_Fire_and_Gas_L.pdf
PDF
Sonar Project Report
PPTX
sensors.pptx
PDF
Automatic Inspection System for Two Wheeler Servicing
PPTX
Tinkercad Workshop PPT, Dept. of ECE.pptx
PPTX
LPG gas leekage dectection
PPTX
Computer networks unit III CHAPTER of frameworks
PPT
IoT Basics with few Embedded System Connections for sensors
PPTX
IoT_Gas_Detection- Presentation presentation.pptx
PPTX
Arduino Based Gas Leakage Detector Project
PDF
Introduction to Arduinos for Environmental Applications
PDF
Fault Detection In Vehicles Using Sensors
PPTX
Final year Engineering project
PPT
embedded system
PPTX
AIR QUALITY MONITORING SYSTEM USING LORA.pptx
PPTX
major project ff (1)-1.pptx
PPTX
Thermal Sensor
PPTX
Mine workers protection slides
PDF
E033021025
Design_and_Development_of_Fire_and_Gas_L.pdf
Design_and_Development_of_Fire_and_Gas_L.pdf
Sonar Project Report
sensors.pptx
Automatic Inspection System for Two Wheeler Servicing
Tinkercad Workshop PPT, Dept. of ECE.pptx
LPG gas leekage dectection
Computer networks unit III CHAPTER of frameworks
IoT Basics with few Embedded System Connections for sensors
IoT_Gas_Detection- Presentation presentation.pptx
Arduino Based Gas Leakage Detector Project
Introduction to Arduinos for Environmental Applications
Fault Detection In Vehicles Using Sensors
Final year Engineering project
embedded system
AIR QUALITY MONITORING SYSTEM USING LORA.pptx
major project ff (1)-1.pptx
Thermal Sensor
Mine workers protection slides
E033021025
Ad

Recently uploaded (20)

PDF
The Detrimental Impacts of Hydraulic Fracturing for Oil and Gas_ A Researched...
DOC
LU毕业证学历认证,赫尔大学毕业证硕士的学历和学位
PDF
Item # 4 -- 328 Albany St. compt. review
PPTX
dawasoncitcommunityroolingadsAug 11_25.pptx
PPTX
The DFARS - Part 250 - Extraordinary Contractual Actions
PPTX
Omnibus rules on leave administration.pptx
PPTX
Nur Shakila Assesmentlwemkf;m;mwee f.pptx
PDF
Item # 5 - 5307 Broadway St final review
PDF
oil palm convergence 2024 mahabubnagar.pdf
PPTX
26.1.2025 venugopal K Awarded with commendation certificate.pptx
PDF
Courtesy Meeting NIPA and MBS Australia.
DOCX
EAPP.docxdffgythjyuikuuiluikluikiukuuuuuu
PPTX
Presentatio koos kokos koko ossssn5.pptx
PPTX
Inferenceahaiajaoaakakakakakakakakakakakakaka
PPTX
Introduction_to_the_Study_of_Globalization.pptx
PPTX
Portland FPDR Oregon Legislature 2025.pptx
PDF
Abhay Bhutada Foundation’s Integration With SEBI's 2021 ESG Guidelines
PDF
4_Key Concepts Structure and Governance plus UN.pdf okay
PDF
ISO-9001-2015-internal-audit-checklist2-sample.pdf
PDF
About Karen Miner-Romanoff - Academic & nonprofit consultant
The Detrimental Impacts of Hydraulic Fracturing for Oil and Gas_ A Researched...
LU毕业证学历认证,赫尔大学毕业证硕士的学历和学位
Item # 4 -- 328 Albany St. compt. review
dawasoncitcommunityroolingadsAug 11_25.pptx
The DFARS - Part 250 - Extraordinary Contractual Actions
Omnibus rules on leave administration.pptx
Nur Shakila Assesmentlwemkf;m;mwee f.pptx
Item # 5 - 5307 Broadway St final review
oil palm convergence 2024 mahabubnagar.pdf
26.1.2025 venugopal K Awarded with commendation certificate.pptx
Courtesy Meeting NIPA and MBS Australia.
EAPP.docxdffgythjyuikuuiluikluikiukuuuuuu
Presentatio koos kokos koko ossssn5.pptx
Inferenceahaiajaoaakakakakakakakakakakakakaka
Introduction_to_the_Study_of_Globalization.pptx
Portland FPDR Oregon Legislature 2025.pptx
Abhay Bhutada Foundation’s Integration With SEBI's 2021 ESG Guidelines
4_Key Concepts Structure and Governance plus UN.pdf okay
ISO-9001-2015-internal-audit-checklist2-sample.pdf
About Karen Miner-Romanoff - Academic & nonprofit consultant
Ad

Building A Gas Detection System With Arduino Nano[1].pptx

  • 1. Building A Gas Detection System With Arduino Nano
  • 2.  GAS DETECTION SYSTEM • A fun electronics project to detect harmful gases! • Learn how to use arduino, sensors, and display to make a safety device.
  • 3.  Introduction To The Project Purpose : Detects harmful gases like CO (carbon monoxide) and NO2 (nitrogen dioxide) in the air. Components : -Arduino Nano: The brain of the system. -MQ-135 Sensor: Detects gas levels. -OLED Display: Shows gas levels or “Gas Detect System” when safe. -Buzzer : Beeps if gas levels are high.  Why It’s Cool: Helps keep us safe by warning about dangerous gases!
  • 4.  How The System Detects Gases? MQ-135 Sensor: Measures gas in the air and sends a signal (0-1023) to the Nano. Arduino Nano: Reads the signal, calculates gas levels (ppm), and decides what to do.  OLED Display: -Shows “Gas Detect System” when no harmful gas is detected. -Shows CO and NO2 levels (e.g., “CO: 125.0 ppm”) and “WARNING: High Gas!” if levels are high.  Buzzer: Beeps loudly if gas levels are dangerous.  Power: Uses a 7.4V battery with a 5V regulator or USB cable.
  • 5. S.NO. IMAGE DISCRIPTION Arduino Nano It is a compact, breadboard-friendly microcontroller board based on the ATmega328, ideal for small-scale projects requiring digital and analog I/O. MQ-135 Gas Sensor It is an air quality sensor used to detect a wide range of gases, including ammonia, nitrogen oxides, alcohol, benzene, smoke, and carbon dioxide. 0.96” OLED Display (SSD1306) It is a compact, low-power screen with 128x64 pixel resolution, commonly used to display text, graphics, or sensor data in embedded projects.  Components Needed
  • 6. SNO. IMAGE DESCRIPTION Buzzer (Active) It is a sound-producing device that generates a tone when powered, without needing an external signal. 7.4V LiPo Battery It is a rechargeable power source known for its high energy density, lightweight, and ability to deliver high current. Breadboard A breadboard is a reusable platform for prototyping electronic circuits without soldering.
  • 7. S.NO. IMAGE DESCRIPTION Jumper Wires These are used to make quick and flexible connections between components on the breadboard. USB Cable It is used to connect devices for data transfer and power supply, commonly used to program and power microcontrollers like the Arduino Nano from a computer.
  • 8.  Wiring The System  Arduino Nano: Place on a breadboard.  OLED Display: -VCC → 5V rail (Nano 5V or LM7805 VOUT). -GND → GND rail (Nano GND). -SDA → Nano A4. -SCL → Nano A5.  MQ-135 Sensor: -VCC → 5V rail. -GND → GND rail. -AOUT → Nano A0.
  • 9. Buzzer: -Positive → Nano D7. -Negative → GND rail. Power: -LM7805: VIN to LiPo positive, GND to LiPo negative and GND rail, VOUT to 5V rail. -Or use USB for testing (Nano 5V to 5V rail, GND to GND rail).
  • 10.  Complete Code  Features: -Displays “Gas Detect System” when CO < 500 ppm and NO2 < 50 ppm. -Shows ppm and “WARNING: High Gas!” if thresholds are exceeded. -Preheats sensor for 2 minutes to ensure accuracy. -Prints debug data to Serial Monitor (open in Arduino IDE). How to Use: -Copy to Arduino IDE. -Install libraries: Adafruit_GFX, Adafruit_SSD1306. -Upload to Nano.
  • 11. #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET-1 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); const int mq135Pin = A0; const int buzzerPin = 6; int gasValue = 0; int threshold = 300; // Adjust based on calibration/environment void setup() { pinMode(buzzerPin, OUTPUT); digitalWrite(buzzerPin, LOW); Serial.begin(9600);
  • 12. if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("OLED failed")); while (1); } display.clearDisplay(); display.setTextSize(1); display.setTextColor(SSD1306_WHITE); display.setCursor(0, 0); display.println("Gas Detection System"); display.display(); delay(2000); } void loop() { gasValue = analogRead(mq135Pin); Serial.println(gasValue);
  • 13. display.clearDisplay(); display.setCursor(0, 0); display.print("Gas Value: "); display.println(gasValue); if (gasValue > threshold) { display.println("Gas Detected!"); digitalWrite(buzzerPin, HIGH); } else { display.println("Air OK"); digitalWrite(buzzerPin, LOW); } display.display(); delay(1000); }
  • 14.  What the OLED Shows? On Startup: -“Gas Detection” (first screen). -“Gas Detection” and “Preheating...” (for 2 minutes, LED blinks).- When Safe (No Gas): -“Gas Detect System” (CO < 500 ppm, NO2 < 50 ppm). -Buzzer is silent. When Gas Detected: -“CO: X.X ppm” (e.g., “CO: 125.0 ppm”). -“NO2: Y.Y ppm” (e.g., “NO2: 12.5 ppm”). -“WARNING: High Gas!” if CO > 500 ppm or NO2 > 50 ppm. - -Buzzer beeps. -Updates every second.
  • 15.  Getting Ready to Program Step 1: Download Arduino IDE ([www.arduino.cc/en/software](https://www.arduino.cc/en/software)) Step 2: Install libraries: -Go to *Sketch* > *Include Library* >*Manage Libraries*. - Search and install: *Adafruit_GFX, *Adafruit_SSD1306*.  Step 3: Connect Nano via USB.  Step 4: Set up IDE: -*Tools* > *Board* > *Arduino Nano*. -*Tools* > *Processor* > *ATmega328P* (or *Old Bootloader*). - -*Tools* > *Port*: Select COM port (e.g., COM3).  Step 5: Copy code, click *Upload*.
  • 16.  Fixing Problems OLED Not Displaying: -Check wiring: VCC to 5V, GND to GND, SDA to A4, SCL to A5. -Test power: Measure 5V at OLED VCC-GND. -Run I2C scanner to check address (should be 0x3C or 0x3D). - Replace OLED (~$5) if faulty. Buzzer Beeping Constantly: -Check Serial Monitor (Tools > Serial Monitor, 9600 baud). -If raw value >500, preheat sensor longer (20 minutes) or test outdoors. -Test buzzer alone: Should beep for 1 second, silent for 1 second.
  • 17. *Upload Error* (e.g., avrdude: stk500_paged_write(): (a) protocol error): - Install CH340 driver ([www.wch.cn](https://www.wch.cn)). - Use data-capable USB cable. - Disconnect MQ-135, OLED, buzzer during upload. - Try *Old Bootloader* or press *Reset* during upload.
  • 18.  Key Takeaways Electronics: How to connect sensors, displays, and buzzers on a breadboard. Programming: Writing Arduino code to read sensors and control outputs. Problem-Solving: Fixing issues like blank displays, beeping buzzers, and upload errors. Real-World Application: Building a device to detect harmful gases for safety. Next Steps: Try adding more sensors or a Wi-Fi module to send alerts!
  • 19. COMPONENTS PIN ON COMPONENT CONNECTS TO ARDUINO DESCRIPTION OLED Display VCC 5V Power supply GND GND Ground SCL A5 I2C Clock (for UNO) SDA A4 I2C Data (for UNO) Gas Sensor VCC 5V Power supply GND GND Ground
  • 20. COMPONENTS PIN ON COMPONENT CONNECTS TO ARDUINO DESCRIPTION AOUT A0 Analog output to Arduino analog pin Buzzer + (Positive) D6 Digital output to control buzzer - (Negative) GND Ground LED (Built-in) - D13 (LED_BUILTIN) Preheat indicator