If you ever wanted to hang your friends' twitter wishes in a tree, here's your chance. This Christmas ornament ball will use Twitter's API to grab tweets with a certain hashtag, username or keyword and display them. All you need is a WiFi module, an arduino, an LCD display some cable and you're ready to go.
Step 1: Parts
Things you'll need:
1. Arduino Uno Rev 3 - Arduino Store
2. RN-XV WIfly Module - Sparkfun
3. 20x4 Serial Enabled LCD - Sparkfun
4. JST jumper cable - Sparkfun
5. A plastic ornament ball (about 5 1/2 inch or 14 cm in diameter) - Hobby stores
6. Power adapter - Adafruit
7. Extension cable - Adafruit
7. Some duct tape, masking tape and spray paint - Hobby stores
Step 2: Assembly
Hookup time. The wiring for this project is pretty straight forward. If you're having difficulty, Lifegraph has a great tutorial to setup your Wifly module.
Connect pin 3 of the Wifly to the 3.3v pin on the Arduino. Then connect pin 2 (TX) of the Wifly to pin 9 (RX) on the Arduino and pin 3 (RX) on the Wifly to pin 10 (TX) on the Arduino. Finally, connect pin 10 (GND) to GND on the Arduino.
The easiest way to connect the display to the Arduino is by using a JST cable (see: parts). You can use any JST cable you want, just make sure you don't get fooled by the color of the cables. Red doesn't always mean VDD. In my case (a standard sensor cable) red is signal, yellow is VDD, and black is GND.
In short: connect VDD to 5v, Signal to pin 2 and GND to GND.
Step 3: Code
We'll need 2 scripts. A small PHP script that uses the Twitter API to search for tweets and the Arduino script that calls the script every 60 seconds and displays the tweets.
To get the PHP part to work, Twitter wil ask for some authentication keys. The process is quite simple:
1. Go to https://dev.twitter.com/apps
2. Login and click on "create new application"
3. Fill out the form (you can leave the Callback URL blank) and click "create".
4. Click ‘create my access token’ on the next screen (you may have to refresh the page to display the token)
5. Copy the Consumer key, Consumer secret, Access token and Access token secret.
6. Go to https://github.com/Gelotology/tweetball and download ball.php
7. Upload the php file to your server.
Next up is the Arduino code, which is pretty much self explanatory. Download it at https://github.com/Gelotology/tweetball. Upload it to your board and you're ready to go.
Step 4: Painting the Ball.
Before you start painting, use a Dremel to cut out 2 small holes on the top of the ball for the Wifly's antenna and the power cable. Then apply some masking tape the size of the LCD's display (87.3 x 41.8 mm) and start spray painting. Let it dry for a bit before we start stuffing the ball with electronics.
Step 5: Final Assembly
Use duct tape to tape the LCD to the ornament ball. Go easy on the duct tape, however. You don't want to overheat the LCD. Then, simply tape the Wifly's antenna and power cable to the ball and connect the power cable to the Arduino. Stuff everything in there and close the ball.