Arduino UNO Gas Leak Detection System with Buzzer and Servo Motor
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to detect gas levels using an MQ2 gas sensor and respond by activating a buzzer and a micro servo motor. The system is controlled by an Arduino UNO microcontroller. When the gas level exceeds a certain threshold, the buzzer sounds, and the servo motor moves to a specified position.
Component List
MQ2 Gas Sensor
- Pins: VCC, GND, AOUT, DOUT
- Description: Detects gas levels in the environment.
- Purpose: Senses gas levels and sends a digital signal to the Arduino.
AC Wire
- Pins: Line, Earth, Neutral
- Description: Standard AC wire for power connections.
- Purpose: Provides power connections in the circuit.
AC Wire
- Pins: GND, Phase
- Description: Standard AC wire for power connections.
- Purpose: Provides power connections in the circuit.
Arduino UNO
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
- Description: Microcontroller board based on the ATmega328P.
- Purpose: Controls the entire circuit, processes sensor data, and drives the output devices.
Buzzer
- Pins: PIN, GND
- Description: Emits sound when activated.
- Purpose: Provides an audible alert when gas levels are high.
Micro Servo 9G
- Pins: GND, +5V, PWM
- Description: Small servo motor.
- Purpose: Moves to a specified position when gas levels are high.
IRFZ44N
- Pins: Gate, Drain, Source
- Description: N-channel MOSFET.
- Purpose: Acts as a switch in the circuit.
Resistor
- Pins: pin1, pin2
- Description: 200 Ohms resistor.
- Purpose: Limits current in the circuit.
Wiring Details
MQ2 Gas Sensor
- VCC connected to 5V of Arduino UNO.
- GND connected to GND of Arduino UNO.
- DOUT connected to A0 of Arduino UNO.
AC Wire
- Phase connected to 5V of Arduino UNO.
- GND connected to GND of Arduino UNO.
AC Wire
- Phase connected to Source of IRFZ44N.
AC Wire
- GND connected to pin1 of Resistor.
AC Wire
- Phase connected to D10 of Arduino UNO.
Arduino UNO
- 5V connected to VCC of MQ2 Gas Sensor.
- GND connected to GND of MQ2 Gas Sensor.
- A0 connected to DOUT of MQ2 Gas Sensor.
- D9 connected to PWM of Micro Servo 9G.
- D8 connected to PIN of Buzzer.
Buzzer
- PIN connected to D8 of Arduino UNO.
- GND connected to GND of Arduino UNO.
Micro Servo 9G
- +5V connected to 5V of Arduino UNO.
- GND connected to GND of Arduino UNO.
- PWM connected to D9 of Arduino UNO.
IRFZ44N
- Gate connected to pin2 of Resistor.
- Source connected to Phase of AC Wire.
Resistor
- pin1 connected to GND of AC Wire.
- pin2 connected to Gate of IRFZ44N.
Code Documentation
#include <Servo.h>
#define gas_sensor A0
#define buzzer 8
int sensor_value;
Servo servo;
void setup() {
Serial.begin(9600);
pinMode(buzzer, OUTPUT);
servo.attach(9); //servo motor signal pin attached to arduino pin 9
servo.write(2); //regulator on
}
void loop() {
sensor_value = analogRead(gas_sensor);
Serial.println(sensor_value);
if (sensor_value > 500) // change this value according to sensitivity of gas
{
digitalWrite(buzzer, HIGH);
servo.write(130);
}
else
{
digitalWrite(buzzer, LOW);
servo.write(5);
}
delay(500);
}
This code initializes the gas sensor, buzzer, and servo motor. In the loop function, it continuously reads the gas sensor value. If the gas level exceeds the threshold (500 in this case), the buzzer is activated, and the servo motor moves to 130 degrees. If the gas level is below the threshold, the buzzer is deactivated, and the servo motor returns to 5 degrees.