Full Width CSS

Fire and defense water system for home using Arduino, relay and Gas sensor

Death and property loss due to fire has become a major problem in today's world. There are many fire fighters stations working for this particular problem. When there is fire caught, it always takes time for water tank to reach the destination and we have loss in life and property as well.

So, in this tutorial we are going to make a fire defense system using Arduino, relay and smoke sensor that senses fire and accordingly take action.

Here, we have taken house having two rooms that may be kitchen or living room or office room. In both the rooms we have connected smoke sensor. When there is no fire in the room or smoke, the sensor goes inactive and the led's, ledG1 and ledG2 is on denoting there is no any problem. If ROOM 1 or  ROOM 2 senses smoke or fire then red led's, ledR1 or ledR2 goes on respectively and the water system will be on in order to minimize or wipe out the flame.


(Note: First upload the code to the Arduino board then only do the programming in order to avoid short circuit from the previously uploaded code in the Arduino. Also, connect 0.5k resistor to each led and you can also add buzzer instead of red led bulb.)

  1. Arduino UNO X 1
  2. MQ2 Gas Sensor X 2
  3. 5 Volt Relay X 2
  4. Led red X 2
  5. Led green X 2
  6. Minibbread board X 1
  • Arduino

It is a small micro-controller device where we can program and relate our work with input and output voltage production and sensing.

For more detail you can go to the link below:

  • MQ2 Gas Sensor

Smoke sensor senses the density of gas in certain values and provide output through DOUT or AOUT i.e. digital out and analog out pin to the arduino respectively and accrodingly we take action through programming.

Here we have taken 400 as threshold value of the sensor above which light and defense system work.

  • Relay
Relay is a device that act as a switch for ac or other high source devices. It switches on when IN1 is High and turns off when  IN1 is LOW.


int ledR1 = 12;
int ledR2 = 11;
int ledG1 = 10;
int ledG2 = 9;
int smokeA0 = A0;
int smokeA1 = A1;
int sensorThres = 400;   // sensor threshold vaue

void setup()
  pinMode(ledR1, OUTPUT);
  pinMode(ledR2, OUTPUT);
  pinMode(ledG1, OUTPUT);
  pinMode(ledG2, OUTPUT);
  pinMode(smokeA0, INPUT);
  pinMode(smokeA1, INPUT);
void loop() 
  int analogSensor1 = analogRead(smokeA0);
  if (analogSensor1 > sensorThres)   // Checks if it has reached the threshold value
    digitalWrite(ledR1, HIGH);
    digitalWrite(ledG1, LOW);
    digitalWrite(ledG1, LOW);
    digitalWrite(ledR1, HIGH); 
  int analogSensor2 = analogRead(smokeA1);
  if (analogSensor2 > sensorThres)   // Checks if it has reached the threshold value
    digitalWrite(ledR2, HIGH);
    digitalWrite(ledG2, LOW);
    digitalWrite(ledG2, LOW);
    digitalWrite(ledR2, HIGH);

In this way you can make your own fire alarm and water defense system at home using arduino, MQ2 gas sensor and relay.

  • You can have safe home from fire.
  • Can save your property during fire
  • Less worry about fire fighters to come late.
  • Can make your way to quality and safe life.

Post a Comment