Arduino Based Fire Fighting Robot

Published  December 20, 2017   139
Aswinth Raj
Author
DIY Arduino Based Fire Fighting Robot Project

According to National Crime Records Bureau (NCRB), it is estimated that more than 1.2 lakh deaths have been caused because of fire accidents in India from 2010-2014. Even though there are a lot of precautions taken for Fire accidents, these natural/man-made disasters do occur now and then. In the event of a fire breakout, to rescue people and to put out the fire we are forced to use human resources which are not safe. With the advancement of technology especially in Robotics it is very much possible to replace humans with robots for fighting the fire. This would improve the efficiency of firefighters and would also prevent them from risking human lives. Today we are going to build a Fire Fighting Robot using Arduino, which will automatically sense the fire and start the water pump

In this project, we will learn how to build a simple robot using Arduino that could move towards the fire and pump out water around it to put down the fire. It is a very simple robot that would teach us the underlying concept of robotics; you would be able to build more sophisticated robots once you understand the following basics. So let’s get started...

 

Material Required:

  1. Arduino UNO
  2. Fire sensor or Flame sensor (3 Nos)
  3. Servo Motor (SG90)
  4. L293D motor Driver module
  5. Mini DC Submersible Pump
  6. Small Breadboard
  7. Robot chassis with motors (2) and wheels(2) (any type)
  8. A small can
  9. Connecting wires

Buy all the above required components for Arduino fire fighting robot.

Working Concept of Fire Fighting Robot:

The main brain of this project is the Arduino, but in-order to sense fire we use the Fire sensor module (flame sensor) that is shown below.

Fire or flame sensor module

As you can see these sensors have an IR Receiver (Photodiode) which is used to detect the fire. How is this possible? When fire burns it emits a small amount of Infra-red light, this light will be received by the IR receiver on the sensor module. Then we use an Op-Amp to check for change in voltage across the IR Receiver, so that if a fire is detected the output  pin (DO) will give 0V(LOW) and if the is no fire the output pin will be 5V(HIGH).

So, we place three such sensors in three directions of the robot to sense on which direction the fire is burning.

Flame sensor setup on fire fighting robot chasis

We detect the direction of the fire we can use the motors to move near the fire by driving our motors through the L293D module. When near a fire we have to put it out using water. Using a small container we can carry water, a 5V pump is also placed in the container and the whole container is placed on top of a servo motor so that we can control the direction in which the water has to be sprayed. Let’s proceed with the connections now

 

Circuit Diagram:

The complete circuit diagram for this Fire Fighting Robot is given below

DIY Arduino based Fire Fighting Robot circuit diagram

You can either connect all the shown connections for uploading the program to check the working or you can assemble the bot completely and then proceed with the connections. Both ways the connections are very simple and you should be able to get it right.

Based on the robotic chassis that you are using you might not be able to use the same type of container that I am using. In that case use your own creativity to set up the pumping system. However the code will remain same. I used a small aluminium can (cool drinks can) to set the pump inside it and poured water inside it. I then assembled the whole can on top of a servo motor to control the direction of water. My robot looks something like this after assembly.

DIY Arduino based Fire Fighting Robot Hardware setup

Water tank with water pump motor for fire fighting robot Attaching servo motor for water direction control

As you can see, I have fixed the servo fin to the bottom of the container using got glue and have fixed the servo motor with chassis using nuts and bolts.  We can simply place the container on top of the motor and trigger the pump inside it to pump water outside through the tube. The whole container can then be rotated using the servo to control the direction of the water.

 

Programming your Arduino:

Once you are ready with your hardware, you can upload the Arduino code for some action. The complete program is given at the end of this page. However I have further explained few important bits and pieces here.

 As we know the fire sensor will output a HIGH when there is fire and will output a LOW when there is fire. So we have to keep checking these sensor if any fire has occurred. If no fire is there we ask the motors to remain stop by making all the pins high as shown below

    if (digitalRead(Left_S) ==1 && digitalRead(Right_S)==1 && digitalRead(Forward_S) ==1) //If Fire not detected all sensors are zero
    {
    //Do not move the robot
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, HIGH);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, HIGH);
    }

 

