Skip to the content
2 layers100 × 50 mmSmart cleaning robot, the printed circuit board in 3D

MicroPython firmware for a low-cost floor-cleaning robot on a Raspberry Pi Pico W, with BLE remote control, ultrasonic obstacle avoidance, and feed-forward plus PID wheel control. Bachelor thesis, GUC 2025.

Size
100 × 50 mm
Copper layers
2
Thickness
1.6 mm
Parts
8
Nets
43
Pads
74
Tracks, vias
133, 0
Routed
Yes
KiCad
KiCad 9.0 (file 20241229)
Created
16 Mar 2026
Updated
1 Nov 2026

Overview

Smart cleaning robot is an open-source printed circuit board by andrew-abdelmalak, from the andrew-abdelmalak/smart-cleaning-robot repository on GitHub, published under the MIT licence. It is a 2-layer board of 100 × 50 mm with 8 parts on 43 nets, routed with 133 tracks and 0 vias.

It is built around the SC0918. Its parts include 3 resistors, 3 connectors and 1 IC. It belongs with the robots and motor control and radio and wireless boards and the RP2040 boards of this library.

Main components

1

README

README.md

Smart Cleaning Robot

MicroPython firmware for a low-cost floor-cleaning robot built on a Raspberry Pi Pico W, with Bluetooth Low Energy (BLE) remote control, ultrasonic obstacle avoidance, and feed-forward plus PID wheel control. It was my bachelor thesis project at the German University in Cairo (GUC), 2025.

CI License: MIT

The round black robot driving across a wooden floor toward a doormat   Top view of the assembled robot: a 35 cm round black chassis with a metal filter, a green button, and a green status light

The robot is a 35 cm round chassis that I designed in SolidWorks and 3D-printed, with a custom KiCad PCB and a repurposed PS3 fan for suction. In autonomous mode it drives straight until something is closer than 15 cm, then pivots left and carries on. From a phone you can drive it, toggle the fan, and sound a horn. The parts cost 3,950 EGP in 2025, about 80 USD at the time.

Try it in your browser: the project site runs this firmware, unchanged, in a drawn room you can drive it around, next to the real footage and the build story.

The 34-second project video, playing silently: the robot, how I built it, and its firmware running in a browser

The project in 34 seconds; select it for the version with sound. Music: “Happy Beats & Business Moves Vol. 10” by Sascha Ende (ende.app), CC BY 4.0.

Results

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

MetricResult
Battery runtimeMore than 60 minutes of continuous autonomous operation
BLE rangeStable indoor connection at more than 5 m
Straight-line drivingPID correction noticeably reduced drift compared with open loop
Stall recoveryDetected a stuck wheel and recovered in simulated stuck conditions
CleaningCollected light debris (paper, dust) from hard floors
System powerAbout 26 W at 12 V (estimate from component ratings)
Build cost3,950 EGP in parts (about 80 USD at the June 2025 exchange rate), against 100 to 900 USD for the commercial robots I compared
Size and weight35 cm diameter, 17 cm high, 2.65 kg

How it works

Block diagram: a phone, push button, ultrasonic sensor, and wheel encoders feed the Raspberry Pi Pico W, which drives the motors through an L298N H-bridge and switches the suction fan and status LED.

The firmware is one file, firmware/main.py, that runs a 20 ms control loop. Each pass handles, in priority order:

PriorityConditionAction
1Horn onBuzz the motors at 10% duty as an audible horn
2Manual command activeDrive forward, backward, or pivot
3Autonomous mode onAdvance the cleaning state machine one step
4OtherwiseMake sure both motors are stopped

Autonomous cleaning

State machine: from IDLE, CLEAN starts forward driving; an obstacle closer than 15 cm triggers a 39-pulse left pivot, and a wheel stall longer than 800 ms triggers reverse then the same pivot, both returning to forward driving.

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.

Motion control

A pure PID controller on the wheel encoders drew enough current to cause brownouts that stalled a motor. The final design uses a feed-forward motor model for most of the drive and keeps the PID only as a small correction to each wheel's target speed. The earlier versions on the way here, from timed driving to per-wheel PID and the tuner that found the final gains, are in docs/history/.

Control loop: the target speed passes through a feed-forward motor model to set PWM, the wheel encoders measure the left-right pulse difference, and a PID adds a correction to the target speed of each wheel.
LoopPurposeP / I / D
StraightKeep both wheels at the same distance travelled0.8 / 0.15 / 0.25
Turn progressReach the target pivot of 39 encoder pulses0.6 / 0.1 / 0.2
Turn balanceShare the pivot between both wheels1.5 / 0.05 / 0.3

The feed-forward model is PWM = kS + kV × speed, fitted per wheel (left: kS 27, kV 0.66; right: kS 30, kV 0.61), with a right-wheel trim of 0.75 and duty capped at 95%. All integrals are clamped to ±15.

