Catching The Bus From The Couch!

posted Aug 15, 2016, 9:22 AM by Srijith Jayakumar   [ updated Aug 17, 2016, 5:22 PM ]

Hurray!!. This is my first Arduino project and would like to share with all makers out there. I am just getting started in this wonderful world of electronics and circuitry. After playing with few example projects  that was part of the arduino starter kit, I wanted to do something useful which I can use everyday. The idea of having always-on display with bus arrival information seemed as a good starting point to take my learning to the next level. Lets get into the ABC of this :)

API

LTA publishes variety of transport related data as rest API's for public and community use. Just quickly created an account received the API keys, tested few request from using RequestMaker.. Bingo the data is ready!!

Bill Of Materials

Now lets do some shopping. This little device will be in my living room connected to my home WiFi so need a arduino compatible WiFi board and a decent LCD.  After some quick search in google I narrowed down to the following

  • Arduino Wifi Shield
  • ESP8266 Boards

ESP8266 was my pick as it was super cheap and I immediately ordered few from Ali Express. While waiting for the board to arrive (Usually Ali Express orders take 20~30days turnaround time for free shipping) found that there are many variants of ESP8266 and the one I ordered was not a good choice. Head to this post to know more on ESP8266 variants.

The next hardware is LCD display. My arduino starter kit came with a 16 * 2 display. For this project I needed a little bigger content display. So ordered a 20 * 4 LCD display with I2C interface which is just 4 wire hook-up which reduces lots of wire clutters.


 S.No     Part Type Amount Link    
 1 LoLin Node Mcu ESP8266 v3 2.78 USD
 Ali Express
 2 20*4 I2C Serial Blue Backlight LCD 5.60 USD
 Ali Express

Circuit & Code

Circuit connections are pretty simple and straight forward as below.



I2C LCD just has four pin to connect as below.

 LCD    ESP8266 Comments
 GND GND 
 VCC 3V3 LCD Takes 5v Input. It was working with 3.3v. The display was little dim however
 SDA D1 Data Line
 SCL D1 Clock

Here is the high level breakup of the code
  1. Connect to WiFi
  2. Get current Time from NTP and sync Clock objects
  3. Connect to LTA and invoke REST API to get Bus Arrival Time (Response is in JSON Format)
  4. Parse the JSON response
  5. Calculate time difference and display.

The code is available in GitHub. I am completely aware that my code can be fine tuned and optimized. My code is sort of copy-paste work from various online resources available. I have tried to give attributions as much as possible.

Library's Used

Little tricky part working with arduino is to know which library to use for your hardware. After some trial and error found the following libraries works good for my setup.

Pics









In Action

Bus Arrival Timings in Action


Packaging


Enjoy Making & Hacking!!

1-1 of 1

Comments