Idea to Build: An ESP32 Flame-Seeking Spray Turret With Three IR Sensors, a Servo and a Pump
Share
You've probably seen the clip: a tiny nozzle swings round, locks onto a lighter flame and mists it out. Under the hood it's three cheap sensors, a servo and a pump, so we typed the idea into Soldr and let it design the thing.
Fair warning: this is Soldr's design, not a finished bench build. Soldr picked the parts, laid out every wire and wrote firmware that compiles for the ESP32-DEVKITC. It flagged the plumbing as unresolved: there's no spray nozzle or water reservoir in the list, so those are yours to add.

What you need
- ESP32-DEVKITC Development Board (the brain)
- IR Flame Sensor Module, 760 to 1100 nm (you need three)
- TowerPro MG995 Servo, 180 degree (aims the nozzle)
- Mini Peristaltic Pump, 5V DC, about 100 ml/min
- L298N Motor Driver Module (switches the pump)
- 5V 5A Regulated Power Supply (servo and pump power)
- Diode Variety Pack (a 1N4007 across the pump)
- Jumper Wire Combo (M-M, M-F, F-F)
- USB to Micro-USB Cable (flashing and ESP32 power)
Step 1: Wire it up
This is Soldr's wiring diagram from the screenshot above, written out:
| Part pin | Goes to |
|---|---|
| Flame sensor 1 (U2) OUT | GPIO4 |
| Flame sensor 2 (U3) OUT | GPIO13 |
| Flame sensor 3 (U4) OUT | GPIO14 |
| All three flame sensors VCC / GND | ESP32 3V3 / GND |
| MG995 signal (orange) | GPIO16 |
| MG995 VCC (red) / GND (brown) | 5V supply + / common GND |
| L298N ENA / IN1 / IN2 | GPIO17 / GPIO18 / GPIO19 |
| L298N IN3 / IN4 / ENB (unused channel) | GPIO25 / GPIO26 / GPIO27 |
| L298N 12V (motor supply) terminal | 5V supply + |
| L298N 5V terminal | ESP32 5V pin |
| L298N GND | common GND |
| Pump wire 1 / wire 2 | L298N OUT1 / OUT2 |
| 5V supply - | common GND (tied to ESP32 GND) |
A few things that save you a debugging session:
- Sensors on 3V3. The flame modules are rated 3.3 to 5V, so from the ESP32's 3V3 their outputs are already 3.3V logic. Soldr's diagram only draws OUT on the third sensor; its VCC and GND go to the same 3V3 and GND as the others.
- Muscle stays off the ESP32. The MG995 can pull over an amp when it moves, so it runs straight from the 5V 5A supply while the ESP32 runs off USB. Never join the supply's + to the ESP32's 5V pin. Do share ground: supply -, ESP32 GND, L298N GND and the servo's brown wire all meet.
- Pull the L298N's 5V jumper. Its onboard regulator needs 7V or more to make its own 5V, so with a 5V motor supply Soldr feeds the logic side from the ESP32's 5V pin instead. Remove the jumper so the two don't fight.
- Expect a gentle stream. The L298N drops roughly 2V, so the pump sees about 3V and runs slower than its rated 100 ml/min. Fine for a mist. Only channel A is used; IN3, IN4 and ENB sit idle.
- Diode and plug. Put the 1N4007 across the pump, band to the wire that goes positive, to catch the switch-off spike. The supply ends in a 5.5 x 2.1 mm centre-positive plug, so use a DC jack to screw-terminal adapter.
How it hunts the flame
- The three sensors sit fixed on the base facing left (45 degrees), centre (90) and right (135). Each has an LM393 comparator and a pot; when it sees enough infrared its output flips and the green LED lights.
- Every 20 ms the ESP32 reads them and steps the servo toward the one that sees the flame, so it slews instead of snapping.
- After the nozzle holds on target for half a second, the pump runs in bursts of up to 4 seconds with 3 second rests.
- If the flame vanishes, it holds its aim for 1.5 seconds, then stops the pump. Move the lighter and it finds it again.
Step 2: The code
No sketch pasted here, on purpose: we only publish code that comes straight out of a Soldr build, and this firmware lives in the build's Firmware tab. Soldr compiled that exact sketch for the ESP32-DEVKITC. It needs the ESP32Servo library from the Library Manager, and the timings above are the constants Soldr listed from it (SETTLE_MS 500, BURST_MS 4000, REST_MS 3000, LOST_HOLD_MS 1500). Describe the same idea at soldr.ai to get firmware for your own pins, flashable from Chrome or Edge over USB.
Step 3: Test it dry first
- Start dry: pump tube out of the water. Power up and open the Serial Monitor for the first boot.
- With a lighter 30 to 50 cm away, turn each sensor's pot until its green LED just comes on. Sunlight and halogen bulbs are full of IR, so tune away from windows.
- Sweep the flame left to right. If the servo turns the wrong way, swap the OUT wires on GPIO4 and GPIO14.
- Hold it still: half a second after the nozzle settles the pump should start, and it should stop about 1.5 seconds after the flame goes.
Step 4: The plumbing (your part)
Put the pump's inlet tube in a small sealed water container, run the outlet up to the servo horn, fit a fine mist nozzle (one from a spray bottle works) and zip-tie the tube so it moves with the horn.
Keep the water below and away from the boards and supply. Test on a tiled floor or outdoors with a small flame. This is a learning build, not a safety device, and it doesn't replace a smoke alarm or a real extinguisher.
How Soldr designed this from the idea
The idea we typed: "Build a mini fire extinguisher that hunts flames by itself: a small nozzle on a servo that turns toward a lighter flame detected by IR flame sensors, then a small pump sprays a fine water mist to put it out. If the flame moves, it turns and finds it again. Use an ESP32." From that, Soldr worked out each job (detection, aiming, pump, driver, power, flyback protection), matched parts from the Compoden catalog, wired them pin by pin and wrote and compiled the firmware. It also said plainly what it couldn't match: the nozzle and the reservoir. Try your own version at soldr.ai.