Hardware

PartComponentPins (GP = Pico GPIO)
ControllerRaspberry Pi Pico W
Motor driverL298N dual H-bridgeENA 6, ENB 7, IN1 to IN4 12 to 15
Drive2 TT DC gear motors, 66 mm wheels
Wheel encoders20-slot optical discs, one channel per wheelLeft 21, right 20
Obstacle sensorHC-SR04 ultrasonicTRIG 10, ECHO 11
SuctionPS3 Slim fan, 12 V, on/off through its PWM wire8
Status LEDGreen LED18
ButtonPush button to GND, internal pull-up16
Power12 V Li-ion pack, LM2596S buck converter to 5 V
Chassis and PCB3D-printed PLA+, custom KiCad PCB

The KiCad project for the board, the SolidWorks files for the printed parts, and their drawings are in hardware/. The thesis has the full bill of materials (Appendix A).

Getting started

You need a Raspberry Pi Pico W with MicroPython for the Pico W (the robot ran v1.25.0, from April 2025), mpremote, and a phone with nRF Toolbox or another BLE UART app.

  1. Flash MicroPython: hold BOOTSEL while you connect USB, then copy the .uf2 file to the drive that appears.

  2. Copy the firmware to the board as main.py, so it runs at boot:

    bash
    mpremote cp firmware/main.py :main.py
  3. Reset the board. It advertises as PicoRobot-XXXX, where XXXX comes from the board ID.

  4. Connect from nRF Toolbox (UART) and send the commands below.

[!WARNING] Test with the wheels off the ground first, and check the motor wiring before you enable autonomous mode. I tuned the gains and thresholds for this chassis; expect to retune OBSTACLE_THRESHOLD_CM, TURN_PULSES, and the PID gains for another build.

Commands

Send these as text over the Nordic UART Service (writes go to RX characteristic 6E400002-B5A3-F393-E0A9-E50E24DCCA9E). Case and surrounding spaces are ignored.

CommandEffect
FORWARDDrive straight with PID correction. Stops with the horn if an obstacle is closer than 15 cm
BACKWARD, LEFT, RIGHTDrive backward, or pivot in place
Same command againBrake and stop
CLEANFrom a full stop: toggle autonomous cleaning (fan on, state machine running). While moving: emergency stop
FANToggle the suction fan (only while stopped)
HORNToggle the horn. Also silences the obstacle alarm

The push button does the same as CLEAN. Losing the BLE connection stops the robot.

Status LEDMeaning
OffIdle, no phone connected
Slow flashPhone connected
SolidAutonomous cleaning
Rapid flashHorn on or path blocked

Development

The tests run the real firmware on your computer against fake machine, bluetooth, and time modules, with a simulated clock that wraps like MicroPython's. They cover the motion math, the command handling, the safety stops, and the state machine. You need uv.

bash
uv sync
uv run pytest
uv run ruff check .
uv run ruff format --check .
uv run mpy-cross -o main.mpy firmware/main.py

CI runs the same steps on every push and pull request.

The site serves its third-party browser code (MicroPython WebAssembly, transformers.js, and the ONNX runtime) itself. package.json lists the versions; nothing installs them. scripts/vendor.json pins each file by SHA-256, taken from the npm package tarball after checking the tarball against the registry. Dependabot proposes new versions in package.json, and CI then fails until the pins are refreshed on that branch:

bash
python3 scripts/fetch_vendor.py --update

To preview the site locally, fetch the files into site/vendor/ (ignored by git) and serve site/:

bash
python3 scripts/fetch_vendor.py site/vendor

The Pages build also adds Mozilla's PDF.js viewer, pinned by version and SHA-256 in .github/workflows/pages.yml, so the thesis links open only on the deployed site.

The site's "Ask the thesis" search ranks passages from site/thesis-index.json. scripts/thesis_latex.py reads the passages from the thesis LaTeX, so results keep their headings, lists, tables, bold text, and subscripts. The build then places each passage on its PDF page and checks its words and numbers against the PDF's own text, so a parsing mistake stops the build. To rebuild the index after the thesis changes, install poppler's pdftotext and run:

bash
uv sync --group search
uv run scripts/build_thesis_index.py
uv run pytest tests/test_thesis_index.py

With the search group installed, the tests also embed 21 sample questions and check that most find the section that answers them in the top three results. When I built the index, 17 of the 21 did. CI skips that check because it needs a 23 MB model download, but still checks that the index matches what the parser reads from the LaTeX.

text
firmware/main.py      MicroPython firmware (copy to the board as main.py)
hardware/             KiCad board, SolidWorks parts, and drawings
scripts/              Builds the thesis search index; fetches the site's pinned libraries
tests/                Host-side tests and hardware fakes
docs/diagrams/        Diagrams used in this README
docs/history/         Earlier firmware versions, kept as written
docs/media/           Demo clips from the thesis presentation and the project video
docs/thesis/          Thesis PDF and its LaTeX source
site/                 Project site: the firmware in a drawn room, and thesis search

