The Kettler Racer 9 is an ergometer with USB and Bluetooth interface. Similarly, Kettler Treadmill "Track S5" also features a USB Port. Unfortunately both lack Bluetooth Smart support and therefore can not be integrated/used together with the Zwift App.
In order to be able to use mentioned fitness machnies as a source for Zwift, the project connects to the fitness machines over USB. The training data is polled and published over a BLE server. Everithing runs on Raspberry PI (tested with models 2, 3 and 4) and probably on other linux based systems:
- Kettler Racer 9 Ergometer: the instantaneous power value is published over Bluetooth Smart Characteristic "Cycling Power Measuermen 0x2A63 of the BLE Service Cycling Power Serivce 0x1818.
- Kettler Treadmill Track S5: Instantaneous speed and total distance are transmitted over BLE using RSC Service 0x1814 (Running Speed and Cadence Service) containing RSC Measurement 0x2A53 and RSC Feature 0x2A54
Inspired by the great work of 360manu and his great work published in kettlerUSB2BLE. However, I wanted to rewrite the functionality using Swift language on Linux. Again, there has been great work already done by the community, namely PureSwift
The Program tries to connect to the machines (Kettler Racer 9, Kettler Treack S5) over USB. After successfully establishing communication, the training status of the device is requestet every second and broadcasted over Bluetooth Smart Service "Cycling Power Service" or "Running Speed and Cadence" respectively.
To compile swift source code on linux, install swift on linux.
Repo: curl -s https://packagecloud.io/install/repositories/swift-arm/release/script.deb.sh | sudo bash
sudo apt-get install swift5
You can use Xcode to develop and compile the software on a Mac. To get a executable to be run on raspberry, the code must be compiled on the target-architecture (aarch64). Currently, the type of fitness machine type has to be choosen at compile time. Assign .racer9 or .track5 to machineType in main.swift (I'll add command line options in a future version).
let machineType : KettlerType = .track5 // .racer9
Fortunately, thomaspaulman created a handy script to rsync the code to the raspberry and run the compilation on the remote machine: Swish. Compile the source with the following command
$ swish <user> <host>
The compiled source can be found in the .build directory. To start for Kettler bike use
$ sudo kracerble/.build/debug/kracerble 2>&1
If you want to connect to Kettler Track S5 treadmill, you can pass the machine type parameter after specifying the serial port (better parameter handling coming in one of the next releases)
$ sudo kracerble/.build/debug/kracerble /dev/ttyUSB0 track5 2>&1
Open the Zwift app and choose the KRacer9 Service after selecting the "Power" - button in the pairing dialogue
You can broadcast random test values by uncommenting/commenting the following section in main.swift
//kettler?.provideFakeData()
kettler?.startPolling(portName)