Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
ayanfeoluwaadekanye1
Published © GPL3+

Fire and Smoke Alarm

This is an updated version of the fire alarm I made. it includes a gas sensor and an app for control

BeginnerShowcase (no instructions)19,173
Fire and Smoke Alarm

Things used in this project

Hardware components

5 mm LED: Red
5 mm LED: Red
×1
5 mm LED: Green
5 mm LED: Green
×1
Buzzer
Buzzer
×2
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Resistor 221 ohm
Resistor 221 ohm
×2
Grove - Gas Sensor(MQ2)
Seeed Studio Grove - Gas Sensor(MQ2)
×1
IR receiver (generic)
×1
Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 1k ohm
Resistor 1k ohm
×3

Software apps and online services

Arduino IDE
Arduino IDE
MIT App Inventor 2
MIT App Inventor 2

Story

Read more

Custom parts and enclosures

The apk

Schematics

The Circuit

I couldn't find a MQ 2 fritzing diagram so i used a MQ 9 instead which has a similar pin out. Don't forget to disconnect the Rx and TX pins from the Bluetooth module before uploading your code else you will have issues uploading your code

Code

The Code

Arduino
#define flamePin A0
#define gasPin A1
#define buzzer1 10
#define buzzer2 9
#define greenLed 2
#define redLed 3
int flameVal;
int gasVal;
int btSwitch=49;
unsigned long curTime;
void(* resetFunc) (void) = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(buzzer1, OUTPUT);
  pinMode(buzzer2, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(redLed, OUTPUT);
  curTime=millis();
}

void loop() {
    // put your main code here, to run repeatedly:
   if(Serial.available() > 0){ // Checks whether data is comming from the serial port
      btSwitch = Serial.read(); // Reads the data from the serial port
   }
   if(btSwitch=='1'){digitalWrite(greenLed,HIGH);digitalWrite(redLed,LOW);}
   else if(btSwitch=='0'){digitalWrite(redLed,HIGH);digitalWrite(greenLed,LOW);}
   else if(btSwitch=='2'){resetFunc();}
   
   flameVal=analogRead(flamePin);
   gasVal=analogRead(gasPin);
   
   if (flameVal<1000 && gasVal>159 && btSwitch=='1'){
     buzzerCall();
   }
   else if(gasVal>159 && btSwitch=='1'){
     buzzerCall();
   }
}

void buzzerCall(){
    digitalWrite(greenLed,LOW);
    digitalWrite(redLed,HIGH);
    tone(buzzer1, 5000);
    delay(1000);
    noTone(buzzer1);
    tone(buzzer2, 1000);
    digitalWrite(redLed,LOW);
    delay(1000);
    noTone(buzzer2);
 }

Credits

ayanfeoluwaadekanye1
0 projects • 8 followers
Contact

Comments

Please log in or sign up to comment.