Known limitations

These come from the hardware and the hand tuning, and need the robot to fix and verify:

  • Navigation is reactive. The robot pivots left at every obstacle; it does not map the room or follow a coverage pattern.
  • The turn-balance PID adds the two wheel counts rather than comparing them, because the single-channel encoders cannot tell direction. I tuned the gains with it working that way on the prototype.
  • A disconnected ultrasonic sensor reads as a clear path. A missing echo returns 999 cm.
  • Pivots have no timeout. A dead encoder during a turn keeps the robot spinning.
  • Braking always pulses backward, whatever the direction of travel.
  • BLE has no pairing, so any phone in range can connect and drive the robot.
  • Cleaning: no check valve and no brushes, so debris can spill and embedded dirt stays.

Thesis

Design and Implementation of a Smart Cleaning Robot, Andrew Khalil Samuel Abdelmalak, Faculty of Engineering and Materials Sciences, German University in Cairo, June 2025.

The firmware has changed since the thesis: it now has tests, CI, and fixes for five control-logic bugs. See CHANGELOG.md.

Supervised by Prof. Dr. Walid Atef Hafez Omran, co-supervised by Dr. Hisham Mostafa El Sherif, and reviewed by Dr. M. A. Moustafa Hassan.

Contributing and security

This is a finished thesis project, so I do not plan new features. Bug reports and fixes are welcome; see CONTRIBUTING.md. Report security issues privately as described in SECURITY.md.

License

Released under the MIT License.

Parts

8
QtyValueFootprintReferences
2Screw_Terminal_01x11TerminalBlock:TerminalBlock_MaiXu_MX126-5.0-11P_1x11_P5.00mmJ2, J3
12.2kRResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR3
1330RResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR1
14.7kRResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR2
1SC0918Raspberry_Pi_Pico_W_Kicad_Files-main:MODULE_SC0918A2
1Screw_Terminal_01x02TerminalBlock:TerminalBlock_MaiXu_MX126-5.0-02P_1x02_P5.00mmJ1
1YAAJ_DCDC_StepDown_LM2596Footprints:YAAJ_DCDC_StepDown_LM2596U2

Similar boards

  • 2 layers87.9 × 98.7 mmBitdoglab smd, the printed circuit board in 3D

    Bitdoglab smd

    BitDogLab/BitDogLab

    Open-source educational hardware for embedded systems, programming, electronics, and physical computing.

    138 parts203
  • 2 layers47.2 × 55.5 mmTinta l2, the printed circuit board in 3D

    Tinta l2

    c0de111/tinta

    Battery-powered e-paper sign: room signage, sensor graphs, home automation, or anything over Wi-Fi. Wakes by real-time clock, NFC tap, or button. Raspberry Pi Pico W firmware, custom PCB, and 3D-printed case included.

    60 parts39Apache-2.0
  • 2 layers87 × 84.1 mmOpenACE V0.0.2, the printed circuit board in 3D

    OpenACE V0.0.2

    gatasConspicuity/gatas

    eConspicuity with support for ADS-L, OGN, FLARM, FANET for General Aviation

    80 parts26GPL-3.0
  • 2 layers41 × 82.1 mmWater Meter PCB, the printed circuit board in 3D

    Water Meter PCB

    dgomes/pico_w_water_meter

    Water Meter using Raspberry Pico W

    6 parts24
  • 2 layers182 × 105 mmPocketComputerUniversalInterface, the printed circuit board in 3D

    PocketComputerUniversalInterface

    N1UGK/PCUI_Public

    Collection of Programs and Utilities for the Pocket Computer Universal Interface

    161 parts15
  • 2 layers74 × 63.2 mmRNG, the printed circuit board in 3D

    RNG

    seanboyce/TRNG

    A spicy little quantum TRNG that pushes out MQTT

    30 parts10
  • 2 layersG2-pico kicad, the printed circuit board in 3D

    G2-pico kicad

    skmp/g2-pico

    can pio haz g2 interface?

    4 parts6BSD-3-Clause
  • 2 layers111.2 × 110.3 mmBadge24, the printed circuit board in 3D

    Badge24

    thestumbler/supercon24-badge-kicad-redrawn

    Redrawing the Hackaday Supercon 2024 Badge in KiCad

    23 parts5

Questions

How big is the Smart cleaning robot PCB?

It measures 100 × 50 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Smart cleaning robot use?

8 parts, built around the SC0918. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Smart cleaning robot KiCad files?

From the andrew-abdelmalak/smart-cleaning-robot repository on GitHub, at the commit this page was made from: the board is hardware/pcb/smart-cleaning-robot.kicad_pcb and its schematic hardware/pcb/smart-cleaning-robot.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Smart cleaning robot design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).