Virtually Cycling the Alps With Arduino and StreetView
Here's how one dev created a top-of-the-line exercise bike with an Arduino board and access to the Google StreetView API years before such tech would become commonplace.
Join the DZone community and get the full member experience.Join For Free
The Tour de France is starting on Saturday, so it is a good chance to tell the story from six years ago when I created a virtual cycling environment using my indoor bike trainer connected to Google StreetView.
The idea came to me six years ago after I finished the Raid Alpine. The Raid Alpine is a cycle from Geneva, Switzerland to Nice, France over the classic cols in the Alps. It was a great cycle, and I thought it would be great to relive the experience during the winter from my garage using Google StreetView.
Timing was on my side as Google had just opened up its StreetView API, and they were offering a good free tier on the Google AppEngine. That made my stack choice:
Google StreetView, Maps, and Altitude APIs
Google GWT: Google Web Toolkit
This was the easy part, and coding it wasn't too hard, and with a bit of work, I got my site to look like this:
The key features being:
Display: Speed, Distance, Time
Map Showing GPX of Route and Distance Traveled
Connecting to My Bike
This was the tricky part — I needed some way to get connect my bike computer to my laptop. But I got lucky and stumbled upon Arduino. It appealed to me because the kit didn't need any soldering, so I could just connect some wires from my bike computer into the Arduino breadboard.
The next stage was to write some Arduino code to convert the bike computer speed and cadence readings into speed and cadence. This was fairly simple, as I could record the time it took for the sensors to complete one full revolution, then it was a few simple calculations:
Cadence = 60 / (end time - start time)
Speed = Wheel Circumference(m) / (end time - start time)s
The final piece of the jigsaw was to input the USB data into the browser. After looking around at options, including Native Chrome or some fancy Chrome Extension, I opted to use a hidden field on the website to take readings from the USB. I could then populate the hidden field using Selenium — simple, but it worked.
Putting it All Together
Here is a YouTube clip of everything working:
In a later version of the site, I used Ant+ technology to give me speed, cadence, cycling power, and heart rate. This was also interesting as it freed me up from hardware requirements, and you could just use your existing Ant+ devices like heart rate monitors (HRMs).
The biggest problem was the refresh rate on StreetView often made the site blurry.
As an idea, it was ahead of its time, and you are now seeing similar technologies coming on the marketplace.
My biggest problem was the free tier on the Google StreetView API increased as I put the site live, and the load I was creating made it obvious the costs were going to skyrocket.
I recently opted to not renew the domain, so the domain above is no longer active. But it was a great experience and nice side project encompassing a lot of technologies.
I still enjoy writing sports software, and it's getting more interesting with the range of IoT and Big Data options.
Opinions expressed by DZone contributors are their own.