Exploring Rust and BLE: Building My Cycling Trainer App

Bike on Beach

I really wanted to learn Rust. I read their book and found a YouTube channel called Let’s Get Rusty, which discussed everything in the book. I completed the entire book and tutorial. Now, I’m thinking about what kind of project to work on.

Indoor Cycling

A little background: I do indoor cycling at home. I have a Wahoo Kickr Core and use the cycling trainer app called Zwift. Zwift costs $14.99 a month, which isn’t a cheap option. So, since I’m learning Rust, I thought, why not create my own cycling trainer app?

Bike Trainer

Bluetooth

I started with the basics, connecting the Rust app to Bluetooth devices. I used the btleplug crate as a Bluetooth Low Energy (BLE) central module library for Rust. I first implemented it to connect to my smartwatch to record heart rate, and then the smart trainer. I read and followed these documentations:

Desktop App

After setting up Bluetooth, I needed a user interface (UI). This is a desktop application, and I initially thought of implementing my own Rust GUI, but it seemed a bit too ambitious. That’s when I discovered Tauri, a library that lets you create desktop apps using Rust for the backend and choose from modern UI frameworks like React and Svelte for the frontend. This way, Rust shines in the backend, and we can use familiar frameworks in the frontend, making development easier.

Current App Development

I’ve completed the major functionalities of the app, making it usable for cycling workouts. This is still in the early stages, so there’s room for improvement. Here’s a list of the features that are already implemented:

  • Smartwatch heart rate Bluetooth support.
  • Wahoo Kickr Core Bluetooth support.
  • Loading Zwift (.zwo) workouts.
  • Displaying live data during workout sessions.
  • Spin Down Calibration.
  • Power and heart rate graphs.

Cycling Trainer Workout

Cycling Trainer Summary

Cycling Trainer Activities

Cycling Trainer Bluetooth

Future Plans

The app is now usable for workouts, but I plan to add more features to make it fully fleshed out. Here’s the checklist for what’s next:

  • Save session summary.
  • Workout interval graph.
  • Custom workout creator.
  • Strava and Garmin integration.

I had a lot of fun with this project. It’s a fun way to learn Rust and work with BLE devices. If you want to check out the repository for this project, you can find it on my GitHub.

Thank you for reading!