Last month, Paul Wallich brought you a bicycle-mounted lidar for detecting cars approaching from behind. I’m continuing the cycling theme this (Northern Hemisphere) summer with a bike computer designed for middle-aged eyes.
Like many people my age, I struggle to see the tiny display of a typical bike computer: I can’t very well put on my reading glasses while I’m pedaling. Also, I enjoy exploring unfamiliar roads, which makes navigation a challenge because I don’t carry a smartphone. My old CatEye cycling computer, which just reports how fast I’m going and how far I’ve gone, is no use at all in that regard.
There are, of course, commercial products that could help me navigate on my bike, but they are expensive, and their compact displays are, again, difficult to see—even for youthful eyes if you’re out in direct sunlight.
These issues led me to explore a DIY solution. My concerns about sunlight visibility meant my DIY cycling computer would need a reflective display of some type, but an alphanumeric LCD panel of the usual sort wouldn’t cut the mustard. I wanted really big numbers displayed. I also wanted it to be able to show a map bigger than a postage stamp.
The answer turned out to be already in my possession: A Kindle Touch e-reader. It was the perfect size—big enough to display a lot of information at once in a large font and to show me a decent chunk of a map without scrolling. Its E Ink display is clear and crisp even in bright light. And the price was right. The only problem was that I couldn’t hack its software to make it do what I wanted.
Building the bike computer required making hardware upgrades to a Raspberry Pi, adding GPS and Wi-Fi (top). With its battery pack, the computer fits easily into my rear saddlebag (second from top). Reed switches and magnets detect how fast the pedals and wheels are turning (bottom two photos).Photos: David Schneider (4)
This wasn’t just a technical issue; it was a legal one. Modifying such a gadget to operate in ways other than the manufacturer intended—even if you own the device—flirts with provisions of the Digital Millennium Copyright Act, bizarre as that may seem. The U.S. government (for odd reasons, specifically the Librarian of Congress) doesn’t want you to have full control of the software on your phone, tablet, or e-reader—even if it’s open source. But after some pondering, I realized that I could make the Kindle serve my needs without touching a single line of code running on it.
The trick was to use the Kindle’s “experimental” Web browser, allowing me to put the brains of the computer elsewhere, in this case on a US $20 Raspberry Pi Model A. The Raspberry Pi, being cheap and open, was perfect for the job. By plugging a suitable Wi-Fi dongle ($12) into its USB port, I could make it into a Wi-Fi access point. Run a Web server on the Pi and it can send HTML of your choosing to the Kindle to display.
My system consists of three parts: the Raspberry Pi and its battery (which reside in the bike’s saddlebag); a small PC board of my own design (which carries a $30 GPS module and plugs into the Pi); and a Kindle Touch (mounted on the handlebars using bits of foam pipe insulation and a few rubber bands).
Two reed switches mounted to the frame of my bike sense wheel rotation and pedal cadence by virtue of magnets attached to a spoke and to the inner chain ring. These switches are electrically connected to pins on the Raspberry Pi’s GPIO (general purpose input/output) port, allowing the Pi to know how fast the wheels and pedals are turning.
Eventually, I was able to get my Flask app to run automatically when the Pi powered up and have the Pi act as a captive portal, meaning that it served up my app’s output no matter which URL the Kindle’s browser was pointed to.
Next, I had to write a cycling-computer Web app that would look good on the Kindle’s E Ink display. There were two notable complications. One arose because of the way E Ink works. It’s very susceptible to ghosting, where pixels don’t properly switch to a new state, so Amazon.com’s engineers arranged for the Kindle’s browser to cycle the entire display from black to white and back again when a new page loads. This initially made for awkward flickering, because my initial app sent a new page with updated values every second. The solution was to use what’s known in Web-development circles as Ajax techniques to update just the necessary elements without sending a whole new page and triggering a refresh.
Another twist peculiar to the Kindle is that when it connects to a new access point, it immediately tries to reach Amazon. If it doesn’t get the right response, it won’t treat the access point as valid. The solution was simple: Have the Pi supply the Kindle with the short response it was expecting from Amazon.
In the end, I managed to pull together a system that shows distance, instantaneous speed, average speed, cadence, elapsed time, and clock time all at once, with digits large enough to read without squinting. Swiping and pressing buttons brings up other screens that offer such goodies as real-time mapping and logging. Even if you have to buy a Kindle for this project, the cost of the hardware involved is probably less than half what you’d be paying for a commercial unit with these capabilities.
This article originally appeared in print as “Take Your Pi for a Ride.”