Skip to content

Latest commit

ย 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš’ FireFighter Robot Car

LangMastero Logo

An autonomous fire-fighting robot car built with ESP32, featuring automatic flame detection, tracking, and extinguishing capabilities with manual override control via WiFi. This smart robot car mainly automatically finds and fights fires using flame sensors and a water pump system until it doesn't detect any fire around it.

Demo


๐Ÿ”ฅ Overview

This project is an ESP32-based autonomous firefighter robot car that can detect, track, and extinguish flames. It features both automatic and manual control modes accessible through a responsive web interface. The robot uses flame sensors for fire detection, a servo-mounted water pump for extinguishing, and a dual-motor drive system for navigation.


โœจ Features

  • ๐Ÿค– Autonomous Fire Detection: Three flame sensors (left, center, right) for 180ยฐ fire detection
  • ๐ŸŽฏ Smart Tracking: Automatically rotates and moves toward detected flames
  • ๐Ÿ’ง Servo-Controlled Water Spray: Sweeping water spray pattern for effective fire suppression
  • ๐Ÿ“ฑ WiFi Web Interface: Control the robot from any device connected to its WiFi network
  • ๐Ÿ”„ Dual Mode Operation:
    • AUTO Mode: Autonomous fire detection and extinguishing
    • MANUAL Mode: Full directional control via web interface
  • ๐ŸŽฎ Responsive Controls: Real-time button controls with visual feedback
  • โšก PWM Motor Control: Smooth speed control for precise movements

๐Ÿ› ๏ธ Components Required

Electronics

Component Quantity Description
ESP32 Development Board 1 Main microcontroller
L298N Motor Driver 1 Dual H-Bridge for motor control
DC Motors (with wheels) 4 For robot movement
Flame Sensors 3 KY-026 or similar IR flame sensors
SG90 Servo Motor 1 For water nozzle direction control
Mini Water Pump 1 3-6V DC submersible pump
5V Relay Module 1 To control water pump
BC547 NPN Transistor 1 For relay switching
1kฮฉ Resistor 1 Base resistor for transistor
18650 Batteries 2-3 Power supply (7.4V or 11.1V)
Battery Holder 1 For batteries
Jumper Wires - Male-to-male and male-to-female

Optional

  • Small water container/tank
  • Plastic tubing for water delivery
  • Switch for main power
  • LED indicators

๐Ÿ”Œ Circuit Connections

1. L298N Motor Driver to ESP32

L298N Pin ESP32 Pin Description
ENA GPIO 25 Left motor speed (PWM)
IN1 GPIO 26 Left motor direction 1
IN2 GPIO 27 Left motor direction 2
ENB GPIO 14 Right motor speed (PWM)
IN3 GPIO 18 Right motor direction 1
IN4 GPIO 13 Right motor direction 2
12V/VCC Battery + Motor power supply
GND Battery - & ESP32 GND Common ground

Note: Remove jumpers on ENA and ENB for PWM speed control.

2. Flame Sensors to ESP32

Sensor Position ESP32 Pin Connection
Left Flame Sensor GPIO 34 Digital OUT โ†’ GPIO 34
Center Flame Sensor GPIO 35 Digital OUT โ†’ GPIO 35
Right Flame Sensor GPIO 32 Digital OUT โ†’ GPIO 32
VCC (all sensors) 3.3V Power
GND (all sensors) GND Ground

Sensor Logic: Output = LOW when flame detected, HIGH when no flame.

3. Servo Motor Connection

Servo Wire ESP32 Pin Description
Signal (Orange/Yellow) GPIO 33 PWM control signal
VCC (Red) 5V Power (can use external 5V if needed)
GND (Brown/Black) GND Ground

4. Water Pump with Relay & BC547 Transistor

This circuit uses a BC547 NPN transistor to safely switch the relay from the ESP32:

ESP32 GPIO 23 โ†’ 1kฮฉ Resistor โ†’ BC547 Base (Middle pin)
BC547 Emitter (Left pin) โ†’ GND
BC547 Collector (Right pin) โ†’ Relay IN pin

Relay Module:
โ”œโ”€ VCC โ†’ 5V
โ”œโ”€ GND โ†’ GND
โ”œโ”€ IN โ†’ BC547 Collector
โ”œโ”€ COM โ†’ Pump VCC (+)
โ””โ”€ NO โ†’ Battery/Power Supply (+)

Water Pump:
โ”œโ”€ Positive โ†’ Relay COM
โ””โ”€ Negative โ†’ Battery GND

Why use BC547?

  • ESP32 GPIO pins output only 3.3V with limited current (~40mA)
  • Relay coils typically need 5V and more current
  • BC547 acts as a switch, allowing ESP32 to control the relay safely

๐Ÿ“ Pin Configuration

/* MOTOR PINS (L298N) */
#define ENA 25         // Left motor speed
#define IN1 26         // Left motor direction
#define IN2 27         // Left motor direction
#define ENB 14         // Right motor speed
#define IN3 18         // Right motor direction
#define IN4 13         // Right motor direction

/* SERVO */
#define SERVO_PIN 33   // Water nozzle servo

/* FLAME SENSORS */
#define FLAME_LEFT 34     // Left flame sensor
#define FLAME_CENTER 35   // Center flame sensor
#define FLAME_RIGHT 32    // Right flame sensor

/* RELAY / PUMP */
#define PUMP_RELAY 23  // Pump control via transistor

๐Ÿ“ธ Gallery

image


โš™๏ธ How It Works

