nealpatel
Published

Gas Sensor

It senses gas and sends an alert if gas is identified.

IntermediateFull instructions provided18,459
Gas Sensor

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Sunfounder MQ-2 gas sensor
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Buzzer
Buzzer
×1
Resistor 220 ohm
Resistor 220 ohm
×3
5 mm LED: Red
5 mm LED: Red
×1
5 mm LED: Green
5 mm LED: Green
×1
4xAA battery holder
4xAA battery holder
×1

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Custom parts and enclosures

Casing

It is a casing for the gas sensor

Schematics

Fritzing Model

The MQ-5 sensor
Pin-> Wiring to Arduino Uno
A0-> Analog pins
D0-> none
GND-> GND
VCC-> 5V
other components
Pin-> Wiring to Arduino Uno
D13-> +ve of buzzer
GND-> -ve of buzzer
D12-> anode of red light
D11-> anode of green light
GND-> cathode of red light
GND-> cathode of red light

Circuit

The circuit in real life and what it is supposed to look like

Code

Code

Arduino
IT is the code that is used to make the gas sensor work with psuedocode.
int red_led=12;//indicates gas
int green_led=11;//indicates normal
int buzz=13;//indicates gas
intsmokeA0 = A5;//indicates sensor is connected to A5
int sensorThres=400;//The threshold value
void setup()
{
pinMode(red_led,OUTPUT);//red led as output
pinMode(buzz,OUTPUT);// buzz as output
pinMode(green_led,OUTPUT);//green led as output
pinMode(A1,INPUT);//sensor as input
Serial.begin(9600);//starts the code
}
void loop()//loops
{
gas_avalue=analogRead(smokeA0);//reads sensor value
if (A0 > sensorThres)//sees if it reached threshold value
{
digitalWrite(red_led, HIGH);//turns on red led
digitalWrite(green_led, LOW);//turns off green led
digitalWrite( buzz, HIGH);//turns on buzzer
}
else//if it hasn't reached threshold value
{
digitalWrite(red_led, LOW);//turns red led off
digitalWrite(green_led, HIGH);//turn green led on
digitalWrite( buzz, LOW);//turns buzzer off
}
delay(100);//delay 0.1 sec
}

Credits

nealpatel

nealpatel

0 projects • 1 follower

Comments