Case study 05Embedded remote-control boat
KObait
A two-board embedded system for a bait boat: a handheld remote and a boat controller joined by a radio protocol of my own, with safety gates in front of the motors.
01 Overview
KObait is a remote-controlled bait boat for fishing. It carries bait out over the water, remembers saved waypoints and releases the bait through hatches. It is also my hardware lab, the place where software habits such as single ownership, explicit contracts and tests meet wiring, radios and batteries.
Where it is now. The system was rebuilt from its first generation into a two-board system with a long-range radio link and a screen on the remote. It is a bench prototype. The radio, displays, positioning and control logic work on the desk, and it has not yet been in the water.
Specification
- Boards
- Two: a boat controller and a handheld remote
- Radio
- Long-range link with a protocol of my own
- Safety
- A lost link stops the boat; gates in front of the motors
- Firmware
- C++; about 4,500 lines on the boat, 14,000 on the remote, partly generated
- Tests
- Host-side check scripts and 24 bench diagnostic sketches
- Only one part of the code may drive the motors, and tests enforce it.
- A lost radio link stops the boat. Autonomous return is deliberately not built until it is an explicit decision.
- The radio timing comes from a measured round trip, not from a datasheet.
02 Architecture
Two boards joined by a radio link. On the boat, the safety logic has the last word over anything the remote asks for.
Handheld remote
HardwareJoystick
stored calibration, diagonal mapping
- connects to Remote firmware
FirmwareRemote firmware
mixing, neutral-to-arm gate, sequenced commands
- connects to Displayperiodic
- exchanges with Radio module
ClientDisplay
custom UI framework, dirty-region repaint
HardwareRadio module
transparent radio, serial interface
- exchanges with Remote firmware
- exchanges with Radio protocol
Radio link
StageRadio protocol
framed, checked; paired, sequenced
- exchanges with Radio module
- exchanges with Radio module
Boat controller
HardwareRadio module
transparent radio, serial interface
- exchanges with Radio protocol
- exchanges with BoatLink
FirmwareBoatLink
accept, dedup, build telemetry
- exchanges with Radio module
- connects to Boat state machineaccepted
- connects to Propulsion authoritymanual
- connects to Bait hatcheshatch
FirmwareBoat state machine
sole mode owner: 6 modes, 13 stop reasons, failsafe stop when control goes silent
- connects to Propulsion authoritygate
- connects to AutopilotAUTO
FirmwarePropulsion authority
only motor-signal writer; ramp, pause, calibration
- connects to ESC controllersdrive
HardwareESC controllers
reverse-capable, two motors
FirmwareAutopilot
heading control to Home, A or B
HardwareWater, leak, battery
latched leak alarm, battery thresholds
- connects to Boat state machinestop
HardwareBait hatches
two servos, closed at startup
03 Hard problems
Radio collisions that looked like dead hardware
Problem
The first radio link looked like a dead uplink, even though both modules powered up and answered.
What I did
Separate test runs showed that every loss was two transmitters talking over each other. A schedule fixed it, with full delivery and zero checksum errors on the bench.
Timing from measured air time
Problem
A measured radio round trip made the original control rate and failsafe timeout physically impossible.
What I did
I re-derived every timing constant from the measurement. The trade-off, some metres of coasting before the failsafe stop, is documented as an estimate, not a measurement.
Stale commands after a reboot
Problem
A remote reboot restarted its counters, so the boat could reject frames or treat an old command as a fresh success.
What I did
The boat re-baselines once per outage and the remote ignores stale echoes. A session-aware protocol is designed but not yet built.
04 Decisions
- Range over water, with framing of my own.
- The radio is transparent. It has no packets, checksums or acknowledgements, so the firmware provides them.
- Stop, not return-to-home, when the link is lost.
- Autonomous movement after losing contact is a product decision that needs an explicit yes, not a default.
- A custom UI framework instead of an off-the-shelf one.
- The usual libraries need far more memory than the board has, and there is no framebuffer. The framework repaints only the regions that changed.
- Optional parts are non-critical.
- A display failure once left the boat in an infinite loop with the motor controllers live. Now the boat runs without a display, or without AUTO, instead of halting.
- The pairing ID is isolation, not authentication.
- It keeps two boats from answering each other's remote. It is not a security boundary, and the protocol documentation says so.
05 What I built
Boat controller
- Firmware organised around safety: explicit modes, a stated reason for every stop and gates in front of the motors.
- Waypoint navigation to saved points, gated off until its sensor is verified.
- Leak and battery alarms, a hardware watchdog and release hatches for the bait.
Radio and protocol
- A protocol of my own over a transparent radio: framed, checked, paired and tolerant of noise.
- Commands that are acknowledged, so each one is carried out exactly once.
- A schedule that keeps the two radios from talking over each other.
Handheld remote
- A remote with its own screen and UI, built on a framework I wrote for a very small memory budget.
- A calibrated joystick and a safe arming sequence. The output stays at zero until the stick is healthy and centred.
Tooling
- Single-purpose bench sketches for every part of the hardware.
- Host-side Python checks for architecture rules, control logic and protocol behaviour.
06 Status
Today
- Both boards run their firmware on the bench, and the radio link has been verified in both directions on a desk.
- Positioning, displays, the remote UI, joystick calibration and sensor baselines are verified on the bench.
- AUTO is gated off in firmware because one sensor does not respond on the current bench wiring.
- A second version of the remote interface is written, with a dashboard, a side menu with saved settings and text in five languages, but it has not been flashed to the bench hardware yet. An offline map is a separate prototype.
Next
- Motor controller characterisation with measured endpoints, then staged tests with motors, props and restraint, and a tethered water test.
- Outdoor range testing.
- A session-aware protocol and a decision on return-to-home.
Notes
No photos of the hardware are published yet. The plate at the top of this page is a schematic illustration, not a render of the boat.
07 What I learned
- Measure before you tune. The radio's real round trip rewrote every timing constant.
- On a machine with propellers, safety is structure. One place that can drive the motors, one owner of the mode, and tests that keep it that way.
- Writing down what has not been tested yet (no water test, no range test) is part of the engineering, not an admission.
08 Stack
- C++
- Arduino
- Python
Built with: credits and licenses
Adafruit GFX Libraryby Adafruit Industries
Graphics primitives on both boards; the remote’s ASCII text uses its 5×7 font.
Adafruit sensor and display driversby Adafruit Industries
Sensor and status-display drivers on the boat, through Adafruit’s driver, unified-sensor and bus libraries.
A sensor-data parserby Mikal Hart
Reads sensor data on the boat.
SdFatby Bill Greiman
SD card storage on the remote.
Servo and the Arduino AVR coreby Arduino
Motor-controller signals, serial, I²C, SPI and EEPROM on both boards.
A community display driverby David Prentice
Drives the remote’s display.