AUTO Mode Operation

  1. Fire Detection: The robot continuously monitors all three flame sensors
  2. Target Acquisition:
    • If center sensor detects fire โ†’ Move forward toward flame
    • If left sensor detects fire โ†’ Rotate right until center sensor locks on
    • If right sensor detects fire โ†’ Rotate left until center sensor locks on
  3. Approach: Robot moves closer to the fire for 0.6 seconds
  4. Verification: Double-checks if fire is still detected by center sensor
  5. Extinguish: Executes spray cycle:
    • Activates water pump
    • Servo sweeps from 70ยฐ to 110ยฐ and back (covering the fire area)
    • Pump turns off after spray cycle
  6. Repeat: Returns to scanning mode

MANUAL Mode Operation

  • User has full control via web interface
  • Directional buttons: Forward, Backward, Left, Right
  • Manual water pump control (hold to spray)
  • Stop button for emergency halt

Web Interface

  • WiFi Access Point: Robot creates "FireFighter_Bot" network (password: 12345678)
  • Control Panel: Responsive web interface accessible at http://192.168.4.1
  • Features: Mode toggle, directional controls, pump control

๐Ÿ“ฅ Installation & Setup

1. Arduino IDE Setup

Install required libraries:

- ESP32 Board Support
- ESP32Servo library

Steps:

  1. Open Arduino IDE
  2. Go to File โ†’ Preferences
  3. Add ESP32 board URL: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
  4. Go to Tools โ†’ Board โ†’ Boards Manager, search "ESP32" and install
  5. Install ESP32Servo library: Sketch โ†’ Include Library โ†’ Manage Libraries โ†’ Search "ESP32Servo"

2. Upload Code

  1. Connect ESP32 to computer via USB
  2. Select board: Tools โ†’ Board โ†’ ESP32 Dev Module
  3. Select correct COM port: Tools โ†’ Port
  4. Click Upload button

3. Hardware Assembly

  1. Mount motors and motor driver on chassis
  2. Connect all components according to circuit diagram
  3. Secure ESP32, sensors, and relay module
  4. Mount servo with water nozzle at front
  5. Attach water container and connect tubing to pump
  6. Connect battery (ensure proper voltage: 7.4V-11.1V)

๐ŸŽฎ Usage

Connecting to Robot

  1. Power on the robot
  2. Wait for ESP32 to boot (~5 seconds)
  3. On your phone/laptop, connect to WiFi:
    • SSID: FireFighter_Bot
    • Password: 12345678
  4. Open browser and go to: http://192.168.4.1

Web Interface Controls

Mode Selection:

  • AUTO: Robot autonomously detects and fights fires
  • MANUAL: User controls all movements

Manual Controls:

  • โ–ฒ Forward
  • โ–ผ Backward
  • โ—„ Turn Left
  • โ–บ Turn Right
  • โ–  Stop
  • HOLD FOR WATER ๐Ÿ’ง: Press and hold to activate pump

Testing

  1. Start in MANUAL mode to test motors and pump
  2. Switch to AUTO mode
  3. Use a lighter or candle to test flame detection
  4. Observe robot's tracking and extinguishing behavior

๐Ÿ“‚ Code Structure

/* Main Sections */
โ”œโ”€ WiFi & WebServer Setup
โ”œโ”€ Pin Definitions
โ”œโ”€ Global Variables (mode, speeds)
โ”œโ”€ setup() - Initialize all components
โ”œโ”€ loop() - Main logic
โ”‚   โ”œโ”€ Auto mode: Flame detection & response
โ”‚   โ””โ”€ Manual mode: Web command processing
โ”œโ”€ executeSprayCycle() - Water spray pattern
โ”œโ”€ Motor Control Functions
โ”‚   โ”œโ”€ moveForward()
โ”‚   โ”œโ”€ moveBackward()
โ”‚   โ”œโ”€ turnLeft()
โ”‚   โ”œโ”€ turnRight()
โ”‚   โ””โ”€ stopMoving()
โ””โ”€ handleRoot() - Web interface HTML/CSS

๐Ÿ”ง Troubleshooting

Problem Possible Solution
Motors don't move โ€ข Check L298N connections
โ€ข Ensure battery is charged
โ€ข Verify ENA/ENB jumpers are removed
โ€ข Check motor polarity
Wrong direction Swap IN1โ†”IN2 or IN3โ†”IN4 connections, or modify LEFT_FORWARD_LOGIC and RIGHT_FORWARD_LOGIC constants in code
Pump doesn't activate โ€ข Check relay connections
โ€ข Verify BC547 transistor orientation
โ€ข Test relay with multimeter
โ€ข Check pump power supply
Flame sensors not detecting โ€ข Adjust sensor sensitivity (potentiometer on sensor)
โ€ข Check 3.3V power supply
โ€ข Test sensors individually with Serial monitor
Can't connect to WiFi โ€ข Reset ESP32
โ€ข Check WiFi credentials in code
โ€ข Ensure device WiFi is enabled
Servo jitters โ€ข Use external 5V power source for servo
โ€ข Add capacitor across servo power lines
Robot moves too fast/slow Adjust motorSpeed and turnSpeed variables (0-255 range)

๐Ÿš€ Future Improvements

  • Add temperature sensor for heat detection
  • Implement obstacle avoidance with ultrasonic sensors
  • Battery level monitoring and low battery warning
  • Add buzzer for audio alerts
  • Implement camera streaming for remote monitoring
  • Add GPS module for location tracking
  • Create mobile app for better control interface
  • Multiple pump nozzles for wider coverage
  • Data logging to SD card
  • Integration with IoT platforms (Firebase, Blynk)

๐Ÿ“ License

This project is open-source and available under the MIT License.


๐Ÿ‘จโ€๐Ÿ’ป Author

  • Mehedi Hasan
  • Farhana Alam

โญ If you found this project helpful, please give it a star! โญ

About

An autonomous fire-fighting robot car built with ESP32 for Microcontroller Lab Course, featuring automatic flame detection, tracking, and extinguishing capabilities with manual override control via WiFi.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages