Very software engineer Oscar Amado loves cycling. Bogotá, Colombia, where he lives, features many scenic places to ride, and heavy traffic means that cycling is the most efficient way to move around the city. After a 2019 cycling injury and the pandemic prevented Oscar from doing what he loved, he decided to gear up again in 2021.
Working with a cycling coach to get back up to speed, Oscar spent hours training on an indoor simulator. Training went well, at first, but as his training increased in pace and intensity, he began to look for a way to feel the wind in his hair again.
After some searching, Oscar found the perfect thing to bring more realism to his simulated rides — a smart fan from Wahoo. Unfortunately, $250 for a fan is not cheap, and it’s even more expensive when you consider taxes and shipping from the US to Colombia.
But that initial setback didn’t kill Oscar’s dream. After all, he works for Very and he’s used to working on all types of Internet of Things (IoT) projects, home automation, and smart devices. Rather than buy his ideal solution, he could build it. Using his skills as a senior software engineer, Oscar decided to give his tired wireless fan an upgrade. He decided to build his own smart fan.
Building a Smart Fan
Oscar’s existing wireless fan used infrared (IR) to communicate with its remote. He also wore a heart rate monitor to track his performance during rides. The heart rate monitor used the ANT+ protocol to transmit the heart rate to other devices. Ant+ is a low-energy communication protocol used in sporting devices like heart rate monitors, bikes, and shoes.
After considering these communication profiles and doing a little digging on the Internet, Oscar hatched his plan: he would use the output from his heart rate monitor to set the speed of the fan. The harder he worked and the faster he pedaled, the more wind the fan would blow. This would create the most realistic — and coolest — solution.
He purchased a Raspberry Pi Zero to use as the “brains” of the setup, a USB ANT+ adapter to communicate with his heart rate monitor, and an IR shield for the Raspberry Pi to prevent any feedback from the IR communication to and from his existing wireless fan.
Step 1: Finding the Heartbeat
Oscar’s first task was to make sure that the Ant+ broadcast worked properly. He booted up the Raspberry Pi, installed Python, and plugged in the USB Ant+ adaptor.
Next, Oscar had to find the right libraries to work with his version of the bike and heart rate sensors. Getting the Ant+ class working proved tricky because the reference documentation that Oscar found was out of date — the libraries had changed significantly since the documentation was written.
After some troubleshooting and testing, Oscar developed a script that correctly received an up-to-date heart rate broadcast from the monitor to the Raspberry Pi. Now, it was time to call the wind.
Step 2: Controlling the Wind
Oscar’s fan was controlled by an IR remote that he used to keep near his bike, but for the smart fan to earn the moniker, the fan needed to cycle through the levels automatically.
If you’ve ever programmed a VCR or set up a new remote control for your television, you know that IR is a mercurial beast. This fan was no different. To communicate with the fan, the Raspberry Pi needed to read the IR codes first, and then transmit signals later. To communicate over IR, Oscar installed the LIRC library onto the Raspberry Pi and used bash commands to send the corresponding IR commands for each fan speed.
At first, Oscar struggled with a lot of environmental noise — visible light — due to the brightness of the light streaming through his windows. To mitigate this interference, Oscar crafted a custom shade to shield the sensors, allowing them to communicate cleanly. With the sensors in place and functional, Oscar was able to set the fan speed from his Raspberry Pi.
Step 3: Stitching It Together
The Raspberry Pi could read Oscar’s heart rate over Ant+ and it could set the fan speeds over IR. All that remained was to use the heart rate to trigger the fan speed. Oscar spent about five hours building a simple version of this translation that included four levels. As his heart rate increased, the fan would ramp up, and as his heart rate decreased, the fan would slow back down.
A Solo Project With an Addictively Compelling Result
The first time he tested the fully functional smart fan, he found it absolutely addictive. He pedaled harder — sprinting — just to see how hard he could make the fan blow. The project was simple. It didn’t have a ton of features. But it worked well.
Wahoo, the manufacturer of the smart fan that originally inspired this project, is a huge company that sponsors professional race teams. Oscar reproduced the main features of their smart fan product all by himself in his spare time.
Oscar was ecstatic — so excited that even when he stopped cycling, his heart rate climbed up and over 100 bpm — and the fan kept pace to match his heart rate.
Oscar already has a few ideas for improvements that he’d like to implement: dealing with the variance of point-in-time heart rate monitoring, and using pulse-wave modulation to smooth out the fan speed controls. Even if he tends to understate his excitement and call out all of the ways that he could improve his smart fan, Oscar’s happily using it daily for training rides. In fact, he’s probably using it right now.
"It's pretty cool," he said when talking about the project.
We couldn’t agree more.
If you’re looking to join a team of spirited problem-solving engineers and designers, apply to one of our open roles. We’d love to talk.