Get in Touch
Back to Projects

·10 min read

Quench: An Autonomous Robot That Finds a Fire, Makes Sure, and Puts It Out with Little Water

An Arduino UNO, three flame sensors, a pump and an Android app I wrote myself. Quench doesn't move until it sees a flame; then it aims with its wheels, stops to make sure, and puts the fire out in short bursts. How it got here from a first version that emptied water onto the table with no fire in sight.

Tags:arduinoroboticsembeddedandroidbluetooth
Mission 05 · SMT-22In progress· v4.1 · final stretchLast updated: My role: Design, hardware, robot firmware and the Android appSee it in SMT-22 ↗

Root cause

Finding a Bluetooth dropout in 60 fps video

The link dropped every time the robot sprayed. Stepping through the video frame by frame showed the HC-06's LED going dark on the very frame the relay clicked: it wasn't the link failing, it was the module's power.

Relay click at 4.45 s · LED dark at 4.47 s · Arduino keeps running

Fix: a separate battery for the pump + a 1N5819 diode and 1000 µF buffer on the HC-06.

Mission specs

Brain
Arduino UNO · single file, no extra libraries · 75% flash, 52% RAM
Sensing
3 flame sensors (left, centre, right) · 1,000 reads a second → % density and NONE/FAR/MID/NEAR
Extinguishing
Relay-driven 3–6 V pump, servo-mounted hose · 0.5 s bursts, at most 4 per flame
Drive
4 mecanum wheels, left/right side drive on an L298N · the wheels do the aiming
Control
HC-06 Bluetooth · my own Android app and line protocol
Status
I2C 2x16 LCD · water level (sensor + estimate) · 5 V supply monitoring

Mission log

Every change to the project is logged here with its date, newest first.

  1. Site

    Project page published: photos of the robot, version history, the state machine, simulation results and the Bluetooth diagnosis. The robot is nearly finished.

  2. Hardware

    Root cause of the Bluetooth dropouts found: in 60 fps video the HC-06's LED goes dark on the frame the relay clicks while the Arduino keeps running. Separate battery for the pump and a 1N5819 + 1000 µF buffered supply for the HC-06; no code changes.

  3. Autonomy

    The robot doesn't move until it sees a flame (WATCH). Fixed hose, aimed with the wheels; multiple flames, turning in place to find one that left its view, short 0.5 s bursts and a water-level estimate from pump run time. App v3.2.

  4. Safety

    Fixed the robot spraying with no fire: it always boots into STANDBY, decides only while the motors are still, discards readings taken while 5 V sags, and confirms for 0.7 s before spraying. Flame proximity from 1,000 reads a second, a Dry test mode, and a new app (Control / Display / Logs).

Image records

The robot

Next steps

  • Verify the separate-battery pump fix in the field (LED check and the p test)
  • Flame distance in centimetres with analog-output sensors

Technical report

Architecture, hardware and software in detail.

Introduction: putting out a fire is easy, not spraying when there isn't one is hard

A robot that sprays water when it sees a flame takes an afternoon with a flame sensor, a relay and a pump. The hard part is making sure it doesn't spray when there is no fire, stops when Bluetooth drops, and doesn't soak the same flame for no reason. Quench (called ALEV-1 on the SMT-22 station) grew up solving exactly those problems.

The robot isn't finished yet, but it's in the final stretch. After four versions and one hardware fix, this is how it works today: in autonomous mode it waits where it is; when one of its three flame sensors sees a flame, it turns the hose toward it with its wheels, approaches, stops to confirm the flame is real, and runs the pump in short bursts. Once the fire is out it moves on to the next flame, if there is one.


🔧 Hardware

PartJob
Arduino UNOAll decision logic; a single .ino file, no extra libraries
L298N + 4 motors, mecanum wheelsLeft and right sides driven separately; turning and aiming
3 × flame sensor (LM393, DO)LEFT ~20° to the left, CENTRE straight ahead, RIGHT ~20° to the right
Servo + hoseHolds the hose; fixed in autonomous mode, moves only in manual
Relay + 3–6 V pumpSprays the water
HC-06 BluetoothTalks to the phone (9600 baud)
I2C 2x16 LCDMode, water level, flame proximity, 5 V
Water level sensorNear the top of the tank; powered only while measuring
2 × 18650 (7.4 V)Main battery; 5 V split across two separate rails

The firmware fits the Arduino UNO without warnings: 75% flash, 52% RAM. The servo signal comes from the Timer1 hardware and flame sampling runs on Timer2; the LCD driver is built into the file, and strings live in flash rather than RAM.


🔥 Getting proximity out of a sensor that only says yes or no

The flame sensors I use only have a digital output: the comparator on the board outputs 1 when infrared light crosses a threshold set by a trimpot, and 0 otherwise. A single reading really only says "flame" or "no flame".

