Arduino is used to read the output of the MQ-2 gas sensor and the Flame sensor. If one of the sensors or both reads fire or smoke automatically, the alarm will sound and automatically the relay will be on. The relay is connected to the Electric Valve and then will open the valve to drain the water. For the application can also be added a relay connected to the AC Sirine, so the alarm sound will be firmer / louder.
Hardware Requirement
- Arduino Uno Board
- MQ-2 Gas Sensor
- IR Flame Sensor
- Relay 2 Channel Module
- Buzzer (Or you can AC Alarm)
- Electric Valve (Solenoid Valve)
- LCD 16*2
- Power supply +5 Volt
- Jumper
Alarm / Sirine AC | Source
Block Diagram
Schematic
Arduino - LCD Wiring
Arduino - Sensors Wiring
Arduino - Relays Wiring
Source Code/Sketch
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
float MQ2;
float sensorApi;
int adc;
byte kedip;
byte keluar;
void setup(){
pinMode(8,OUTPUT);
digitalWrite(8,LOW);
pinMode(9,OUTPUT);
digitalWrite(9,LOW);
lcd.begin(16, 2);
lcd.print("Alarm kebakaran ");
delay(2000);
lcd.clear();
lcd.print(" Tunggu sensor");
lcd.setCursor(0, 1);
lcd.print(" siap...");
delay(2000);
do{
adc=(analogRead(A0));
MQ2 = adc * (5.0 / 1023.0);
}
while(MQ2 > 1.5);
lcd.clear();
}
void loop(){
adc=(analogRead(A0));
MQ2 = adc * (5.0 / 1023.0);
adc=(analogRead(A1));
sensorApi = adc * (5.0 / 1023.0);
lcd.setCursor(0,0);
lcd.print("Api :");
lcd.print(sensorApi);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("Asap:");
lcd.print(MQ2);
lcd.print(" ");
if (MQ2 > 1.2 || sensorApi<3){
lcd.setCursor(0,0);
lcd.print(" Ada kebakaran");
lcd.setCursor(0,1);
lcd.print("AlarmON ValveON");
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
delay(1000);
keluar=1;
do{
adc=(analogRead(A0));
MQ2 = adc * (5.0 / 1023.0);
adc=(analogRead(A1));
sensorApi = adc * (5.0 / 1023.0);
if(sensorApi>4 && MQ2<1)keluar=0;
}
while(keluar);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
lcd.clear();
}
delay(100);
}
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
float MQ2;
float sensorApi;
int adc;
byte kedip;
byte keluar;
void setup(){
pinMode(8,OUTPUT);
digitalWrite(8,LOW);
pinMode(9,OUTPUT);
digitalWrite(9,LOW);
lcd.begin(16, 2);
lcd.print("Alarm kebakaran ");
delay(2000);
lcd.clear();
lcd.print(" Tunggu sensor");
lcd.setCursor(0, 1);
lcd.print(" siap...");
delay(2000);
do{
adc=(analogRead(A0));
MQ2 = adc * (5.0 / 1023.0);
}
while(MQ2 > 1.5);
lcd.clear();
}
void loop(){
adc=(analogRead(A0));
MQ2 = adc * (5.0 / 1023.0);
adc=(analogRead(A1));
sensorApi = adc * (5.0 / 1023.0);
lcd.setCursor(0,0);
lcd.print("Api :");
lcd.print(sensorApi);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("Asap:");
lcd.print(MQ2);
lcd.print(" ");
if (MQ2 > 1.2 || sensorApi<3){
lcd.setCursor(0,0);
lcd.print(" Ada kebakaran");
lcd.setCursor(0,1);
lcd.print("AlarmON ValveON");
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
delay(1000);
keluar=1;
do{
adc=(analogRead(A0));
MQ2 = adc * (5.0 / 1023.0);
adc=(analogRead(A1));
sensorApi = adc * (5.0 / 1023.0);
if(sensorApi>4 && MQ2<1)keluar=0;
}
while(keluar);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
lcd.clear();
}
delay(100);
}
How it Works
1. Connect the Arduino with Peripherals needed.
2. Plug in the Power Source on the device.
3. Add some library if needed
4. Compile and upload the script program above to your arduino.
5. First initial LCD display
6. Furthermore, if the sensor is ready then the display on the LCD displays the sensor readings.
No comments:
Post a Comment