Similarly, if there is any fire we can ask the robot to move in that direction by rotating the respective motor. Once it reaches the fire the left and right sensor will not detect the fire as it would be standing straight ahead of the fire. Now we use the variable named “fire” that would execute the function to put off the fire.

    else if (digitalRead(Forward_S) ==0) //If Fire is straight ahead
    {
    //Move the robot forward
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);
    fire = true;
    }

 

Once the variable fire becomes true, the fire fighting robot arduino code will execute the put_off_fire function until the fire is put off. This is done using the code below.

     while (fire == true)
     {
      put_off_fire();
     }

   

Inside the put_off_fire() we just have to stop the robot by making all the pins high. Then turn on the pump to push water outside the container, while this is done we can also use the servo motor to rotate the container so that the water is split all over uniformly. This is done using the code below

void put_off_fire()
{
     delay (500);
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, HIGH);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, HIGH);  
   digitalWrite(pump, HIGH); delay(500);
    for (pos = 50; pos <= 130; pos += 1) {
    myservo.write(pos);
    delay(10); 
  }
 for (pos = 130; pos >= 50; pos -= 1) {
    myservo.write(pos);
    delay(10);
  }
  digitalWrite(pump,LOW);
  myservo.write(90);
    fire=false;
}

 

Working of Fire Fighting Robot:

It is recommended to check the output of the robot in steps rather than running it all together for the first time. You can build the robot upto the servo motor and check if it is able to follow the fire successfully. Then you can check if the pump and the servo motor are working properly. Once everything is working as expected you can run the program below and enjoy the complete working of the fire fighter robot.

DIY Arduino based Fire Fighting Robot working

The complete working of the robot can be found at the video given below. The maximum distance to which the fire can be detected depends on the size of the fire, for a small matchstick the distance is relatively less. You can also use the potentiometers on top of the modules to control the sensitivity of the robot. I have used a power bank to power the robot you can use a battery or even power it with a 12V battery.

 

Hope you understood the project and would enjoy building something similar. If you have any problems in getting this build, use the comment section below to post your quires or use the forums for technical help.

 

Check out our Robotics Section to find more cool DIY Robots.

Code
/*------ Arduino Fire Fighting Robot Code----- */
 
#include <Servo.h>
Servo myservo;
 
int pos = 0;    
boolean fire = false;
 
/*-------defining Inputs------*/
#define Left_S 9      // left sensor
#define Right_S 10      // right sensor
#define Forward_S 8 //forward sensor
 
/*-------defining Outputs------*/
#define LM1 2       // left motor
#define LM2 3       // left motor
#define RM1 4       // right motor
#define RM2 5       // right motor
#define pump 6
 
void setup()
{
  pinMode(Left_S, INPUT);
  pinMode(Right_S, INPUT);
  pinMode(Forward_S, INPUT);
  pinMode(LM1, OUTPUT);
  pinMode(LM2, OUTPUT);
  pinMode(RM1, OUTPUT);
  pinMode(RM2, OUTPUT);
  pinMode(pump, OUTPUT);
 
  myservo.attach(11);
  myservo.write(90); 
}
 
void put_off_fire()
{
    delay (500);
 
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, HIGH);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, HIGH);
    
   digitalWrite(pump, HIGH); delay(500);
    
    for (pos = 50; pos <= 130; pos += 1) { 
    myservo.write(pos); 
    delay(10);  
  }
  for (pos = 130; pos >= 50; pos -= 1) { 
    myservo.write(pos); 
    delay(10);
  }
  
  digitalWrite(pump,LOW);
  myservo.write(90);
  
  fire=false;
}
 
