The fire alarm is an embedded system that interacts with some sensors and other components and support humans.
Fire alarms work when a temperature sensor feels that the room temperature is not normal and increases from given criteria or a smoke sensor detects that there is too much smoke around the sensor. In both conditions, this device makes a loud sound and warns all the people present there.
Fire alarm is very helpful in large companies, hospitals, underground parking, etc.
Used elements for this project:
1 Arduino Board
1 LED
2 Register
1 Temperature Sensor
1 Gas Sensor
1 Piezo
Cables
Here, we have connected one LED to the Arduino board’s digital pin, which gives a signal of warning. One Piezo is also connected in the digital pin, with two cables connected, one for the digital signal and the other for ground.
A gas sensor have three power supplies whose value is 5V, and two cables go into the ground and one cable goes to the analogue pin.
One temperature sensor’s cable is connected to the 5V power supply, one is to ground, and another one is to the analogue pin.
This is all about connections in a fire alarm. Connect all the connections correctly so that the device works successfully.
Now, go to the source code section and paste it.
float tempC;
float temp;
float vout;
int LED = 13;
int gasSensor;
int piezo = 7;
void setup()
{
pinMode(A0,INPUT);
pinMode(A1, INPUT);
pinMode(LED,OUTPUT);
pinMode(piezo,OUTPUT);
Serial.begin(9600);
}
void loop()
{
temp = analogRead(A1);
vout = (temp / 1023) * 5000;
tempC = (vout - 500) / 10;
gasSensor = analogRead(A0);
if (tempC >= 50)
{
digitalWrite(LED,HIGH);
digitalWrite(piezo,HIGH);
delay(1000);
}
else
{
digitalWrite(LED,LOW);
}
if (gasSensor >= 300)
{
digitalWrite(piezo,HIGH);
}
else
{
digitalWrite(piezo,LOW);
}
Serial.print("Temperature(°C) = ");
Serial.print(" ");
Serial.print(tempC);
Serial.print("\t");
Serial.print("Smoke = ");
Serial.print(" ");
Serial.print(gasSensor);
Serial.println();
delay(1000);
}
Sign in to your account