- C 48.1%
- HTML 30.5%
- C++ 15.8%
- Kotlin 3.6%
- Rust 1.2%
- Other 0.8%
|
|
||
|---|---|---|
| app | ||
| docs/images | ||
| firmware | ||
| hardware | ||
| laptop | ||
| .gitignore | ||
| .gitmodules | ||
| LICENSE | ||
| README.md | ||
| THIRD_PARTY_NOTICES.md | ||
SmartWatch
A smartwatch built from scratch: custom PCBs, firmware for four separate microcontrollers, and an Android companion app. This is hardware revision V6 ("Mark VI").
Everything lives in this one repository. The full commit history of each project was merged in when the separate repositories were combined, so git log -- <folder> still shows each project's own history.
Contents
- What it does
- How it fits together
- Hardware
- Repository layout
- Building and flashing
- Further documentation
- License
What it does
On the watch
- Watch face with date, time and seconds, battery, BLE status, the phone's now-playing track, and the current temperature
- Phone notifications and incoming calls, relayed over BLE, with haptic feedback
- Alarms, timers and an hourly chime; alarms can also be edited from the phone
- Calendar, weather forecast, and a university timetable synced from the phone
- TOTP authenticator (two-factor codes), with accounts imported on the phone, including from QR codes
- Emergency card (contact details, stored as a vCard)
- An encrypted private LoRa link (2.4 GHz) to a home-automation system
- Sensors: pressure with a day of history and its trend, light in lux, a compass, a spirit level and temperatures
- Wrist gestures and display auto-rotation
- A demo mode: a self-running tour of everything here, for showing the watch to people
- LED animations on the charlieplexed LED matrix
- Hot-pluggable expansion modules on the two side USB-C ports (magnetometer, ToF distance sensor, IR thermometer)
- Games and tools: Minesweeper, Hexcells, dice, coin flip, random numbers, and a subnet-mask calculator
- Doom (E1M1), in a separate build:
pio run -e doominfirmware/main, see its README - A USB serial console for debugging, screenshots and flashing (
firmware/main/scripts/watch.py)
Idle power is the main design constraint. The main MCU spends nearly all its time in STOP2 sleep and wakes only on a button, the RTC's one-second tick, BLE data, the charger, or an IMU gesture. Every peripheral is powered only while it's in use.
In the companion app (Android, app/)
- Forwards phone notifications and incoming calls to the watch; a call can be answered from the watch
- Syncs alarms, weather (Google Weather API), the timetable, TOTP accounts and the emergency card
- Runs as a foreground service that reconnects on boot
On a laptop (Arch Linux with KDE Plasma, laptop/)
- Connects alongside the phone and lives in the system tray
- Forwards desktop notifications, with a per-app blacklist (KDE Connect is blocked by default, since the phone already forwards those)
- The watch's media and volume keys can control the laptop instead of the phone, switchable on the watch or from the tray
- Shows the laptop's track on the watch face, and "find my laptop" from the watch
How it fits together
flowchart LR
phone["Android app<br/>app/"]
subgraph watch["Watch"]
nrf["nRF52810<br/>BLE bridge<br/>firmware/ble"]
main["STM32U575<br/>main MCU<br/>firmware/main"]
sec["STM32G031<br/>secondary MCU<br/>firmware/secondary-mcu"]
led["STM32L031<br/>LED MCU<br/>firmware/led-mcu"]
lora["SX1280<br/>LoRa 2.4 GHz"]
end
home["Home automation"]
phone <-- "BLE GATT" --> nrf
nrf <-- "SPI, framed protocol" --> main
main <-- "I2C 0x15" --> sec
main <-- "I2C 0x42" --> led
main <-- SPI --> lora
lora <-. "AES-128-GCM" .-> home
| Chip | Role | Talks to the main MCU over |
|---|---|---|
| STM32U575VGT6 | Main MCU: UI, apps, sensors, power management, scheduling | — |
| nRF52810 (S112 SoftDevice) | BLE peripheral bonded to the phone; relays notifications, status and data both ways | SPI with a DATA_READY line that also wakes the main MCU from STOP2. Protocol: firmware/ble/README.md |
| STM32G031G8U6 | Secondary MCU: scans and debounces the keypad, routes power and USB on the two side USB-C ports, wakes the main MCU | I2C address 0x15, plus the COM1/COM2 interrupt lines |
| STM32L031G6U6 | LED MCU: drives the charlieplexed LED matrix and plays animations by itself | I2C address 0x42. Protocol: firmware/led-mcu/src/LedAnimProtocol.h |
| SX1280 | 2.4 GHz LoRa radio for the home-automation link (lora_secure submodule) |
SPI (RadioLib) |
Hardware
The watch is a stack of three boards in a 3D-printed case with a clear cover. KiCad projects are in hardware/.
| Board | Current revision | What's on it |
|---|---|---|
| Top board | top-board-V2.0 |
SSD1306 128×64 OLED (mounted rotated 180°), LED MCU (STM32L031) with the LED matrix, BMI270 IMU, BMM350 magnetometer, BMP388 barometer, LTR-303 light sensor, FRAM (FM24CL64B), antenna |
| Middle board | middle-board-V1.1 |
STM32U575 main MCU, STM32G031 secondary MCU, nRF52810 BLE, SX1280 LoRa with an RF switch, BQ24073 charger, BQ27441 fuel gauge, TPSM8286x buck converters, DRV2605 haptic driver, eMMC/SD card, the keypad, and two USB-C ports |
| LED board | LED-board-V1.1 |
White LED strip along the top edge (a flashlight), with a thermistor |
The other board folders (*-V1, top-board-V1.1) are earlier revisions, kept for reference. Each current board folder also has an interactive BOM (bom/) and production files (production/). 3D/ holds 3D models and ART/ the silkscreen artwork.
The Jolteon line art on the top board was traced by hand from artwork by olyester (@cco00oo). The bottom of the top board has a boykisser. Credits for all the artwork are in THIRD_PARTY_NOTICES.md.
Rework on the middle board: bodge wires next to the nRF52810 and the STM32U575.
Repository layout
.
├── firmware/
│ ├── main/ STM32U575 main firmware (PlatformIO, Arduino framework)
│ ├── ble/ nRF52810 BLE bridge (nRF5 SDK 17.1.0, Makefile + arm-none-eabi-gcc)
│ ├── led-mcu/ STM32L031 LED animation firmware (PlatformIO)
│ │ └── master-lib/ LedWatchController: the main MCU's side of the LED protocol
│ └── secondary-mcu/ STM32G031 keypad / USB / wake-up firmware (PlatformIO)
├── app/ Android companion app (Kotlin, Gradle, package com.watchbridge)
├── laptop/ Laptop companion for Arch Linux (Rust, GTK 4 + system tray)
├── hardware/ KiCad projects for the top, middle and LED boards
└── docs/images/ Photos used in this README
| Folder | Was previously |
|---|---|
firmware/main/ |
SmartWatch-code |
firmware/ble/ |
SmartWatch-BLE |
firmware/led-mcu/ |
SmartWatch-LED-MCU |
firmware/secondary-mcu/ |
SmartWatch-secondary-mcu (no-sleep branch) |
app/ |
SmartWatch-compation-app |
hardware/ |
smart-watch-board |
Building and flashing
Clone with the submodule; firmware/main needs lora_secure:
git clone --recurse-submodules ssh://git@forgejo.vratk0529.com/vratk0529/SmartWatch.git
# or, in an existing clone
git submodule update --init
Main firmware — firmware/main
Needs PlatformIO. The toolchain and every library are pinned, so a fresh checkout builds as-is.
cd firmware/main
pio run -e custom_u575vgt6 # build
scripts/watch.py flash # flash over USB through the serial console, no buttons needed
pio run -e custom_u575vgt6 -t upload # or flash via DFU
scripts/watch.py info # check that it's alive
pio test -e native # host-side unit tests
Two local headers are gitignored and optional, so a fresh clone builds without them:
include/passwords.hholds the LoRa key (LoRa24Key). Without it the build prints a warning and uses an all-zero key, so the LoRa link won't talk to a real gateway.include/name-bitmap.hholds the owner's name, drawn as a bitmap on the Info screen. Without it the screen shows plain text.
For a few seconds after every reset the firmware stays awake (BOOT_ATTACH_WINDOW_MS), so a probe or DFU can always attach, even if a change breaks sleep. See firmware/main/docs/uploading.md for recovery.
BLE firmware — firmware/ble
Needs the nRF5 SDK 17.1.0 (with the S112 v7.2.0 SoftDevice) and arm-none-eabi-gcc. The Makefile expects the SDK at firmware/SDK/nRF5_SDK_17.1.0_ddde560; to use it from somewhere else, override the path:
cd firmware/ble
make SDK_ROOT=/path/to/nRF5_SDK_17.1.0_ddde560
The main firmware doesn't need this rebuilt, only the nRF52810 when its protocol changes.
LED and secondary MCU firmware — firmware/led-mcu, firmware/secondary-mcu
PlatformIO projects flashed and debugged with a Black Magic Probe. upload_port in each platformio.ini points at a specific probe, so change it to match yours.
cd firmware/led-mcu # or firmware/secondary-mcu
pio run -t upload
Companion app — app
Open app/ in Android Studio, or build from the command line (JDK 17, Android SDK 34, minimum Android 8.0):
cd app
echo "<your Google Weather API key>" > google_api_key # optional, gitignored; weather is disabled without it
./gradlew assembleDebug
Laptop client — laptop
Rust, for Arch Linux with KDE Plasma (BlueZ, PipeWire). See laptop/README.md.
cd laptop/arch
makepkg -si # build and install the package
Further documentation
firmware/main/docs/: the serial console, building and uploading, and a code map of how a button press, a notification and a setting travel through the codefirmware/main/CLAUDE.md: a condensed architecture overview covering the sleep and power design, the UI screen stack, settings storage in FRAM, and crash recordsfirmware/ble/README.md: the nRF52810 ↔ STM32 SPI protocol and the GATT service the phone talks tofirmware/led-mcu/src/LedAnimProtocol.h: the LED MCU's I2C command set
License
The firmware, app and PCB designs are released under the MIT License. Bundled third-party code keeps its own license (LGPL-2.1, BSD-3-Clause, Apache-2.0 and the Nordic 5-Clause license). The silkscreen artwork in hardware/ART/ is not licensed at all. THIRD_PARTY_NOTICES.md has the details.


