“Life is too short for traffic.”- Dan Bellack, Professor at Trident Technical College
We all hate traffic jams, right? Being stuck in traffic is all well and good if you are in a contemplative mood, but for most of us, it feels that the time wasted sitting in a jam could always be put to better use. Behold! I have found a neat solution for avoiding traffic after searching through the realms of the Internet, and I am thankful to Eslam Ali who made this project and put it out for all the makers looking for something new to tinker with. Today I am going to talk about building your own Traffic Indicator with the help of Arduino, 1Sheeld and Google Maps API.
Alright, let’s first see what all components were required to build this project. I used:
- Arduino Uno
- RGB LED
- An Android Smartphone with 1Sheeld app installed (you can also use iOS)
- Laptop with Arduino IDE installed
- USB A to B
- Jumper Cables
Before I start with the whole how-to-do bit, let me put forth a message of sorts. I am new at this making business, so this is something that most of the experienced makers already know, but for folks like me, who have just started out here goes:
the joy of making is not merely in the success of your end product, it is also in the labour you put and the lessons you take home from your mistakes.
I’ll not simply outline and explain the steps involved to make this project so you may do-it-yourself; I’ll take you through all that was involved in building my own traffic indicator, complete with failed steps, small hacks and all the troubleshooting. That, I hope, shall be helpful in you grasping what Do-It-Yourself is all about.
My first step was to get familiar with API: Application Programming Interface. I found some info that was both cogent and easily digestible about what an API is and how to work with it; you can learn more here. I also tinkered a bit with RGB LED before proceeding further. You can play around too if you like; visit RGB to know more. I then created a free developers account for using Google Maps Distance Matrix API and read up on it in the documentation.
Next up, I plugged the 1sheeld onto the Arduino Uno board, connected the RGB LED to the appropriate pins via resistors and installed the 1sheeld app on my Android phone. In my Arduino IDE I added 1sheeld library and then picked up the required code from traffic.ino. Now, you’ll need to change certain fields in the code, namely the latitude, longitude for the origin and the destination of your choice as well as the API key with the one that you’ll get from Google Maps API. Once I had made the appropriate changes, I uploaded the code on to Arduino via 1sheeld (take care to put 1sheeld in upload mode; once done uploading then switch it to operation mode) and in the Android app, I connected to 1sheeld and selected Internet and Terminal shields, connected 1sheeld via bluetooth to app. Moment of truth closed in on me as I pressed reset upon the 1sheeld; <JSON_KEY_CHAIN is wrong> showed the terminal window, it didn’t work. It was time to take a step back and reassess the situation in order to troubleshoot.
I later recognised the problem was due to using an expired API key, so make sure that your API key is updated (copy updated key from your Google developer’s account). This was not the end of my problems, since now I was not even connecting and sending a request to Maps API. The issue was due to connectivity problems between 1sheeld app and the shield. A simple reboot of the app and re-connecting via bluetooth solved this and viola! My traffic indicator was up and running.
I would like to thank Eslam Ali again for not only making this project public, but also for being kind enough to answer my queries regarding his post on this project. However, I am not satisfied completely working with 1sheeld, especially the app on Android, so I am gonna work this out with an Ethernet Shield and see how that goes.Will update soon about the results I get. Till then, farewell and Happy Making!
I must thanks Mr. Amr Saleh of Intereight for sending us the 1Sheeld as a Gift