Few days back one of my colleague made a project named IoT enabled LCD display. I was just wondering where can I use this project. Then I came with an Idea what if I can get the top trending twitter hashtag on display so that while I am busy in my work that time also I am aware of whats trending on social media that too without visiting the app. Isn't it cool? Let's see how we can build this with the help of Bolt.
Bolt was recently launched via a Kickstarter campaign and was more then 484% funded. It is now available via Indiegogo Indemand. Click here to know more. Bolt IoT also offers a lifetime cloud access to the early adopters who buy it via the Indiegogo Campaign, so do check it out soon.
The use of an I2C enabled LCD display reduces the effort required to connect the LCD to half. It has only 4 connections (Compared to a regular 16*2 lcd which has 16).
Step 1) Connect the LCD to the Arduino as follows
- SCL of the lcd goes to A4 of Arduino.
- SDA of the lcd goes to A5 of Arduino.
- VCC of the lcd goes to 5v of the Arduino.
- GND of the lcd goes to Gnd of the Arduino.
Step 2) Connect the Bolt WiFi unit to the Arduino as follows
- Tx of Bolt to Rx of Arduino.
- Rx of Bolt to Tx of Arduino.
- Gnd of Bolt to Gnd of Arduino.
- Vcc of Bolt to Vcc of Arduino.
Please refer to the following Fritzing diagram to simplify your connections.
The LCD along with the Bolt unit draws quite a bit of current from the system. Use of DC adapter is recommended.
- If you have not already done so create a Bolt Cloud account here.
- Download the Bolt app (for Android and Iphone), and follow the steps in the app to connect your Bolt WiFi module to your WiFi. (Skip if already done)
- Download the Arduino code from here. Flash it into the Arduino Uno (Do remember to disconnect the Bolt unit while doing so. The serial programming sometimes gets messed up due to it's presence.)
- Login to cloud.boltiot.com and note the ID of your Bolt WiFi Module.
Now click on the API Tab and under the section for Generate Key, click on Enable.
Next click on the copy button to copy your API key. Your API key will may look something like this: f1f918e9-d9c2-4e5b-aed0-b7cb743f74cf
Step 5) Time for Coding. For this project, I am using Ubuntu 14.04 with python 2.7 but you can use other OS also, you just need to find out the alternatives for that or you can buy some online ubuntu server here www.digitalocean.com
First we have to install boltiot library. To do so you have to run below command in terminal.
sudo pip install boltiot
To know more visit https://cloud.boltiot.com/docs
Other library that is required is twitter. To install type:
sudo pip install twitter
Below is the complete python code for the same.
from twitter import * import requests from boltiot import Bolt API_KEY = 'Your API Key' DEVICE_ID = 'BOLTXXXX' twitter = Twitter(auth = OAuth("access_key", "access_secret", "consumer_key", "consumer_secret")) mybolt = Bolt(API_KEY, DEVICE_ID) #Create object to fetch data from Bolt results = twitter.trends.place(_id = 'Your Place ID') for location in results: for trend in location["trends"]: data_to_display = trend["name"] +' '+ str(trend["tweet_volume"]) response = mybolt.serialWrite(data_to_display) # Calling serialWrite function to display data on display connected to Bolt break