Andrew Abdelmalak

Smart Cleaning Robot

A floor-cleaning robot I designed and built from scratch for my bachelor thesis: the 3D-printed body, the circuit board, and the code that drives it. Its real code runs right here: take the remote and try it.

in parts, 2025
3,950 EGP
per charge
60+ min
35 cm across
2.65 kg
The real robot, filmed for the thesis, driving toward a doormat. 7 s, no sound.

Real firmware Drawn room

Starting the firmware in your browser…

Floor cleaned 0%

Starting the firmware.

State
-
Distance ahead
-
Motor power L / R
-
Wheel pulses L / R
-
Status light
-
Fan
-
    Connected to PicoRobot

    The robot in the room runs its real firmware, firmware/main.py, unchanged, on MicroPython compiled to WebAssembly. Every stop, turn, honk, and blink comes from that code. The room, the dust, and the floor grip are drawn: each wheel turns as fast as the firmware's own motor model predicts, slowed to match the pace of the real clip. Arrow keys drive it while the remote has focus.

    The whole project in 34 seconds

    The only clip on this page with sound.

    Music: “Happy Beats & Business Moves Vol. 10” by Sascha Ende, ende.app, CC BY 4.0.

    The real robot, on real floors

    One press of the green button on the lid, and it starts cleaning on its own. 18 seconds, no sound.
    Driving it from a phone over Bluetooth, with the same button layout as the remote above. 31 seconds, no sound.

    From breadboard to finished robot

    I did every part myself: the body, the electronics, and the software. These are the stages, in order.

    1. Circuit simulation in Proteus: an Arduino board wired to an ultrasonic sensor, an H-bridge, two motors, a fan, and start and stop buttons.

      Proteus Checked the obstacle-avoidance logic in a circuit simulator first.

    2. Breadboard prototype: the Pico W, motor driver, and a yellow gear motor connected with jumper wires on a desk.

      Breadboard Wired the controller, motor driver, sensor, and motors together to test them for real.

    3. SolidWorks model of the open round chassis, labelled with the DC motors, the debris collection chamber, and the ultrasonic sensor window.

      SolidWorks Designed the 35 cm round body, the debris chamber, and the mounts, then 3D-printed them in PLA+.

    4. 3D render of the custom green circuit board with the Pico W, a buck converter, and rows of screw terminals.

      KiCad Designed a two-layer, 100 × 50 mm circuit board to replace the loose wiring.

    5. Inside the robot: the debris chamber in the middle, two yellow motors, the circuit board, the motor driver, and the wiring.

      Assembly Fitted the motors, fan, battery, and electronics inside the shell.

    6. Underside of the robot: two drive wheels, a front caster, and the rectangular intake nozzle in the middle.

      Underside Two drive wheels, a caster, and the intake that feeds the debris chamber.

    The finished robot: a round black 3D-printed body with a metal filter, a green button, and a green light on the lid, and the ultrasonic sensor in a window at the front.
    The finished robot: 3,950 EGP in parts in 2025, about 80 USD at the time. Store-bought robot vacuums were listed at 100 to 900 USD.

    The hardest bug: a smarter controller that stalled the motors

    Two cheap motors never spin at exactly the same speed, so a robot told to go straight drifts. I added wheel sensors and a feedback controller (a PID controller) that pushes harder on whichever wheel falls behind.

    It worked until the robot turned. The controller asked for so much current that the supply voltage sagged and a motor stalled, and the robot stopped dead.

    The fix was to let a simple model of each motor supply most of the power (feed-forward) and keep the feedback controller for small corrections only. The robot stayed stable, in exchange for slightly less precise steering. The earlier firmware versions show each step.

    Control loop diagram
    The control loop: a feed-forward motor model turns each wheel's target speed into PWM. The wheel encoders measure the left-right pulse difference, and a PID adds a small correction to each wheel's target speed.

    What it does, measured

    From the prototype tests in the thesis (Table 4.2 and section 5.1.1).

    Runs on one chargeMore than 60 min of continuous cleaning
    Phone rangeStable at more than 5 m indoors
    Cost of parts3,950 EGP, about 80 USD at the June 2025 exchange rate
    Store-bought robots100 to 900 USD in 2025, from basic models to the Roomba 980
    Size and weight35 cm across, 17 cm tall, 2.65 kg
    PowerAbout 26 W at 12 V, estimated from part ratings
    Picks upLight debris such as paper bits and dust, on hard floors
    Straight drivingNoticeably less drift with the controller than without
    Stuck wheelDetected and recovered in simulated stuck conditions

    What it can't do yet

    • It doesn't map the room. It turns left at every obstacle, so it can miss spots, as the room at the top shows.
    • It has no brushes and no flap to hold debris in, so it picks up only light, loose dirt.
    • Any phone in Bluetooth range can connect and drive it; there is no pairing.
    • A disconnected distance sensor reads as a clear path.
    • Turns have no time limit, so a failed wheel sensor during a turn keeps it spinning.

    How it works

    The firmware is one MicroPython file on a Raspberry Pi Pico W, running a 20 ms control loop. After the thesis I added 42 host-side tests that run the real firmware against fake hardware, continuous integration, and fixes for five control-logic bugs, each found with a failing test first.

    Hardware block diagram
    Hardware: the phone, the push button, the ultrasonic sensor, and the wheel encoders feed the Raspberry Pi Pico W. It drives the two motors through an L298N H-bridge and switches the suction fan and the status LED.
    Autonomous cleaning state machine
    Autonomous cleaning, the state machine you drove at the top of the page. From IDLE, CLEAN starts forward driving. An obstacle closer than 15 cm triggers a 39-pulse left pivot. A wheel stall longer than 800 ms triggers a reverse, then the same pivot. Both return to forward driving.
    PID gains I tuned by hand on the prototype
    LoopPurposePID
    StraightKeep both wheels at the same distance0.80.150.25
    Turn progressReach the 39-pulse pivot0.60.10.2
    Turn balanceShare the pivot between the wheels1.50.050.3

    The thesis

    Design and Implementation of a Smart Cleaning Robot

    Andrew Khalil Samuel Abdelmalak. Bachelor thesis, Faculty of Engineering and Materials Sciences, German University in Cairo, June 2025. Supervised by Prof. Dr. Walid Atef Hafez Omran, co-supervised by Dr. Hisham Mostafa El Sherif, reviewed by Dr. M. A. Moustafa Hassan.

    Ask the thesis

    Semantic search over the thesis, run in your browser. It finds the three passages closest in meaning to your question and links to their pages. It quotes the thesis and never writes an answer of its own.

    Try