I built some cadence controlled LED bike lights this week to put on my bike for this weekend’s Dunwich Dynamo – an annual overnight cycle ride from London to the coast.
Here is a quick demo of the thing in action:
Hardware
The cadence on the bike is measured by a Wahoo fitness cadence sensor, which detects each time the pedal passes it, as a magnet is fitted to the pedal. The Wahoo fitness sends a signal wirelessly via the ANT+ protocol, typically used for bike computers to display the info on the handlebar.
I used a Raspberry Pi computer with a Suunto USB Ant-stick to pick up the ANT+ signal, and also a Wifi USB dongle so that I could VNC from my phone into the Raspberry PI to make tweaks whilst I was on the ride.
The LED light itself was a strip I’d bought off of eBay.
I used an 13,000mAh Anker battery pack to supply power to both the Pi and the LED strip light.
Software
The code was based on:
Python ANT library – https://github.com/mvillalba/python-ant/
Tom Wardill’s HRM code – https://github.com/tomwardill/developerhealth
Haotianwooo’s Cadence code – https://github.com/haotianwooo/ant_raspberry/blob/master/only_cadence.py
Bibliopixel LED library – https://github.com/ManiacalLabs/BiblioPixel/
Implementation
The LEDs and Pi were wired up as follows:
Pi 5V – 5V on USB powers supply, +5V on LED strip
Pi MOSI – DI on LED strip
Pi SCLK – CI on LED strip
Pi GND – GND on USB power supply, GND on LED strip
To get the Suunto USB stick up and running, follow: https://www.johannesbader.ch/2014/06/track-your-heartrate-on-raspberry-pi-with-ant/
Install Python-ANT and the Bibliopixel LED library
I set it to run automatically when the Pi boots up, and installed TightVNCServer so I could log into in from my phone (set up phone tethering as a known wi-fi network on the Pi).
It worked well on the night, and the battery pack lasted the distance – it went from 100% to ~50% over the 11½ hours it was switched on.
My code used on the night ride can be found here: https://github.com/jimlondon/cadence-led/
Hi James,
which raspian version are you using? I am trying it on buster, but I am stuck with thousands of errors like
ImportError: No module named core
or : ImportError: No module named queue
This was back in 2016, so I’m guessing it was Jessie.