A DIY cleaning robot is an autonomous embedded system that integrates differential drive kinematics, closed-loop motor control, and dynamic power management to navigate and clean floors without human tethering. Building one fundamentally changes your circuit design approach: it forces you to abandon simple open-loop logic and engineer a robust power distribution network (PDN) capable of absorbing sudden current spikes without browning out the logic core. When entering this space, builders commonly confuse open-loop PWM duty cycle with actual motor velocity, falsely assuming a 50% PWM signal yields 50% speed regardless of the mechanical load or battery voltage sag.
To build a machine that doesn't strand itself under a sofa when the battery sags, you need to treat the power bus as a dynamic, high-current environment rather than a static 5V rail. This means sizing your battery management system (BMS), selecting MOSFET-based motor drivers over legacy BJT bridges, and routing your PCB traces to handle transient stall currents.
The Core Power Budget and Component Specs
Before writing a single line of PID control code, you must establish the absolute maximum current your system will draw. A cleaning robot has three distinct load profiles: the steady-state logic draw, the continuous mechanical drive draw, and the transient stall/vacuum draw. Below is the baseline spec sheet for a mid-sized, 12V-class DIY robot using an ESP32 and high-torque gear motors.
| Component | Nominal Voltage | No-Load / Idle Current | Peak / Stall Current | Design Notes |
|---|---|---|---|---|
| JGB37-520 Gear Motor (x2) | 12.0V | 150 mA (each) | 2.5 A (each) | Includes 11 PPR magnetic encoders for odometry. |
| Brushless Vacuum Impeller | 12.0V | 300 mA | 1.2 A (startup) | Requires a dedicated MOSFET switch; high EMI on spin-up. |
| TB6612FNG Motor Driver | 2.5V - 13.5V (VM) | < 1 mA (standby) | 3.2 A (per channel) | MOSFET H-bridge. Rds(on) is ~0.5Ω, vastly superior to L298N. |
| ESP32-WROOM-32 + ToF Sensors | 3.3V | 160 mA | 350 mA (TX burst) | Must be fed by a 2A-rated buck converter to handle RF spikes. |
| Servos (Brush/Side-Sweep) | 6.0V | 20 mA | 800 mA (stall) | Stall current occurs if brush gets tangled in carpet fringe. |
Notice the massive gap between no-load and stall currents. Your power supply and wiring cannot be sized for the 460 mA no-load cruise state; they must be sized for the worst-case transient where the drive motors stall while the vacuum impeller is spinning up.
Calculating Stall Current and Voltage Sag
Let's run a worked numeric example to size the battery pack and BMS. Imagine the robot drives onto a thick rug fringe. Both JGB37-520 drive motors stall simultaneously, the vacuum impeller is already running, and the ESP32 is actively transmitting LiDAR data over WiFi.
- Drive Motors (Stalled): 2.5 A × 2 = 5.0 A
- Vacuum Impeller (Running): 1.2 A
- Logic & Sensors (TX Burst): 0.35 A
- Total Peak Transient Draw: 6.55 A
You need a battery and BMS capable of sustaining at least 6.55 A without triggering overcurrent protection or suffering catastrophic voltage sag. If you choose a 4S LiFePO4 pack (12.8V nominal), you must select a BMS rated for a minimum of 10 A continuous discharge to prevent nuisance tripping during multi-second stall events.
Now, calculate the voltage sag. Assume your battery pack and wiring have a combined internal resistance (IR) of 60 mΩ (0.06 Ω). Using Ohm's Law:
Your 12.8V pack will drop to 12.4V under peak load. The TB6612FNG motor driver will pass this through to the motors, and your 12V-to-5V buck converter will easily maintain a stable 5V rail for the ESP32's secondary regulator. However, if you had used cheap, mismatched 18650 cells with an IR of 250 mΩ, the sag would be 1.63 V. The battery voltage would plunge to 11.17 V, potentially tripping the undervoltage lockout (UVLO) on your motor driver or causing the ESP32's internal brownout detector (BOD) to reset the chip if the buck converter drops out.
Where You Meet This in Practice: PCB Layout and Noise
Theory meets reality when you route the physical traces on your robot's power distribution board. High-current motor paths generate massive electromagnetic interference (EMI) and ground bounce, which will corrupt your I2C sensor buses and encoder signals if layout rules are ignored.
According to IPC-2221 standards, carrying 5 A continuously on an external PCB layer with a 10°C temperature rise requires a trace width of roughly 110 mils (2.8 mm) using 2 oz copper. For a DIY robot, you should double this to 200 mils for the main battery input traces to minimize resistance and heat. More importantly, you must implement star grounding.
Do not daisy-chain your ground connections. The high-current return path from the TB6612FNG motor driver must go directly to the battery negative terminal (or the main ground pour) in a thick, dedicated trace. The ESP32 logic ground should connect to that exact same central star point. If you daisy-chain the logic ground through the motor ground trace, the 5 A motor current will create a voltage differential across the trace resistance, effectively lifting the ESP32's ground reference by hundreds of millivolts. This ground bounce will cause erratic ADC readings and I2C bus lockups.
For further layout guidance on separating high-current motor paths from sensitive logic, refer to the Texas Instruments Motor Driver Board Layout Guidelines, which detail proper decoupling capacitor placement and thermal via stitching for H-bridge ICs.
Troubleshooting Power Delivery Failures
Why does my ESP32 reboot every time the vacuum motor turns on?
This is a classic brownout. Brushed and brushless vacuum motors generate severe voltage transients on the 12V rail during commutation. If your 12V-to-5V buck converter lacks sufficient input capacitance, the transient dips below the converter's dropout voltage, causing the 5V rail to sag. The ESP32's internal brownout detector (typically set around 2.43V on the 3.3V rail) triggers a hardware reset. The Fix: Add a 470μF low-ESR electrolytic capacitor and a 100nF ceramic capacitor directly across the VM (motor voltage) input pins of your motor driver, and ensure your buck converter is rated for at least 3A continuous output.
My wheel encoder counts are erratic and jumping randomly. How do I fix this?
Encoder signals are low-voltage, high-impedance digital pulses that are highly susceptible to capacitive coupling from nearby PWM motor wires. If your encoder cables are routed parallel to your motor power leads, the 20 kHz PWM switching noise will induce false pulses. The Fix: Route encoder wires perpendicular to motor wires. If using I2C for magnetic encoders (like the AS5600), ensure you have 4.7kΩ pull-up resistors on SDA/SCL, and keep the I2C bus length under 30 cm to minimize parasitic capacitance. For longer runs, switch to SPI or use differential line drivers.
Should I use an L298N or a TB6612FNG for my drive motors?
Always choose the TB6612FNG (or a modern equivalent like the DRV8701) for a DIY cleaning robot. The L298N uses legacy BJT (Bipolar Junction Transistor) technology, which has a fixed voltage drop of roughly 1.5V to 2.0V per channel. At 2 A, the L298N wastes 4 Watts as heat, requiring a massive heatsink, and robs your motors of critical torque. The TB6612FNG uses MOSFETs with an Rds(on) of ~0.5Ω, dropping only about 1 V at 2 A and wasting significantly less power. For deeper microcontroller integration and strapping pin configurations, consult the Espressif ESP32 Hardware Design Guidelines to ensure your PWM pins aren't conflicting with boot modes.