void loop()
{
   myservo.write(90); //Sweep_Servo();  
 
    if (digitalRead(Left_S) ==1 && digitalRead(Right_S)==1 && digitalRead(Forward_S) ==1) //If Fire not detected all sensors are zero
    {
    //Do not move the robot
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, HIGH);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, HIGH);
    }
    
    else if (digitalRead(Forward_S) ==0) //If Fire is straight ahead
    {
    //Move the robot forward
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);
    fire = true;
    }
    
    else if (digitalRead(Left_S) ==0) //If Fire is to the left
    {
    //Move the robot left
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, HIGH);
    }
    
    else if (digitalRead(Right_S) ==0) //If Fire is to the right
    {
    //Move the robot right
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, HIGH);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);
    }
    
delay(300); //Slow down the speed of robot
 
     while (fire == true)
     {
      put_off_fire();
     }
}
Video

Have any question realated to this Article?

Ask Our Community Members

Comments

Submitted by EJ on Tue, 04/24/2018 - 08:08

Permalink

Hi, is there anybody else that knows what is the correct L293D motor driver module to buy. I want the same exact one that is shown in the project.If you do, do you know where I can buy it ? Please respond to me as soon as possible.

Submitted by Mudasir Jamil on Tue, 04/24/2018 - 14:31

Permalink

Hi, thanks for the response
I have eliminated the previous issue
Now situation is like this
Robot is moving and stopping for a couple of seconds
Pump is working when wheels stops and synchronous motor is rotating according to pump
But the issue i am facing is :
It looks like arduino is giving command to pump.to spray water irrespective of flame sensor
I have disconnected the flame sensor still it is working the same
Can you kindly go through or match the code with ur working code so that if there is a bracket missing or something else, kindly guide me
Thanks

Submitted by Michael on Fri, 04/27/2018 - 21:45

Permalink

If i change l293d to l298n ..did have the same function ?

Hi Everyone,

I need help to get the right code to make the robot work properly. have used below code but is not working. what should I delete or add to below code?

/*------ Arduino Fire Fighting Robot Code----- */

 

#include <Servo.h>

Servo myservo;

 

int pos = 0;   

boolean fire = false;

 

/*-------defining Inputs------*/

#define Left_S 9      // left sensor

#define Right_S 10      // right sensor

#define Forward_S 8 //forward sensor

 

/*-------defining Outputs------*/

#define LM1 2       // left motor

#define LM2 3       // left motor

#define RM1 4       // right motor

#define RM2 5       // right motor

#define pump 6

 

void setup()

{

  pinMode(Left_S, INPUT);

  pinMode(Right_S, INPUT);

  pinMode(Forward_S, INPUT);

  pinMode(LM1, OUTPUT);

  pinMode(LM2, OUTPUT);

  pinMode(RM1, OUTPUT);

  pinMode(RM2, OUTPUT);

  pinMode(pump, OUTPUT);

 

  myservo.attach(11);

  myservo.write(90);

}

 

void put_off_fire()

{

    delay (500);

 

    digitalWrite(LM1, HIGH);

    digitalWrite(LM2, HIGH);

    digitalWrite(RM1, HIGH);

    digitalWrite(RM2, HIGH);

   

   digitalWrite(pump, HIGH); delay(500);

   

    for (pos = 50; pos <= 130; pos += 1) {

    myservo.write(pos);

    delay(10); 

  }

  for (pos = 130; pos >= 50; pos -= 1) {

    myservo.write(pos);

    delay(10);

  }

 

  digitalWrite(pump,LOW);

  myservo.write(90);

 

  fire=false;

}

 

void loop()

{

   myservo.write(90); //Sweep_Servo(); 

 

    if (digitalRead(Left_S) ==1 && digitalRead(Right_S)==1 && digitalRead(Forward_S) ==1) //If Fire not detected all sensors are zero

    {

    //Do not move the robot

    digitalWrite(LM1, HIGH);

    digitalWrite(LM2, HIGH);

    digitalWrite(RM1, HIGH);

    digitalWrite(RM2, HIGH);

    }

   

    else if (digitalRead(Forward_S) ==0) //If Fire is straight ahead

    {

    //Move the robot forward

    digitalWrite(LM1, HIGH);

    digitalWrite(LM2, LOW);

    digitalWrite(RM1, HIGH);

    digitalWrite(RM2, LOW);

    fire = true;

    }

   

    else if (digitalRead(Left_S) ==0) //If Fire is to the left

    {

    //Move the robot left

    digitalWrite(LM1, HIGH);

    digitalWrite(LM2, LOW);

    digitalWrite(RM1, HIGH);

    digitalWrite(RM2, HIGH);

    }

   

    else if (digitalRead(Right_S) ==0) //If Fire is to the right

    {

    //Move the robot right

    digitalWrite(LM1, HIGH);

    digitalWrite(LM2, HIGH);

    digitalWrite(RM1, HIGH);

    digitalWrite(RM2, LOW);

    }

   

delay(300); //Slow down the speed of robot

 

     while (fire == true)

     {

      put_off_fire();

     }

}

 

