Designing an ESP32 board from scratch: the reboot was never a software bug, it was two loads sharing one rail
The car was running fine. Four motors at full forward. Then the author pushed the stick to full reverse, and the board rebooted — Bluetooth controller dropped, everything shut down, power button needed again, program restarting from the top.
It was not intermittent. Any simultaneous full-forward-to-full-reverse transition on all four channels reliably reset the board.
The cause is not subtle once stated: a spinning motor is a generator, and an abrupt reversal dumps that energy back into the circuit as back EMF. The rail gets pulled down and then spiked up, the MCU sees undervoltage, and it resets. That single problem is what the board was designed to survive. It dragged a chain of other problems along with it.
First attempt: pay someone else
The first instinct was not to design anything. Through an introduction the author found someone who agreed to design a power board for RMB 500, paid RMB 300 up front.
Once the money moved, the schedule changed. The board was fabricated; when the author asked to test the engineering sample, the designer refused to hand it over until the remaining RMB 200 was paid. Testing before paying was not on offer. The author wrote off the RMB 300.
The lesson was not the money. It was that if the core artefact is not in your hands, you do not even have the standing to find out whether it works. Someone else's board means unknown routing, unknown components, unknown path to production, and no idea where to look the next time something breaks.
Learning the vocabulary
So: from zero. Schematic capture and layout in LCEDA, learned from the official tutorials and a Bilibili series.
First the components. What a resistor does, why a capacitor filters, what an inductor contributes in a supply — all of it looked up one item at a time. Then packages: an 0603 and an 0805 resistor are a size apart and completely different in footprint and soldering difficulty. A schematic symbol becomes one specific footprint on the board, and choosing wrong means the parts you bought will not fit.
Soldering as a separate skill
Drawing the board is half of it; the assembled board still has to be soldered by hand.
- Iron and solder. 0805 by hand means shaky fingers, bridges and cold joints. The first solder wire bought was 0.8 mm, too thick for small pads — one touch delivered a blob. 0.6 mm gave usable control. The iron needs stable temperature adjustment and a fine conical tip: precise deposition, fast heat transfer, easier drag-soldering of fine-pitch parts.
- Consumables. Board wash to remove flux residue so the board is not tacky, does not leak, and can be inspected. Solder paste with syringes and tips of different gauges — too much bridges, too little cold-joints, all feel.
- Hot plate. Three criteria: stable temperature, even ramp, low across-plate gradient. Temperature drift means paste either never flows or overcooks; a large gradient means one side of the board reflows while the other has not started. The author bought a Zhengdian Yuanzi HP20 with built-in reflow at RMB 285, failed the joint, decided it was too expensive, and returned it — then bought a cheaper plate at roughly half the price and used its constant-temperature mode instead, which worked better in his hands. A hot air gun was also tried, badly enough to scorch it.
The actual engineering: supply
Soldering is craft. Power is engineering, and it is where most of the failures accumulated.
The conflict is structural. The MCU and sensors want a stable voltage. The motors want momentary large current. Those two requirements fight.
The first design used two lithium cells in series, 7.4 V nominal. Cell voltage is not constant: 8.4 V at full charge, then a long plateau around 7.4 V with slow decline, then a rapid drop at end of discharge. As the rail moved, the line-following car's behaviour moved with it — same parameters, good behaviour on a fresh charge, drift after a while, constant retuning to follow the voltage down.
The second problem with series is cell mismatch. If one cell is full and the other is empty, pack capacity is set by the weaker one, which empties first. Keep discharging and current is forced backwards through the flat cell, causing reverse charging, heating, swelling and possible damage, and the protection board cuts the whole pack. Two cells look like one pack and are hostage to the worst cell.
So the topology was inverted: cells in parallel for a stable 3.7 V, then a boost converter to 7.4 V. Parallel cells share voltage and can supply current to each other, which softens the matching problem considerably.
The new problem was the boost chip. The first choice was SOT-23-6 — small, easy to route — with no thermal pad and high package thermal resistance. As soon as the motors drew current the chip heated, efficiency fell, thermal protection kicked in, and the output became less stable than before. The charger overheated under high current too, and charge rate had to be stepped down repeatedly.
Heating and charging were addressed one by one, and the board still rebooted on a hard reversal.
The boost was then changed to a current-mode part. Compared with voltage mode, current mode responds faster to load steps with better current limiting and dynamics, which is exactly the profile of a motor load. The package changed to ESOP-8 with an exposed thermal pad, so heat goes into the copper. That is when the thermal problem actually stopped.
With the supply stable and the chip cool, the next question was whether two parallel cells were needed at all. Two 14500 cells were replaced with one 18650 — roughly equivalent capacity, one fewer cell, one fewer source of mismatch and ageing. Two cells that match today will not necessarily match in a year.
The reboots continued.
The answer was architectural
The idea that finally worked was to integrate the battery and the main board and run two isolated internal rails: one dedicated to the MCU, one dedicated to the motors.
That separates clean power from dirty power at the root. Whatever current surge and back EMF a reversal produces stays on the motor rail and never travels up the logic supply. Testing confirmed it, and the reboot problem got a structural fix rather than another filter.
It is worth noting the shape of this: four successive supply improvements — parallel topology, current-mode boost, thermal pad, single cell — each correct, each insufficient. The problem was not that the supply was noisy. It was that one rail was serving two loads with incompatible requirements.
Redesigning the board around what broke
With the power architecture settled, the board itself was redrawn module by module, folding in fixes accumulated from using other development boards.
Pin count. Four motors at two control pins each is eight pins before anything else. ESP32 GPIO is not generous, and four servo channels were also wanted. The solution was pin multiplexing — time- and region-sharing pins between functional blocks — plus an expander to absorb the rest.
Servos. Four onboard channels plus a four-channel expansion header, for eight total, enough for multi-joint mechanisms.
I2C address collision. Two identical devices on one bus conflict. The design resolves it so both can sit on the board and communicate, with no manual re-addressing or flying leads.
Dual ultrasonic. Front and rear headers, so the car can range in both directions.
Field controls. Two function buttons plus reset, so parameters and modes can be changed without a laptop.
Sockets instead of soldered parts. The gyro is a header, not a chip, because module variants differ by vendor and requirement — attitude, balance and heading each want something different. OLED is a header too.
Indicators and power. Two WS2812s, Type-C and DC input, plus composite and expansion headers for further sensors.
What the board is
The final bill of features: ESP32 main control, four onboard DC motor drivers on PH2.0 connectors, eight servo channels (four onboard, four expandable), dual ultrasonic headers, plug-in OLED and gyro, two function buttons and reset, two WS2812s, Type-C and DC input, and spare composite and expansion headers.
It is not a specification-stacked board. It is a board that was repeatedly broken by a real project and then amended until the breakage stopped — and the decisive amendment was not a better component but a boundary between two loads.