
Bitdoglab smd
BitDogLab/BitDogLab
Open-source educational hardware for embedded systems, programming, electronics, and physical computing.

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.
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.
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.
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 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.
From the prototype tests in the thesis (Table 4.2 and section 5.1.1):
| Metric | Result |
|---|---|
| Battery runtime | More than 60 minutes of continuous autonomous operation |
| BLE range | Stable indoor connection at more than 5 m |
| Straight-line driving | PID correction noticeably reduced drift compared with open loop |
| Stall recovery | Detected a stuck wheel and recovered in simulated stuck conditions |
| Cleaning | Collected light debris (paper, dust) from hard floors |
| System power | About 26 W at 12 V (estimate from component ratings) |
| Build cost | 3,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 weight | 35 cm diameter, 17 cm high, 2.65 kg |
The firmware is one file, firmware/main.py, that runs a 20 ms control loop. Each pass handles, in priority order:
| Priority | Condition | Action |
|---|---|---|
| 1 | Horn on | Buzz the motors at 10% duty as an audible horn |
| 2 | Manual command active | Drive forward, backward, or pivot |
| 3 | Autonomous mode on | Advance the cleaning state machine one step |
| 4 | Otherwise | Make sure both motors are stopped |
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.
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/.
| Loop | Purpose | P / I / D |
|---|---|---|
| Straight | Keep both wheels at the same distance travelled | 0.8 / 0.15 / 0.25 |
| Turn progress | Reach the target pivot of 39 encoder pulses | 0.6 / 0.1 / 0.2 |
| Turn balance | Share the pivot between both wheels | 1.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.
| Part | Component | Pins (GP = Pico GPIO) |
|---|---|---|
| Controller | Raspberry Pi Pico W | |
| Motor driver | L298N dual H-bridge | ENA 6, ENB 7, IN1 to IN4 12 to 15 |
| Drive | 2 TT DC gear motors, 66 mm wheels | |
| Wheel encoders | 20-slot optical discs, one channel per wheel | Left 21, right 20 |
| Obstacle sensor | HC-SR04 ultrasonic | TRIG 10, ECHO 11 |
| Suction | PS3 Slim fan, 12 V, on/off through its PWM wire | 8 |
| Status LED | Green LED | 18 |
| Button | Push button to GND, internal pull-up | 16 |
| Power | 12 V Li-ion pack, LM2596S buck converter to 5 V | |
| Chassis and PCB | 3D-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).
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.
Flash MicroPython: hold BOOTSEL while you connect USB, then copy the .uf2 file to the drive that appears.
Copy the firmware to the board as main.py, so it runs at boot:
mpremote cp firmware/main.py :main.pyReset the board. It advertises as PicoRobot-XXXX, where XXXX comes from the board ID.
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.
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.
| Command | Effect |
|---|---|
FORWARD | Drive straight with PID correction. Stops with the horn if an obstacle is closer than 15 cm |
BACKWARD, LEFT, RIGHT | Drive backward, or pivot in place |
| Same command again | Brake and stop |
CLEAN | From a full stop: toggle autonomous cleaning (fan on, state machine running). While moving: emergency stop |
FAN | Toggle the suction fan (only while stopped) |
HORN | Toggle the horn. Also silences the obstacle alarm |
The push button does the same as CLEAN. Losing the BLE connection stops the robot.
| Status LED | Meaning |
|---|---|
| Off | Idle, no phone connected |
| Slow flash | Phone connected |
| Solid | Autonomous cleaning |
| Rapid flash | Horn on or path blocked |
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.
uv sync
uv run pytest
uv run ruff check .
uv run ruff format --check .
uv run mpy-cross -o main.mpy firmware/main.pyCI 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:
python3 scripts/fetch_vendor.py --updateTo preview the site locally, fetch the files into site/vendor/ (ignored by git) and serve site/:
python3 scripts/fetch_vendor.py site/vendorThe 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:
uv sync --group search
uv run scripts/build_thesis_index.py
uv run pytest tests/test_thesis_index.pyWith 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.
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 searchThese come from the hardware and the hand tuning, and need the robot to fix and verify:
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.
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.
Released under the MIT License.
| Qty | Value | Footprint | References |
|---|---|---|---|
| 2 | Screw_Terminal_01x11 | TerminalBlock:TerminalBlock_MaiXu_MX126-5.0-11P_1x11_P5.00mm | J2, J3 |
| 1 | 2.2kR | Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal | R3 |
| 1 | 330R | Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal | R1 |
| 1 | 4.7kR | Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal | R2 |
| 1 | SC0918 | Raspberry_Pi_Pico_W_Kicad_Files-main:MODULE_SC0918 | A2 |
| 1 | Screw_Terminal_01x02 | TerminalBlock:TerminalBlock_MaiXu_MX126-5.0-02P_1x02_P5.00mm | J1 |
| 1 | YAAJ_DCDC_StepDown_LM2596 | Footprints:YAAJ_DCDC_StepDown_LM2596 | U2 |

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

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.

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


N1UGK/PCUI_Public
Collection of Programs and Utilities for the Pocket Computer Universal Interface



thestumbler/supercon24-badge-kicad-redrawn
Redrawing the Hackaday Supercon 2024 Badge in KiCad
It measures 100 × 50 mm and has 2 copper layers, 1.6 mm thick.
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.
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.
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).