Smoke Detection Alarm using Arduino(烟雾传感器)

ArduinoHow to make Smoke Detection Alarm using Arduino?

Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards can read digital & analog inputs from the sensors and The MQ2 smoke sensor is sensitive to smoke gases like LPG, Butane, Propane, Methane, Alcohol, Hydrogen.

In this article, We will learn how can we make a Smoke Detector Alarm using Arduino. When the MQ2 Gas Sensor will detect the smoke level high, the red led will glow and the buzzer will start.

Components Required
 

  • Arduino UNO -> A microcontroller board based on the ATmega328P
  • Buzzer -> A device that produces sound or alarm
  • 5V LED -> A Light-emitting diode that emits light 
  • 100ohm Resistor -> To resist the current
  • Jumper Wires -> For connecting the elements of the circuit

77c966079f8a416eb2f696e5cf8d78a2.png

 In this circuit, the MQ2 gas sensor detects the level of smoke in the environment and sends the analog value to the Arduino. which compares the value with the standard value if the value is higher, Arduino sends the signal to the led and the red light will be illuminated and the buzzer will be started. otherwise, green led will be illuminated.

Pins Connection

  • Arduino Digital pin 0 is connected with the (+ve) pin of Buzzer
  • Arduino Digital pin 1  is connected with the (+ve) pin of LED1(green)
  • Arduino Digital pin 2  is connected with the (+ve) pin of LED2(red)
  • Arduino Analog pin A0  is connected with A0 Pin of MQ2 Gas sensor
  • Arduino 5v Power pin is connected with VCC pin of Gas sensor
  • Arduino GND Power pin is connected with GND pin of Gas sensor
  • Arduino GND Power pin is connected with (-ve) pins of LED’s with resistance
  • Arduino GND Power pin is connected with GND pins of a Buzzer with resistance

Arduino Code

 

//stored pins in variables

#define gasSensor A0
#define buzzer 0
#define ledGreen 1
#define ledRed 2
#define HIGH 600

void setup() {

   //Initialising all pins
   
   pinMode(gasSensor, INPUT);
   pinMode(buzzer, OUTPUT);
   pinMode(ledGreen, OUTPUT);
   pinMode(ledRed, OUTPUT);
  }

void loop() {
  //Read data from the sensor
int gas_value = analogRead(gasSensor);


//check data from sensor if there is smoke, if will execute otherwise else will execute
if(gas_value > HIGH)
{
  tone(buzzer,1000,500);
  digitalWrite(ledRed, HIGH);
  digitalWrite(ledGreen,LOW);
  
  
}
else
{
  noTone(buzzer);
  digitalWrite(ledGreen,HIGH);
  digitalWrite(ledRed, LOW);
}
delay(200);
  
}

When the smoke concentration is greater than the standard value, the MQ2 gas sensor detects that the smoke level is higher than the normal value, the LED red light is on, and the buzzer sounds a warning.

dcbe23cb5ae1460581f93c63df08cc86.png

 When the smoke concentration is lower than the standard value, the MQ2 gas sensor detects that the smoke level is lower than or equal to the normal value, the LED green light is on, and the buzzer does not respond.

49267bb6da684677b141f96c5a71c4df.png

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值