Whenever it’s time to get off the office, I always check the traffic status to choose the best time to go home. But I couldn’t find a way to do that autonomously. So then …. I was up to make a system that shows me the current traffic status with the help of a simple tool that is used probably in all the offices, a wall clock ?
Using the 1Sheeld and Arduino, I can access the internet and check the traffic time duration (every 5 minutes) to my home and glow the clock green if traffic is clear, or red if is horrible ? Let’s check out the steps to know how to do it yourself!
Components
You will need:
1- A cheap transparent clock : actually I got this one for less than 3$ from IKEA, and I chose it transparent so that the RGB LED colors glow easily.
2- Arduino UNO: you can buy it from Arduino’s official store or even from Amazon.
3- 1Sheeld: Buy it on our store or from Amazon.
4- 12 RGB LEDs: Get 12 RGB LEDs to place them beside the 12 clock labels.
5- Jumpers and wires: To connect the LEDs with Arduino.
6- 9v battery: To power the wholes system.
7- Double face glue tape: To stick the LEDs to the back of the clock.
8- Soldering iron & solder paste.
9- Google Distance Matrix API: To get the traffic duration using 1Sheeld’s Internet shield.
Assembly
1- First you will have to solder the 12 RGB LEDs in parallel, stripping out the three wires (5v, Gnd, control), then test the LEDs before sticking them to the back of the clock.
2- Cut down small pieces from the double face tape and place them adjacently to the 12 clock numbers (Figures), then stick the 12 LEDs on them.
3- Make sure the three stripped wires are clear and little bit tall to connect them to Arduino & 1Sheeld.
Now it’s time for some coding ?
Code
So, I used three shields in my code: Internet, Clock and the Terminal (for debugging) shields.
But I faced a problem when trying to get the traffic duration to my home..! The API needs the current time to do so, and i should provide it in a UNIX time format along with my internet request (as parameter). I figured out that there’s a library called TimeLib that has a function called now() which returns the UNIX time format, But it just needs to be updated with the time once the application starts to run, and that’s why I used the Clock shield, to get the current time.
After that, I made sure that the sketch compiles without errors, then switched 1Sheeld UART switch to the uploading mode, uploaded, then switched back to communication mode as stated in the video. If you have any problems in uploading, check the 1Sheeld troubleshooting guide.
Smartphone Connection
Now, open 1Sheeld app, then choose the Clock and Internet shields, (you may open the Terminal shield to check the code status), and finally press Arduino’s reset button to send the Http requests to 1Sheeld application and the clock will show you the best time to go home.
The original post:http://1sheeld.com/get-traffic-status-on-an-ikea-clock-with-arduino-and-1sheeld/
Leave a Reply
You must be logged in to post a comment.