But flames flicker. A distant flame crosses the threshold now and then; a close one crosses it all the time. So the code reads each sensor 1,000 times a second and works out what percentage of the last half second said "flame": roughly 20–60% for a distant flame, 90–100% for a close one. The CENTRE sensor's trimpot is deliberately set less sensitive (~25 cm), so a high CENTRE reading means "I'm within spraying distance". That gives a NONE / FAR / MID / NEAR indicator, shown on the LCD and on the radar panel in the app.


🧠 The state machine

All of the robot's behaviour is an explicit state machine. It always boots into STANDBY; autonomous mode can only be started from the app.

                 AUTONOMOUS from the app (3 s countdown)
   ┌─────────┐  ─────────────────────────────▶  ┌──────────┐
   │ STANDBY │                                  │  WATCH   │  robot and servo still
   └─────────┘  ◀── E-STOP / STANDBY (anywhere) └────┬─────┘
                                                     │ a sensor ≥ 25% on 2 looks
                                                     ▼
   ┌────────┐  flame lost                       ┌──────────┐
   │ SEARCH │ ◀──────────────────────────────── │ APPROACH │  aims with the wheels, LEFT vs RIGHT
   └───┬────┘ ────────────────────────────────▶ └────┬─────┘
       │       flame found                           │ CENTRE ≥ 60%
       │                                             ▼
       │                                       ┌───────────┐
       │                                       │  CONFIRM  │  0.7 s, 75% of readings
       │                                       └────┬──────┘
       │                                            ▼
       │      ┌────────┐   flame < 25%         ┌────────────┐  not out after 4 tries
       └───── │  OUT   │ ◀──────────────────── │ EXTINGUISH │ ─────────────▶ ALARM
  remembered  └────────┘                       └────────────┘
  flame left                                    0.5 s water + 0.8 s check
  • WATCH: wheels and servo stay still, and the robot checks its sensors every 0.3 s. It does nothing until it sees a flame.
  • APPROACH: the hose is fixed, so the wheels do the aiming. LEFT and RIGHT percentages are compared; if they differ a lot the robot turns that way, otherwise it steps forward. If CENTRE sees nothing but both sides see a strong flame, there are two separate flames: rather than driving between them, the robot turns to one and remembers where the other was (up to 4).
  • CONFIRM: the last gate against false alarms. The robot stops and checks, for 0.7 s, whether CENTRE ≥ 60% and LEFT ≈ RIGHT in 75% of readings. If LEFT and RIGHT disagree, the flame isn't dead ahead, so it nudges a few degrees using the wheels on one side.
  • EXTINGUISH: 0.5 s of water, then a 0.8 s check with the pump off. If the flame is still there, the robot realigns or turns the hose slightly left, then right, with its wheels and tries again. At most 4 bursts per flame (2 s of water in total).
  • OUT → next flame: after 2 s it looks again. If another sensor sees a flame it goes for it; if not but it remembers one, it turns slowly on the spot in that direction (80 ms turn, 0.3 s look). If a full turn finds nothing, it goes back to WATCH.

💧 "Why did it empty water onto the table with no fire?"

This was the most annoying bug in the early versions. The cause was in the power wiring, and the software made it worse:

  1. When the pump or motors started, the Arduino's 5 V rail sagged for a moment.
  2. While it sagged, the flame sensors' comparators all output "1" at once: the infamous "all ones" in the Serial Monitor.
  3. When the voltage dropped further the Arduino reset, the old code booted straight into autonomous mode, mistook the noise for fire and sprayed for 8 seconds at a time.

In v3 every link in that chain was broken separately:

  • Safe boot: the robot always starts in STANDBY. Even if the power dips and the Arduino resets, it doesn't move or spray on its own, and the app gets a "robot restarted" warning.
  • Stop, look, go: decisions are made only from readings taken while the motors, pump and servo are still.
  • 5 V monitoring: the Arduino's supply is measured continuously against its internal reference, and readings taken while it fluctuates are thrown away. If 5 V sags by more than 14% for longer than 0.25 s while the pump runs, the pump is cut.
  • Confirm, then spray briefly: 0.7 s of confirmation before any water, and short bursts instead of long ones.
  • Dry test: a pump-off mode for trying autonomous mode without soaking the table.

📡 Finding a Bluetooth dropout in video (v4.1)

With the software fixed, one problem remained: Bluetooth dropped whenever the robot sprayed. The app only reported it a few seconds later, so the dropout seemed to happen "after the spray".

The answer was in a video. Stepping through 60 fps footage frame by frame:

  • The relay click is at 4.45 s in the audio and the HC-06's LED goes dark at 4.47 s: on the very frame the relay pulls in.
  • The LED stays dark while the pump runs, then starts blinking fast once the pump stops: the module has rebooted and lost the phone.
  • The Arduino keeps running; its restart counter doesn't change.