I am not using water pump ...only wants the robot to follow fire when sensor detects fire please anybody can help the project is due this Monday 30th

Submitted by Vikky on Sat, 05/05/2018 - 01:58

Permalink

When it detect flame, servo motor works but due to high current capacity of pump it does not work with arduino .. plz help me to run it ... Rest is working fine..

Submitted by Muhammad Riaz on Fri, 05/11/2018 - 15:16

Permalink

kindly sir, can you tell me, how you learn about the codding, which is used in this project, and which software is use for this codding.

Submitted by andicahyo on Tue, 05/29/2018 - 14:12

Permalink

ok sir thankyou for the answer, the trouble is on the sensor, sensor right and left same model, but sensor forward is different. sensor forward when read fire the output 5v but sensor right and left when read fire = 0v hmmm...so i modified the program...and the robot now can working

Submitted by Mudasir Jamil on Tue, 06/26/2018 - 19:53

Permalink

I used a 5 channel flame sensor module, but it is highliy senstivie. It sends the signal to arduino (fire detected:spray water) in a normal place like having temperature greater than 30(outdoor). Can any one help me how to overcome this issue

The sensor does not react to heat, it reads to IR light. So if you are operating the bot in a place sunlight is high then the sensor by get false triggered.

If you want to reduce the sensitivity then check of there is a pot on the sensor module,if yes vary it else try using analog read if the sensor supports it  

Submitted by Hsai on Thu, 07/12/2018 - 11:43

Permalink

Hi Sir,
Can i get the correct code and connection, please help me!!

Submitted by Faraz Ahmed on Mon, 07/30/2018 - 16:15

Permalink

i just want to run a water pump when sensor detect the fire what is the coding for that. i code by my self but when sensor detect the fire pump was not active but than i use led instead of pump led was on when sensor detect the fire.How the pump is going to work plz any one help.Thanks

Submitted by Hsai on Mon, 08/13/2018 - 20:27

Permalink

Hi sir!
Can I get the correct code? It is not work like you do.

Submitted by Prakhar Dudani on Mon, 08/20/2018 - 23:47

Permalink

I have used a 9 volt water pump but it is not working please help me in this matter as soon as possible.

Submitted by jake on Sun, 09/02/2018 - 23:16

Permalink

can I connect a motor with a fan other than a water pumping motor pls helps me guys ASAP

thank you very much for providing such important information but i am facing a problem that when i compile the code i get a compilation error in the first line 

    which is expected unqualified-id.kindly guide me about it.

 

thank you for sharing .the robot works when the supplied connections are made, but the 5v water pump does not work . I would appreciate if you could help me with this.

Hello OP. I need some advice and insight related to this project. Is it possible to connect four of these sensors in parallel with two servos and get them to perform a Top-right, bottom-right, top-left and bottom-left motion? And how will this affect the original code if it were to be implemented. A quick reply would be deeply appreciated

What should I do if water pump is not working when connected to 6 number pin of arduino.but it is working when it is connected between +5V and ground. I guess the pump is not receiving enough voltage when connected to arduino.Is there any solution to solve this problem. Please reply as soon as possible.

Hey admin!!
I have done all the connections correctly but my robot is only to its left and the wheels are also moving in the opposite direction.. servo motor is also not working.. i have not tested the water pump yet I will test that after these issues are solved

Looking forward to your assistance 
thanks