Gas Leak Detection and Warning System:
This project focuses on creating a Gas Leak Detection and Warning System using an Arduino Uno and various components. The main goal is to enhance safety by detecting potentially dangerous gasses like methane and propane. When gas levels exceed safe limits, the system provides clear visual and audible warnings to alert users and mitigate potential hazards.
What makes this project especially appealing is its user-friendly nature. The kit is designed for ease of assembly, with comprehensive instructions provided. All the necessary details, including circuit diagrams, pinout connections, and Arduino programming code, are included. Uploading the code to the Arduino is a straightforward process, ensuring that even beginners can quickly assemble and deploy this gas detection system for enhanced safety.
Components Required:-
Â
1.One Arduino UNO 2.One MQ-5 Gas Sensor 3.One Buzzer
4.One White LED 5.One Red LED
- One Jumper Wires (Set of 10)
- One 12V Li-ion 1200mah Rechargeable Battery Pack
Components and Their Functions:
- Arduino UNO:-
Function: The Arduino Uno is a microcontroller board that serves as the brain of your project. It’s responsible for controlling all other components based on the code you program it with.
Specifications:-
- Microcontroller: The Arduino Uno is based on the ATmega328P microcontroller from Atmel (now a part of Microchip Technology). It operates at a clock speed of 16
- Digital I/O Pins: It has a total of 14 digital input/output These pins can be used for both digital input and output operations.
- Analog Input Pins: The board has 6 analog input pins marked A0 through A5, which can be used for reading analog
- PWM (Pulse Width Modulation) Pins: There are 6 PWM output pins, which can be used for tasks such as controlling the brightness of LEDs or the speed of
- Operating Voltage: The Arduino Uno can be powered either via a USB connection (5V) or an external power supply (7-12V). It has a built-in voltage regulator that regulates the voltage to 5V for the
- Flash Memory: It comes with 32KB of flash memory for storing your
- SRAM: The Uno has 2 KB of SRAM for storing variables and runtime
- EEPROM: It has 1KB of EEPROM, which can be used for storing non-volatile
- Clock Speed: The Arduino Uno operates at 16 MHz, which determines the execution speed of your
- USB Interface: It features a USB Type-B connector for connecting to a computer for programming and serial
- Reset Button: The board includes a reset button for restarting your
- LEDs: There are built-in LEDs on the board, including a power LED and a built-in LED on pin 13, which is often used for testing and
- Size: The Arduino Uno board has dimensions of approximately 7 x 2.1 inches (68.6 x
53.3 mm).
- Operating Voltage Range: The recommended operating voltage range for the Arduino Uno is 7-12V, although it can tolerate a wider
- Communication: The Arduino Uno can communicate with other devices via UART, SPI, and I2C
- Software: Arduino Uno is programmed using the Arduino IDE (Integrated Development Environment), which is based on the C++ programming It has a vast library of pre-built functions and examples for various sensors and modules.
- Open Source: The Arduino platform is open-source, which means that the hardware and software designs are available for anyone to use and
The Arduino Uno is a versatile and beginner-friendly board that is widely used for prototyping and learning electronics and programming. Its simplicity and strong community support make it a popular choice for makers and hobbyists.
Pin Out :-
Digital Pins (D0-D13):
- D0 to D13 are digital input/output pins. These pins can be used for both digital input (reading digital signals like a button press) and digital output (controlling LEDs, relays, ). Pin D13 also has an onboard LED that can be used for testing and debugging.
Analog Pins (A0-A5):
- A0 to A5 are analog input These pins can be used to read analog voltage levels (0-5V). They are often used to interface with sensors or read analog data.
Power Pins:
- 5V: This pin provides a regulated 5V output, which can be used to power external
- 3V: This pin provides a 3.3V regulated output.
- GND (Ground): There are several GND pins on the board, which are the ground reference for your
Other Pins:
- Vin: This pin allows you to provide an external voltage supply to power the Arduino It should be in the range of 7-12V.
- ARef: This pin can be used as a reference voltage for analog
- RESET: The RESET pin is used to reset the Communication Pins:
- TX (Transmit): Used for serial communication (transmit data).
- RX (Receive): Used for serial communication (receive data).
- SCL (I2C Clock): Used for I2C
- SDA (I2C Data): Used for I2C
- SCK (SPI Clock): Used for SPI
- MISO (SPI Data In): Used for SPI
- MOSI (SPI Data Out): Used for SPI
- SS (SPI Slave Select): Used for SPI
These pins are essential for connecting sensors, actuators, and other components to your Arduino Uno and for communication with other devices. Remember to consult the Arduino documentation and your specific project requirements to determine how to use these pins effectively.
- MQ-5 Gas Sensor:
Function: The MQ-5 Gas Sensor is designed to detect various gases, such as methane, propane, and other combustible gases.
Use: While it’s not typically used for obstacle avoidance, you can employ it to detect gas leaks in a specific area.
Specifications:-
- Operating Voltage: The MQ-5 sensor module typically operates at a voltage between 5V and 12V DC. It’s essential to provide the correct voltage within this range for proper
- Power Consumption: The power consumption of the MQ-5 sensor is relatively low, typically in the range of 150mW to 800mW, depending on the operating conditions and the specific
- Sensitivity: The MQ-5 sensor is highly sensitive to a range of combustible gases, including LPG (liquefied petroleum gas), methane, propane, and It can detect concentrations of these gases in the air.
- Response Time: The response time of the MQ-5 sensor is generally in the range of a few It can quickly detect changes in gas concentrations in its vicinity.
- Heating Element: The sensor module contains a built-in heating element that is used to heat the sensor’s sensing element, which is usually a tin dioxide (SnO2)
- Analog Output: The MQ-5 sensor provides an analog output voltage that varies with the gas This output can be read by an analog-to-digital converter (ADC) on a microcontroller or other control systems.
- Digital Output: Some MQ-5 sensor modules also come with a digital output pin that provides a high or low signal based on a predefined gas concentration
- Operating Temperature Range: The sensor is typically designed to operate within a temperature range of -20°C to +50°C (-4°F to +122°F). Operating the sensor outside of this range can affect its accuracy and
- Storage Temperature Range: It can be stored within a broader temperature range, often from -20°C to +70°C (-4°F to +158°F).
- Operating Humidity Range: The MQ-5 sensor can operate in relative humidity conditions of up to 95% RH (non-condensing).
- Dimensions: The physical dimensions of the MQ-5 sensor module can vary between manufacturers, but they are typically small and
- Calibration: Calibrating the sensor may be necessary for accurate gas concentration This process involves exposing the sensor to a known concentration of the target gas and adjusting the readings accordingly.
- Lifespan: The lifespan of the sensor can vary depending on usage, environmental conditions, and the quality of the sensor Regular calibration and maintenance can help prolong its lifespan.
Pin Out:-
- AO (Analog Output): This pin provides an analog output voltage that varies with the concentration of the detected gas. You can connect this pin to an analog-to-digital converter (ADC) on a microcontroller to measure the gas
- DO (Digital Output): Some MQ-5 sensor modules include a digital output pin that provides a high or low signal based on a predefined gas concentration You can connect this pin directly to a digital input pin on a microcontroller for digital gas detection.
- VCC (Voltage Supply): This pin is used to provide power to the sensor module. It typically operates at 5V, but some modules may accept a voltage range between 5V and 12V, so check the datasheet or module specifications for the exact voltage
- GND (Ground): This pin is connected to the ground (0V) of your power supply or microcontroller to complete the
Buzzer:
Function: The buzzer generates audible alerts or alarms when specific events, such as gas detection or obstacle avoidance, occur.
Specifications:-
- Operating Voltage: Ensure the buzzer’s voltage rating matches your power
- Sound Output Level: Consider the sound output level (measured in dB) to determine how loud the buzzer
- Tone Type: Check if the buzzer produces a continuous sound or specific
- Frequency: Look at the buzzer’s frequency to ensure it produces the desired
- Current Rating: Ensure your power supply can provide the required current for the
- Size and Dimensions: Consider the physical size and form factor to fit your
- Operating Life: Check the expected operating life to assess
- Sound Pattern: Determine if the buzzer can produce the desired sound
- Housing Material: Consider the housing material for
- Termination Type: Choose a termination type that suits your wiring
Pin Out:-
- Positive Terminal (+): This terminal is connected to the positive voltage supply, typically your power source’s positive
- Negative Terminal (-): This terminal is connected to the ground (0V) of your power
White LED:
Function: The white LED provides illumination and can be used for signaling.
Use: You can use the white LED to indicate when the gas sensor detects a specific gas. Specifications:-
- Luminous Flux (Brightness): Indicates how much visible light the LED emits, measured in lumens (lm). Choose the appropriate brightness level for your lighting
- Color Temperature: Determines the warmth or coolness of the white Select a color temperature that suits your lighting application, such as warm white for a cozy atmosphere or cool white for task lighting.
- Forward Voltage (Vf): The voltage required to operate the Ensure your power supply voltage matches or exceeds the LED’s forward voltage to prevent damage.
- Forward Current (If): The current flowing through the LED when it’s Use an appropriate current-limiting resistor or driver to control the current.
Pin Out:-
- Anode (A or +): This is the positive terminal of the It connects to the positive side of your power supply.
- Cathode (K or -): This is the negative terminal of the It connects to the ground (0V) of your power supply.
Red LED:
Function: The red LED serves as a warning or indicator. Specifications:-
- Color Wavelength: Red LEDs typically emit light in the red portion of the visible spectrum, with a wavelength around 620-750 nanometers (nm).
- Forward Voltage (Vf): The voltage required to make the LED emit red light, typically around 8 to 2.2 volts.
- Forward Current (If): The current flowing through the LED when it’s lit, typically in the range of 5mA to
- Luminous Intensity: Measures the brightness of the LED, specified in millicandelas (mcd) or candelas (cd).
Pin Out:
- Anode (A or +): This is the positive terminal of the Connect it to the positive side of your power supply or circuit.
- Cathode (K or -): This is the negative terminal of the Connect it to the ground (0V) or the negative side of your power supply or circuit.
9V Li-ion Battery:
Function: The battery provides a power source for the Arduino and components, ensuring portability.
Specifications:-
- Voltage: A 9V Li-ion battery provides a nominal voltage of 9 volts, which is suitable for devices designed for 9V power
- Capacity (mAh): Capacity indicates how long the battery can power a Higher milliampere-hour (mAh) ratings mean the battery can provide power for a longer duration.
- Chemistry: Li-ion (Lithium-ion) chemistry provides a high energy density, making it an efficient and long-lasting power
- Rechargeability: 9V Li-ion batteries are rechargeable, allowing you to use them multiple times and reduce
- Cycle Life: The cycle life specifies how many charge and discharge cycles the battery can endure before its capacity significantly Longer cycle life is desirable for extended use.
- Operating Temperature Range: Check the temperature range within which the battery can operate Typically, it’s around -20°C to +60°C (-4°F to +140°F).
- Self-Discharge Rate: A low self-discharge rate means the battery can hold its charge for extended periods when not in use, ensuring it’s ready when
- Safety Features: Some 9V Li-ion batteries include safety features like overcharge protection and short-circuit protection to prevent accidents during charging and
Pin Out:
- Positive Terminal (+): This terminal is the positive side of the battery, and you connect your device’s positive input or load to this
- Negative Terminal (-): This terminal is the negative side of the battery, and you connect your device’s negative input or ground to this
Circuit Diagram:
Connections:
Â
MQ-5 Gas Sensor Connections with Arduino:
Vcc: Connect to 5V on the Arduino for power.
Ao (Analog Output): Connect to an analog pin on the Arduino (e.g., A0) for reading the gas sensor’s analog output.
Gnd: Connect to the ground (GND) on the Arduino for reference. Buzzer Connections with Arduino:
Vcc: Connect to a digital pin on the Arduino (e.g., D4) for controlling the buzzer. Gnd: Connect to the ground (GND) on the Arduino for reference.
White LED Connection with Arduino:
Vcc: Connect to a digital pin on the Arduino (e.g., D3) for controlling the white LED. Gnd: Connect to the ground (GND) on the Arduino for reference.
Red LED Connection with Arduino:
Vcc: Connect to a digital pin on the Arduino (e.g., D2) for controlling the red LED. Gnd: Connect to the ground (GND) on the Arduino for reference.
Project Functionality:
The project uses the MQ-5 Gas Sensor to detect gas levels. When gas is detected, the Arduino can trigger various actions, such as illuminating the white LED to provide visibility in the area, activating the red LED as a warning indicator, and sounding the buzzer as an alarm.
While this project is primarily focused on gas detection and signaling rather than obstacle avoidance, you can adapt the code to perform actions based on gas sensor readings, providing safety alerts when certain gas levels are detected.
Code:
Â
// GAS DETECTOR
int Input = A0; // Analog pin for gas sensor input int R_LED = 2;Â Â // Red LED pin
int G_LED = 3;Â Â Â // Green LED pin int Buzzer = 4; // Buzzer pin
int val;Â Â Â Â Â Â Â Â Â // Variable to store the sensor reading
int MAX = 400;Â Â Â // Maximum threshold for gas detection
void setup() {
Serial.begin(9600); // Initialize serial communication pinMode(Input, INPUT);Â Â Â // Set gas sensor pin as input pinMode(R_LED, OUTPUT); // Set red LED pin as output pinMode(G_LED, OUTPUT); // Set green LED pin as output pinMode(Buzzer, OUTPUT); // Set buzzer pin as output
}
void loop() {
val = analogRead(A0); // Read the gas sensor value
if (val >= MAX) {
digitalWrite(R_LED, HIGH); // Turn on the red LED digitalWrite(Buzzer, HIGH); // Turn on the buzzer digitalWrite(G_LED, LOW);Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Turn off the green LED
Serial.println(“GAS LEAKING”); // Print gas leak message to serial monitor
} else {
digitalWrite(R_LED, LOW);Â Â Â // Turn off the red LED digitalWrite(Buzzer, LOW);Â Â // Turn off the buzzer digitalWrite(G_LED, HIGH); // Turn on the green LED Serial.println(“NORMAL”);Â Â Â Â Â // Print normal message to serial monitor
}
}
Here’s an explanation of how this code works:
Â
Setup Function:
The setup function initializes the following:
Serial communication at a baud rate of 9600, which allows debugging information to be printed to the serial monitor.
Configures the gas sensor pin (Input) as an input.
Sets the pins connected to the red LED (R_LED), green LED (G_LED), and buzzer (Buzzer) as outputs.
Loop Function:
The loop function runs continuously, repeatedly executing the following steps: Reading Gas Sensor:
It reads the analog value from the gas sensor connected to pin A0 and stores it in the val variable.
Gas Leak Detection:
If the val (the gas sensor reading) is greater than or equal to the predefined threshold MAX (400 in this case), it signifies a gas leak condition.
In this condition:
The red LED (R_LED) is turned on (HIGH).
The buzzer is activated, generating an audible alert by setting it to HIGH. The green LED (G_LED) is turned off (LOW).
A message “GAS LEAKING” is printed to the serial monitor. Normal Environment:
If the val is below the MAX threshold, it indicates a normal environment condition. In this case:
The red LED (R_LED) is turned off (LOW). The buzzer is turned off (LOW).
The green LED (G_LED) is turned on (HIGH).
A message “NORMAL” is printed to the serial monitor. Functionality Summary:
The code continuously monitors the analog output of the gas sensor.
If the sensor reading surpasses the predefined threshold, it activates the red LED and buzzer, indicating a gas leak.
In a normal environment, the green LED remains on, and no audible alert is generated.
The code provides real-time feedback via the serial monitor, making it useful for detecting and responding to gas leaks.
This gas detector system is a simple but effective way to monitor gas levels and provide immediate visual and audible alerts in the event of a gas leak, contributing to safety and early detection.