Main Content

I’ve been using a pedal generator for a few years now during the winter months, but this year decided to sign up with Zwift and see if I could integrate my pedal generator with Zwift. This Instructable will show how I tied my pedal generator and a charge controller to Zwift using an Arduino Nano 33 IoT. Zwift now controls the wattage (resistance) through the Arduino using the Bluetooth Low Energy Fitness Machine Service.
Some history first… I initially built the Zwift integration Arduino code using the Cycle Power Service, and was able to report the wattage to Zwift this way. A good first step, but was not the “full experience” of Zwift. I stumbled upon a blog post where Luke shows how to control a DPSxxxx controller using a modbus library with an Arduino. “Eureka!!!”, I thought - this is how I can control the wattage. I bought a DPS5020 and reworked my code to use the BLE Cycle Power Service and the Fitness Machine Service, and actually had a working version that controlled the resistance while training on Zwift! Yay! A few days later as I was writing this up to share, I decided to make a video of it. As I started things up to make the video, Zwift had an update - (rut row Shaggy). Sure enough, the update broke my code.
Back to the drawing board - I dug around and found people suggesting that trying to do both Cycle Power and Fitness Machine services in one Bluetooth service was problematic. Fortunately in my stumbling around the internet, I found Kris’ GitHub with the FTMS service already coded for Arduino, but with a different use case (retro fitting Zwift into a Tacx Flow ergotrainer). I refactored the code, integrating the DPSxxxx charge controller code I had used previously into the FMTS only BLE service and removing any of Kris’s code that didn’t fit my needs. Now I have a working Zwift pedal generator that automatically changes wattage resistance while in Zwift “erg” mode, and can also provide a more realistic ride in Zwift “sim” mode, adding resistance going up hills, reducing it while going down hill. Overriding sim mode is allowed as well, just manually change the amps to get 20 watts or more over the base and an OVERRIDE state will be triggered for the remainder of the ride. From there on, you manually change the resistance to whatever you choose - helpful if you want to challenge yourself on the sprints, or want to keep a specific pace on a group ride.
Putting this all together took many fits and starts, but I’m so excited to be able to fully experience Zwift on my pedal generator! A great big shout out to Luke and Kris for helping me get through some of the challenges!”

Link to article