Project Qwen
An offline home-security and assistant robot, built on salvaged hoverboard motors, that sees, listens, guards the house and docks itself to recharge.
Qwen is a home robot I designed and built from scratch over about three months. A Raspberry Pi 4 (4 GB) runs everything that needs intelligence, all offline: a custom wake word, speech recognition, a local language model, text-to-speech, hand-gesture control, owner face recognition and person detection. An ESP32 handles everything with a deadline: closed-loop wheel speed control on salvaged hoverboard hub motors, obstacle reflexes, the scissor-lift servos and status LEDs. In security mode it sleeps on a motion sensor, wakes to check faces, turns to follow an intruder, lights the room through my smart-home system, sounds an alarm and alerts my phone. It returns to its charger by itself using two AprilTags and wheel odometry, and confirms the dock by measuring charging current. This report covers the design, what failed and how each problem was solved.
Goals and constraints
I wanted a robot that is useful around the house rather than a demo: something I can talk to, that keeps an eye on the place while I'm out, and that looks after its own battery.
- Compute. A Raspberry Pi 4 with 4 GB of RAM and no GPU. RAM, not storage, was the binding limit.
- Power. A salvaged hoverboard Li-ion pack, 25.2 V nominal (7 cells in series), that the robot recharges itself.
- Offline. No cloud services for speech, language or vision. Only phone alerts leave the house.
- Budget. Mostly salvaged and second-hand parts (section 03).
Guiding principle: only cheap processes run all the time; heavy work happens on demand. That rule decided the wake-word design, the security power states, the idle mode and how the camera is shared.
Board split. The Pi does perception and decisions; the ESP32 does anything with a deadline. Safety reflexes such as obstacle stops and the motor watchdog live on the ESP32, so they never depend on a round trip to the Pi.
Design and build
Qwen is an original design. I was going for a Star Wars droid look: I sketched it by hand, modeled it in Fusion 360 and printed every part in PETG. I also wanted the neck to reach human height, which just isn't doable with these servos. The one borrowed mechanism is the scissor lift, which I adapted from a Thingiverse design.
The scissor lift. Each MG996R servo can turn 180°, but I limited it to 130°, as far as the mechanism extends. I added a bridge to join the two mirrored lifts so they support the head better, and melted the joints together with a soldering iron instead of gluing them. The first lift test with every head component on it was far too heavy for the servos, so I stripped the C920 webcam out of its housing and removed a heavy metal plate; after that the lift raised everything smoothly.
- Month 1
Jul 7 –AI, vision and first parts. Voice pipeline, wake word, gestures, testing components one at a time, and reverse engineering the hoverboard over UART.
- Month 2
Mechanics. Hub motors on separate controllers, the scissor lift and its weight problem, designing and printing the body and head, mounting the wheels.
- Month 3
– Oct 17Integration. Security mode and the smart-home link, perfboards, odometry, speed control, docking, power management, one program that starts at boot.
Hardware
Computing
Raspberry Pi 4 · 4 GBAI, vision, decisions
ESP32 dev boardmotors, sensors, servos, LEDs · UART to the Pi, powered over the Pi's USB
Vision + audio
Logitech C920camera + built-in microphone
MAX98357A I²S ampclass D, about 3 W
Gikfun 2″ speaker4 Ω, 5 W: never driven past its rating by the 3 W amp
Drive
2× hoverboard hub motors6.5″ wheels, built-in hall sensors
2× ZS-X11H BLDC controllersDIR + PWM from the ESP32
Logic-level shifter3.3 V ↔ 5 V
12× 10 kΩfour hall-sensor dividers for odometry
Neck + head
Scissor liftThingiverse design, modified, PETG
2× MG996R servoslimited to 0–130°, own 7.2 V supply
Potentiometermove the lift by hand
Sensors
PIR motion sensorin the head, wakes the robot
3× IR obstacle sensorsfront of the body, 3.3 V
INA226 power monitoron the charging branch
Lights
3 W LED module5 V, onboard driver: the head flashlight
4 indicator LEDs + 4× 220 Ωgreen / yellow / red battery, white status
Power
Hoverboard battery7S Li-ion, 25.2 V nominal
2× buck converters5 V (Pi) and 7.2 V (servos)
Power switch
Charging + dock
Hoverboard charger29.7 V measured, no load
Leaf-spring contacts + padsrobot-vacuum style
1N4007 diodein the + pad lead
2× AprilTagstag36h11, IDs 0 and 1, 79 mm
Out of pocket for the major parts: used hoverboard $25 (eBay), C920 $15 (Facebook Marketplace), two ZS-X11H controllers $25, the Pi a hand-me-down. The rest were parts I owned or a few dollars each. Tools: 3D printer, ST-Link v2, USB logic analyzer, Arduino Uno, multimeter, bench supply, soldering iron.
System architecture
Everything on the Pi runs in one Python process (assistant.py) started by a systemd service at boot. One
process means one owner for each shared resource: one camera manager, one serial link to the ESP32, one web server.
That turned out to matter more than any single algorithm. The only separate program is a small C++ tag tracker,
which borrows the camera while the robot drives itself. The two boards talk over a plain-text serial protocol
(V 30 30 means both wheels at 30 mm/s), and the ESP32 enforces its own safety rules: a 500 ms motor
watchdog, an IR obstacle stop and a reverse limit by distance, since there are no rear sensors.
V 30 30 = both wheels 30 mm/s; the ESP32 reports wheel counts, speeds, IR states and lift position).Voice assistant
The robot was first called Piko, so the first wake word was "Hey Piko". My first prototype skipped a real wake-word model and transcribed everything with Whisper, which kept speech recognition running almost nonstop on a board that also has to do vision, so I replaced it before it reached the Pi.
| Stage | Choice | Why |
|---|---|---|
| Wake word | openWakeWord, custom "Hey Qwen" | A tiny always-on classifier; everything heavier runs only after it fires |
| Speech to text | faster-whisper tiny.en | Smallest model that understood me reliably on the Pi |
| Language model | Qwen 2.5 (1.5B) via Ollama | Runs locally, so nothing I say leaves the house |
| Text to speech | Piper | Natural voice, runs locally |
I tried Google's Gemma 3 first, but its answer to "what is Ohm's law?" wasn't what I expected, so I switched to Qwen 2.5, and that's where the robot's name comes from. I trained the wake word with openWakeWord's notebook, which generates synthetic speech; its voice read "Qwen" as the letter Q, so I spelled it "hey kwen". Piper had the same problem, so the robot's speech swaps in "Kwen" before speaking.
The speaker sits a few centimetres from the microphone, so the robot could wake itself. The fix is one line:
self.mic.mute_for(duration_s + MIC_MUTE_TAIL_S) # deaf while speaking, + 0.3 s
Known commands (record, photo, flashlight, room lights, look up/down, move, "what do you see", "is anyone here", security mode, alarm) skip the language model entirely. In a quiet room the microphone level is boosted automatically (up to +12 dB) so a soft "Hey Qwen" still wakes it.
Vision: gestures, faces and people
Hand gestures
MediaPipe Hands returns 21 points per hand. Instead of training a gesture model, I classify gestures with geometric rules on those points, divided by the palm size so distance from the camera doesn't matter. Telling a fist from a thumbs-up took four attempts; a live overlay that drew the skeleton and the raw measurements made each attempt a measurement instead of a guess. The rule that finally worked uses height, not shape:
if four_fingers_curled:
# thumb tip well above the folded fingertips?
if _thumb_raised_ratio(landmarks) > 1.25: # in palm widths
return "thumbs_up"
return "fist"
| Gesture | Action |
|---|---|
| Thumbs up | Start recording |
| OK sign | Stop recording |
| Peace sign | Photo after 1.5 s |
| Rock sign, held 1 s | Toggle the head flashlight |
| L sign, held 1 s | Lock the front door (smart-home system) |
Faces and people
Faces are found with YuNet and compared with SFace embeddings: one enrolled owner, everyone else "unknown". Recognition depends on lighting and lift height, so I enroll the owner once per condition. People are detected with YOLO26n exported to NCNN, which runs well on the Pi's ARM cores and still sees someone who has turned away.
Security mode and the smart home
Security mode is built around power: the expensive parts only run when there is a reason to.
- Arming: "Hey Qwen, security mode" or the exit button on my keypad, with a 100 s exit delay.
- Armed-idle: camera, microphone and lights off; only the PIR motion sensor is watched.
- Armed-active: on motion the camera wakes and runs face recognition and person detection. When it sees someone, it turns on the room lights and the head flashlight, drives a little away from the wall and turns slowly on the spot to keep the person in view.
Intruder response: an unknown face starts recording and a spoken warning; if they're still there 25 s later, the alarm sounds, the flashlight flashes and the video goes to my phone through a Telegram bot. Recognizing the owner's face, or the correct keypad code, disarms it.
The smart home. Qwen plugs into an ESP32 smart-home system I built earlier: a door-lock servo, two light-switch servos and a keypad on an ESP-NOW hub. From my phone I can unlock the door for someone; Qwen then raises the lift so the camera can see faces from the floor and gives them 3 minutes to be verified before the alarm. Recognizing the owner locks the door again.
Telegram also works the other way: sending stop locks the wheels and lift from anywhere, and
resume continues, picking docking back up if it was mid-run.
Drivetrain: from hoverboard to closed-loop control
Reverse engineering the hoverboard
A used hoverboard cost $25 and came with two hub motors strong enough to carry a person, plus a 25.2 V battery. My plan was to reflash its controller with an ST-Link, but the programmer kept failing: the chip isn't an STM32 at all but a Linkosemi LKS32MC088, which has no open-source hoverboard firmware.
So I tried speaking the protocol the two boards already use. I found the link pins (12, R1, T1, G),
sniffed them with an ESP32 and replayed the "forward" data, but the boards still shut off. Copying data from
screenshots kept turning the letter O into zeros, and 115200 baud turned out to be the wrong rate. A logic analyzer
settled it: each bit lasts 13 µs, about 76,923 baud, in fixed 19-byte frames. With exact captures turned
straight into C arrays, both boards stayed on with no errors, but the wheels never moved. My best
guess is that the link only carries status between the boards. I chose to treat the wheels as plain motors instead.
Motor controllers
With the first ZS-X11H the motor locked up, vibrated and eventually smoked. I suspected the hall sensors and phases were mismatched and tried all 36 combinations; what finally worked was the hall order printed on the motor's own hall board. The ESP32's 3.3 V signals were too weak for the controller's inputs, so a logic-level shifter sits in between, and each motor now needs just two signals: direction and PWM.
Wheel odometry
To know how far each wheel turned, I tapped two hall sensors on each controller's hall connector. They switch at 5 V and the ESP32 only takes 3.3 V, so each tap goes through a divider made of three 10 kΩ resistors:
Spinning each wheel by hand gave 60 counts per turn. With 162 mm wheels, one turn rolls \(\pi \times 162 \approx 509\) mm, so each count is 8.5 mm. Turning follows from the difference between the two wheels:
In code, a turn on the spot is just both wheels rolling the same arc in opposite directions:
arc = WHEEL_SPACING_MM * math.pi * deg / 360.0 # each wheel rolls this far
got = self._odo_move(-arc if left else arc, # one wheel back...
arc if left else -arc, speed) # ...one forward
Closed-loop speed control
Open-loop PWM meant "slow" changed with battery voltage and the two wheels never matched, and even the lowest setting was too fast for docking. Now the ESP32 measures each wheel's real speed from the time between hall counts and corrects it 50 times a second, with an acceleration limit so the rear caster doesn't lift and slam:
float speedOut(float target, float measured, float& integ,
float dt, float cap) {
const float err = target - measured; // mm/s
integ = clampf(integ + err * dt * SPEED_KI, SPEED_I_MAX);
float out = target * SPEED_FF + err * SPEED_KP + integ; // FF + PI
...
}
A second term keeps the wheels in step when driving straight or spinning. The robot now drives anywhere from a few mm/s for fine turns up to 130 mm/s.
Electrical design
Two buck converters split the battery: 5 V for the Pi (the ESP32 is powered from the Pi's USB) and 7.2 V for the lift servos, so their current spikes can't brown out the Pi. The motor controllers run straight from the pack.
Charging, and why it charges through the wrong wires
The hoverboard battery has four wires: two for output and two for charging. As soon as it started charging, the battery's protection board switched the output off and everything shut down. A multimeter still read 28 V on the output, but a multimeter draws almost no current, so voltage alone didn't mean it could power anything. The fix was to charge through the output wires instead. That may bypass the battery's own overcharge protection, so the robot enforces it in software: at 90% it says "Battery full" and drives itself off the charger. A 1N4007 diode in the positive pad lead only lets current flow into the robot, so the battery voltage never appears on the exposed pads. The INA226 on that branch tells the robot when it's really charging.
Full schematic
Every connection as built, in PCB-schematic style. Labels with the same name are connected.
| Function | Pins | Notes |
|---|---|---|
| Pi ↔ ESP32 link | Pi 14/15 ↔ ESP32 22/21 | 115200 baud, 3.3 V both sides |
| Speaker (I²S) | Pi 18 / 19 / 21 | the Pi's fixed hardware I²S pins |
| INA226 (I²C) | Pi 2 / 3 | address 0x40, powered from the 5 V rail |
| PIR / flashlight | Pi 24 / 23 | the 3 W LED module runs straight from the GPIO |
| Motors PWM / DIR | ESP32 17, 13 (L) · 18, 5 (R) | through the level shifter, 20 kHz |
| Hall taps | ESP32 16, 23 (L) · 32, 19 (R) | through the 10 kΩ dividers |
| IR sensors | ESP32 15, 35, 4 | 35 is input-only, with a 10 kΩ pull-down |
| Lift servos / pot | ESP32 25, 33 / 34 | servos on the 7.2 V supply |
| LEDs | ESP32 26, 27, 14, 12 | green, yellow, red, white, each through 220 Ω |
Docking and automatic recharging
The dock is two spring-loaded metal pads, the kind robot vacuums use, on a plate glued to the wall, with two printed AprilTags above it. The robot's contacts are on its back and it has no rear sensors, so docking means reversing blind onto two small pads. When the battery drops to 25%, Qwen says "Low battery, returning to dock":
- Find and line up. A 360° scan finds the tags. Using two tags instead of one matters: a single square tag can look the same from two angles, and the robot kept getting confused about which side it was on.
- Drive to the turn spot, about 37 cm out, in short measured legs, re-facing the wall between them.
- Turn around. Turns on this wooden floor slip, so the turn is checked by the camera against pictures of the room taken while docked.
- Back on in gentle nudges, re-checking the heading every few centimetres. It only counts as docked when charging current holds for 3 seconds, and then it says "Charging."
If it doesn't charge, it pulls forward and tries again, up to three times, then asks for help on Telegram. If it can't see the tags at all, it searches the room with ORB-SLAM (section 11).
Teaching it the dock
My first "dock line" came from geometry and kept landing a few centimetres off. So I drove the robot onto the dock by hand five times while it recorded where it was before turning around. The positions agreed to within about a centimetre and set both the line it lines up on (9.0 cm right of tag 0) and the turn spot (37 cm out). Then, to fix the blind turn, I had it take a picture every centimetre while creeping slowly off the dock, so while turning and reversing it can compare what it sees to where it should be.
What failed and how I fixed it
| Problem | Fix |
|---|---|
| Tag not detected at 30–80 cm: the webcam's autofocus kept hunting | Fixed focus (0 of 20 frames → 20 of 20) |
| Robot sure it was on the wrong side of the dock | A second tag: one pose solve from 8 corners |
| Wheels slipped, and even the slowest PWM was too fast | Pulses at first, then odometry and closed-loop speed control |
| The 180° turn came out 160° or 200° | Turn checked against the docked pictures |
| The dock's springs pushed the robot back off | Foam pads to hold the wheels (more problems, removed); then gentle nudges and "charging for 3 s" |
| Lined up on one tag instead of between them | Step 1 only finishes when it's on the line after facing the wall |
| Sidestepped into a beanbag from 1.6 m away | Drive toward the tags first; front IR stops sidesteps |
| Kept driving after I lifted it onto the pads by hand | Motors stop as soon as real charging current holds 0.6 s (below) |
# power_manager.py - while the robot drives itself
if charging and armed: # armed = it has been off the charger this run
since = since or time.time()
if time.time() - since >= GUARD_HOLD_S: # 0.6 s of real charging current
self.robot.stop("DOCKED - charging")
Room mapping and the lost-tag search
Docking only works when the robot can see the tags. If the 360° scan finds nothing, Qwen switches its tag tracker into monocular ORB-SLAM and searches: it drives slowly outward in gentle arcs, stops for obstacles, keeps a coarse map of where it has been so it heads somewhere new, and repeats the tag scan every metre or so. As soon as a tag is seen, normal docking takes over; if the search runs out of time, it tells me on Telegram.
ORB-SLAM3 runs on the Pi at about 5–10 frames a second. To test mapping I drove the robot around the room by hand. My first drive turned too fast: at 41°/s and 5.5 fps the view jumps about 7° between frames and tracking kept failing. Turning at about 9°/s on a second, longer drive gave a much better map.
The map shows the room's structure but isn't accurate enough for path planning. The weak link is heading: across the drive the robot turned a total of 8,474°, every spin on wood slips a little, and one camera has no true scale. That's why the map is used to search rather than to navigate. A gyro would fix most of it.
Operating modes
Power management and idle mode
- Battery LEDs, solid at every level: red at 25% or below, yellow up to 50%, green above.
- Low battery: at 25%, and idle for 30 s so motor current sag can't trigger it, it returns to the dock.
- Full: at about 90% (a charging-voltage threshold held for a minute) it says "Battery full" and drives 13 cm off the pads.
- No lift motion while charging: the servos' current disturbed the contacts. Only the remote-unlock face check may raise it.
- Idle mode: two minutes without motion turns off the camera, gestures and microphone, leaving only the motion sensor. The sensor rides on the head, so the robot ignores it while it moves its own head.
I estimate the average draw at about 7.5 W from the wall, mostly asleep in security mode: roughly 0.18 kWh a day, or about 73 cents a month at my utility's rate.
What broke along the way
| What happened | Cause | Fix |
|---|---|---|
| A servo and the amplifier fried (smoke) | Supplies weren't set before connecting: 15 V into a 5–7 V servo, and far too much into the 5 V amp | Set and measure every supply before connecting anything |
| Pi wouldn't power up, only the motors | The buck's + output was bridged to − on the back of the perfboard | Found with a continuity tester in half an hour |
| Everything shut off when charging started | The battery's protection board cuts the output while charging | Charge through the output wires; software stop at 90% |
| Motors ran at full speed while the ESP32 booted | The level shifter's pull-ups hold PWM high when nothing drives it | Planned: 10 kΩ pull-downs (until then, lift the wheels) |
| A wheel ran away during rework | A solder blob fell across a controller's pins | Removed it; never rework a powered board |
| Wake word stopped while the live view was open | The video thread starved the audio thread | Lower priority for the stream |
| Robot lost Wi-Fi after brownouts | Power dips emptied the network config on the SD card | Repaired the card; a boot service restores the config |
| Docking and the assistant fought over the camera | They started as separate programs | One process; the tag tracker borrows the camera |
The habit that saved the most time: after soldering each group of parts onto the perfboard, test it before moving on, so when something breaks you know exactly where to look.
How I used AI
I used AI assistants throughout, mainly to speed up debugging: reading logs and measurements with me to narrow a fault down faster, drafting code for subsystems I had specified, and checking datasheets and pin maps.
The decisions, the hardware and the testing were mine. I set the requirements, built, wired and soldered the robot, ran every test and judged the results on the real hardware, and caught the AI's mistakes, including a security requirement I had never asked for and fixes that were wrong until I measured what the robot actually did.
Results
| Feature | Status |
|---|---|
| Wake word, speech, local LLM, voice commands | Working |
| Hand gestures (5), owner face recognition, person detection | Working |
| Security mode, person tracking, alarm, Telegram alerts, smart-home link | Working |
| Closed-loop drive and odometry | Working |
| Docking and recharging, battery-full drive-off, idle mode | Working |
| Low-battery return to dock | Working |
| Room map / lost-tag search | Testing |
Future improvements
- Safety first: a main fuse and a fuse on the charging branch, a PTC fuse and TVS diode on the Pi's 5 V, 10 kΩ pull-downs on the PWM lines, a MOSFET for the flashlight, and an emergency-stop switch.
- A proper PCB to replace the perfboards (in progress).
- A gyro (IMU) for heading that doesn't drift with wheel slip: better turns, map and docking.
- A dock funnel or wider pads, so a few millimetres of error still lands on the contacts.
- A fan on the Pi, which reaches the low 80s °C with vision running.
What I learned
- Measure before tuning. The gesture overlay, the logic analyzer and the docking log each turned guessing into measuring.
- Change the problem when tuning stalls. A new gesture vocabulary beat a fifth threshold; a second tag beat clever single-tag logic; my own manual docks beat the geometry.
- Negative results point the way. The hoverboard replay and the mapping drift each led to the right next decision.
- Electrical decisions come from failure modes, not ratings: fuse placement, strapping pins, level-shifter pull-ups and battery protection all bit me or nearly did.
- Integration is its own engineering problem. One owner per shared resource fixed a whole class of bugs at once.