Designing an Automatic Bicycle Wheel Light PCB
February 24, 2021
While it’s still a bit cold to ride a bicycle right now over much of the United States (and the Northern Hemisphere in general), here in Florida, it’s a great time to get outdoors. The only small problem is that as the sun sets fairly early until daylight savings time starts. It’s therefore quite possible then that you might end up being out beyond sunset, and in that case it’s a good idea to have a light to keep yourself visible to others.
There are of course a plethora of commercial versions available, and I even implemented my own “manual” PCB light last year. Now, however, as I’ve gotten a bit more well-versed in PCB design, I decided to create a bike light that comes on automatically as the wheel is moving. Like my previous designs, I turned to the small-but-mighty ATtiny85 to cycle through the lights, adding on a “fast”–i.e. easily triggered–vibration sensor to activate the program.
These little sensors, available from Adafruit, eBay, and elsewhere are interesting devices in that they act as simple switches thanks to a spring contact inside. They require no power, and as a switch they can be used to reset the ATtiny or provide power to turn them on. The original idea is that I would activate the reset when it hits a bump. The ATtiny85 would then go through its cycle for a set amount of time and turn off when idle.
First PCB: Success and Revision
(Image Credit: Jeremy Cook)
I designed my first PCB to strap onto spokes using zip-ties, and thanks to a bit of laser-cut prototyping the geometry looked very good. Unfortunately, on the first version I did make one error in that one of the holes for the vibration sensor was not large enough, which was fixed with a bit of “creative” soldering and the use of epoxy.
The other error here was not so much a mistake on the PCB, as an error in judgement about how these sensors are activated. While they are certainly triggered via bumps, when the wheel is spinning fast enough, this centripetal acceleration of the wheels is great enough that it keeps the switch closed. The result is that at low speeds, the device works as intended, but when you’re going fast enough the lights don’t actually come on.
Second PCB: Conceptual Changes
(Image Credit: Jeremy Cook)
For my second try at this type of PCB, I instead wired up this switch to the power input of the ATtiny85 PCB. While this seems obvious in hindsight, I didn’t expect these switches to be activated by the continuous rotation of the wheel. With a capacitor implemented to steady the voltage out, it’s able to shine while moving at a higher speed.
One downside is that it doesn’t generally come on at low speeds, and the thought that such a setup could be done without a microcontroller whatsoever has certainly crossed my mind. The other problem is that when I stop or slow down the bike at a crosswalk or for whatever reason, the light turns off very quickly, leaving the wheels dark. In part for this reason, I also carry another “manual,” purchased light that I also activate when it’s dark out.
Foray into Surface Mount Technology
(Designing surface-mount wheel light in open source KiCad EDA - Image Credit: Jeremy Cook – screencap)
The other big change from the rev 0 to rev 1 PCB was that I decided to embrace surface-mount technology, or SMT in its construction. I’d been hesitant to use this method, as it seemed like one more turn down the seemingly infinite electronics rabbit hole. However, with the proper equipment–such as this hot air gun–it’s not that hard. In fact, once you get used to it, it likely saves you time, and definitely saves a ton of space (and thus expense) on your PCBs.
That being said, it’s a great way to level-up your design and build capabilities. While I’ll certainly keep using through-hole technology (THT) when appropriate, I don’t see myself going back to that paradigm in its entirety again.
So, is this a good design? Yes and no. The battery runs out much faster than I had anticipated in the second iteration, and there is the big drawback that it doesn’t stay on when you’re still. That aside, it was a great learning experience, significantly broadening my capabilities. With the availability of custom-made PCBs, along with a variety of electronic design automation (EDA) packages, there’s never been a better time to experiment. PCB files are here on GitHub if you’d like to experiment, and I’m selling leftover boards on Tindie, even with their various faults.