So it wasn't the link failing, it was the HC-06's power. The pump shared the robot's battery and ground, so its inrush current and brush sparks reached the HC-06 and rebooted it. The phone only noticed about 5 s later because of Android's connection timeout. The same cause explains why the pump ran for half a second and stopped while the button was held: with the HC-06 down, the "pump on" commands stopped arriving and the robot cut the pump for safety.

The real fix was in hardware:

  • A separate battery for the pump: the relay contact isolates the pump circuit from the robot completely; pump current never touches the robot's battery, ground or 5 V rails.
  • A buffered supply for the HC-06: Arduino 5 V → 1N5819 diode → HC-06, with 1000 µF + 100 nF across it. The diode stops the capacitor from draining back when the voltage drops, and the capacitor keeps the module up for ~25 ms through short dips.

To verify it, the test firmware gained a p test: it runs the pump five times for 0.5 s, logs how far 5 V drops and whether Bluetooth survives each time, and ends by saying whether the cause is a 5 V collapse or interference.


💧 Water level: sensor plus estimate

The off-the-shelf water sensor only measures about 4 cm and sits near the top of the tank. Because it can't reach the bottom, older versions reported "tank empty" while there was still water. v4 takes a different approach:

  • While the sensor is wet, the level comes from the sensor.
  • Once it's dry, the robot warns "water level falling" and estimates the level from total pump run time: a full tank empties in a time measured with the test firmware.
  • Below an estimated 20%, it warns "water level low". Water level never blocks the pump in any mode.
  • The estimate is saved to EEPROM, so it survives a power cycle. Refilling the tank wets the sensor and the level corrects itself.

The sensor isn't powered all the time; it gets power from pin D10 only while a measurement is taken.


📱 The Android app and protocol

I also wrote the Android app that controls the robot (Java, no extra libraries). It has three tabs:

  • Control: STANDBY / MANUAL / AUTONOMOUS selector, E-STOP, a status light, a tank gauge, the flame sensor radar, a round D-pad and a SPRAY button.
  • Display: what to show on each of the LCD's two lines (mode, water, flame direction, 5 V, fixed or scrolling text).
  • Logs: lowest voltage seen, reconnect count and restart count.

Communication is a simple line protocol: the phone always asks, and the robot only answers. Commands like M:A (autonomous), X (emergency stop), D:F (forward) and P:1 (pump) get a one-line status reply:

S:<state>,<alarm>,<pump>,<water%>,<servo>,<bursts>,<left%>,<centre%>,<right%>,<proximity>,<5V mV>,<min 5V>,<restarts>,<flags>

A safety rule is built into the protocol: manual drive and pump commands are valid for only 0.5 s. If the link drops, the robot and pump stop on their own within half a second, and the app reconnects automatically.


🧪 Testing in simulation

The main firmware was tested unmodified on a computer against a virtual robot with motor start-up lag, flickering flames, motor and pump noise, 5 V dips, a pump, hose, servo, LCD and phone. To put a flame out, the hose had to point within ±10° of it.

ScenarioResult
Autonomous, no fire, noise + 5 V dips, 300 sThe robot never moved and the pump never ran
One flame, 54 positions in view (−70°…+70°, 0.4–1.0 m)54/54 out; median 15 s, median aiming error 1.2°
Same 54 positions, tighter tolerance (±6°)54/54 out, worst aiming error 4.5°
Two and three flames, one leaving view while another is put outAll out in 24/24; the lost flame was found by turning on the spot
Two flames side by side, ~25 cm apartBoth out in 6 of 8 runs; 2 stopped with an alarm
Bluetooth dropped mid-drive with the pump on, in manualPump and motors stopped on their own within 0.5 s
Power dipped while pumping, Arduino reset, flame in frontBooted into STANDBY, nothing ran, the app was warned

The most useful part of the simulation was showing where it fails: two flames very close together can look like one to the sensors. That isn't a software bug; it's the limit of a digital-output sensor.


🛠️ Test firmware

A separate DonanimTest.ino is flashed before the main code. From the Serial Monitor, one key tests each part on its own: the motors and each side's direction, the servo, the pump, flame sensor percentages, the LCD, water sensor calibration, Bluetooth, how long the tank takes to empty (d), a power test (g) and the pump + Bluetooth test (p). When something breaks, "where?" gets answered by measuring, not guessing.


🎯 Conclusion

The biggest lesson from Quench: in an embedded system, much of what looks like a software bug starts in the power wiring. The robot that sprayed with no fire didn't have a bad flame algorithm, it had a collapsing 5 V rail; the dropping Bluetooth wasn't a range problem, it was the pump's inrush current. Software can contain those failures, but finding the root cause takes measuring, and sometimes stepping through a video one frame at a time.

The project is still evolving; the latest status is in the mission log at the top of this page.

⚠️ Quench is an educational project, not a real fire suppression system. Test it under adult supervision, on a non-flammable surface, with a small candle and a container of water nearby.