Next project
Outreach Initiatives and Community Awareness


16x2 LCD Twitter Client – Tweet to my door (Arduino)

 

Objective:

The end goal of this project is to build a device that will display tweets on a 16x2 character LCD screen. This screen is small and can therefore be mounted on a door or at the side of a desk. Along the way, the engineering student will learn how to program an Arduino microcontroller as well as write a Python script. They will get involved in the world of embedded Linux and understand how to use the Twitter OAuth API.

The Arduino microcontroller was chosen because of its ease of use. The Arduino has many features that appeal to beginners such as it's headers for easy wire connection, built-in crystal resonator, built-in voltage regulator and built-in FTDI chip.

Python was chosen as the programming language for the desktop program because it has a gentle learning curve. The beginner programmer does not need to know about pointers or other low level mechanics to make a program work. The tweepy library is available for Python so this makes it easier for the beginner programmer as they need not create the HTTP requests themselves.

A Linux distribution was chosen as the operating system because it has many features that appeal to programmers. Linux has the cron scheduler to make the Python script run on a given time interval to update with the latest tweets. Linux has the advantage of being cross-platform so that our software can be run on regular x86 computers as well as ARM computers such as the Raspberry Pi.

Description of project:

This project uses the OAuth API to get tweets from a users Twitter feed. It then sends them to a serial port where the data is read by an Arduino microcontroller and then displayed on a 16x2 character LCD display. The LCD is small in physical size and can be mounted in many places such as on a door. This is useful for a person who would want to leave a message on their door without actually going to their door. As long the person can access Twitter, they can change what their door says from anywhere in the world. An example would be if a person was in a meeting, they could update their door without leaving the meeting telling anyone who wants to visit the person that they are unavailable.

This could also be modified to follow somebody else's Twitter feed. One could follow a news feed on Twitter and the LCD display would give them live news updates right on their desk.

When the student completes the lab they will have learned about engineering design processes. They will understand how the project works and they will be inspired to make innovations. Knowing about how the hardware and software works, they will be able to adapt it to their own needs.

Hardware Components:

 

  • 5kΩ trimmer -  adjusts contrast by adjusting voltage at pin 3 (V0) on the LCD display
  • Solderless breadboard – to hold trimmer and make connections.
  • Wire – for connecting everything together

Software Components:

 

Tools:

  • Soldering tool, solder and flux – for connecting wires to the LCD
  • Wire stripper – for removing insulation from wires

 

Method:

  1. Create a Twitter account for this project.
    1. Go to www.twitter.com and fill in the sign-up form. Validate the account by clicking on the link sent to your email.
  2. Create a Twitter application for this project.
    1. Go to https://dev.twitter.com/apps/new and login.
    2. Give the application a name, description and website. The URL of the website is not important. Leave Callback URL blank.
    3. Accept the “Developer Rules of the Road”
    4. Complete the CAPTCHA and press next
      screenshot
  3. Get the OAuth keys
    1. Leave the Access Level to read-only
    2. Click on “Create my access token”
    3. Copy the Consumer key, Consumer secret, Access token and Access token secret into a place where they will be remembered.
  4. Add the application to your account
    1. Go to https://twitter.com/settings/applications and verify that the application has access
      twitter screenshot
  5. Install tweepy – in Linux terminal type: sudo pip install tweepy and press enter
  6. Add the OAuth keys to the Python script.
    1. Open the file twitter_lab_test.py in an IDE such as Geany and complete the following lines:
    2. CONSUMER_KEY = '<Consumer key>'
    3. CONSUMER_SECRET = '<Consumer secret>'
    4. ACCESS_KEY = '< Access token>'
    5. ACCESS_SECRET = '< Access token secret>'
    6. Where <variable> are the keys from step 3
    7. Save the file
  7. Test out the application.
    1. Go to your Twitter page (https://twitter.com/<twitter username>
    2. Click on “compose new tweet” button on the top right corner and tweet something.
    3. Open the lab files directory in a terminal. Type: python twitter_lab_test.py and press enter. If your tweet is displayed in the terminal, everything is working.
  8. Solder wires the the LCD.
    1. For each wire do the following:
      1. Strip away about 0.5cm of insulation
      2. Twist the wire so that all the strands are together.
      3. Apply a small amount of flux to the wire.
      4. Feed the wire through the appropriate hole on the LCD.
      5. Apply a small amount of solder to the tip of a soldering tool and press the solder into the joint to secure the wire into the hole.
    2. Do this for LCD holes: 1,2,3,4,5,6,11,12,13 and 14.
  9. Connect the LCD to the Arduino
    1. Connect the wire from LCD pin 1 (Vss) to GND on the Arduino by going through the breadboard.
    2. Connect the wire from LCD pin 2 (VDD) to 5V on the Arduino by going through the breadboard.
    3. Connect the so that the two ends, pins 1 and 3, and connected to 5V and GND respectively.
    4. Connect the wire from LCD pin 3 (V0) to pin 2 on the  5kΩ trimmer.
    5. This should look as follows
      breadborad potentiometer
    6. Connect the wire from LCD pin 4 (RS) to Arduino digital pin 12.
    7. Connect the wire from LCD pin 5 (R/W) to Arduino GND.
    8. Connect the wire from LCD pin 6 (E) to Arduino digital pin 11.
    9. Connect the wire from LCD pin 11 (D4) to Arduino digital pin 5.
    10. Connect the wire from LCD pin 12 (D5) to Arduino digital pin 4.
    11. Connect the wire from LCD pin 13 (D6) to Arduino digital pin 3.
    12. Connect the wire from LCD pin 14 (D7) to Arduino digital pin 2.
    13. This should look as follows:
      arduino schematic
    14. Upload Arduino sketch
      1. Plug the Arduino into the PC with a USB cable.
      2. Open the Arduino IDE.
      3. Open the file SerialDisplay_Twitterfeed.ino in the directory  SerialDisplay_Twitterfeed.
      4. Press the Upload button
    15. With a flat-tip screwdriver turn the trimmer until the LCD display becomes readable. It should say, “Updating...”
    16. Make it display tweets.
      1. Open the file twitter_lcd.py in a programming IDE.
      2. Repeat the steps from step 5 for entering the keys.
      3. Open the directory where twitter_lcd.py is found in a terminal and type: python twitter_lcd.py
      4. If all is working, the first 26 characters of your latest tweet is displayed on the LCD along with the time that it was tweeted.
    17. Make it automatic.
      1. Copy the file twitter_lcd.py into your /home/<username> directory
      2. Make it executable. Right-click file, go to properties, permissions and check “Make the file executable”
      3. Alternatively, open the directory in a terminal and type: chmod 700 twitter_lcd.py, then press enter.
      4. In the terminal type: crontab -e , then press enter.
      5. Add the following line: */1 * * * * /home/<username>/twitter_lcd.py replacing username with your Linux username.
      6. Press Ctrl+O.
      7. Press enter.
      8. Press Ctrl+X
      9. The LCD will now be automatically updated every minute.

 

Final Product:

Arduino twitter

arduino twitter LCD

arduino schamatic layout

 

Areas for improvement:

This lab teaches the student many different concepts related to electrical and computer engineering. They will learn about the basics of these fields so that they will be able to learn more advanced concepts in these fields. With this new knowledge of electrical and computer engineering the student may wish to make the following modifications:

  1. The LCD screen only displays the first 26 characters of a tweet. With a bit of extra coding, the LCD screen could scroll the tweet so that the entire thing can be read.
  2. The LCD screen has support for an LED backlight. An improvement would be to make the backlight go on when it's dark by adding a photo-resistor.
  3. Adding a color and graphical LCD screen would be more aesthetically pleasing.
  4. Remove the solderless breadboard by soldering everything on a regular breadboard and use a header to plug into the Arduino.

 

This project would be appropriate for high school students in grades 11 and 12. Physics and computer science courses are available for these students so that they will be able to follow along with the concepts described in this lab.

 

Other Projects
Networked Thermometer
Networked Thermometer Thermometers are old. They are useful: superb tool to control experiments in science labs, monitor body heat, get weather data, save devices from overheating as your flat screen tv, and car engines. Continue >>
Arduino Lilypad Remote Mouse
Arduino Lilypad Remote Mouse Control your computer's mouse with this homemade remote-control. Build touch switches completely in software and then link the remote to the computer via infrared. Continue >>
Optical Network Made Easy
Optical Network Made Easy Optical communication is fast, cheap, and reliable. Build your own prototype of a peer-to-peer network using laser. Understand how big Rogers, Bell and use Fibre to connect you in lightning speed to... Continue >>
Paper Music Player Tutorial
Paper Music Player Tutorial Play music from paper as if the paper was an "ipod". You build a system that senses capacitive touch on pencil shaded shapes on paper. With these touches music is controlled. Continue >>
Professional Circuit Drafting
Professional Circuit Drafting CAD drawing gives you professional grade circuit schematics and prototype models. Learn to communicate design of electronics and hardware innovation like the professional engineer. Continue >>
Internet Controlled Lights
Internet Controlled Lights Use internet to make lighting during Christmas or other occasions dance! Surprise your buddies with LED sequence control. Make decoration energetic during your sweet holidays. Continue >>
Knock to Ring Bell
Knock to Ring Bell Make a complete musical bell system that rings with your knock. Possibly, this may reduce door banging or frustration at dormitory doors that aren't allowed to have buttoned door bells, yikes! Continue >>
Raspberry Pi Tweet to my Door Raspberry Pi Tweet to my Door Raspberry Pi connected to colour display wirelessly. Show your twitter updates on a screen attached to your door at school's club office, classroom, treehouse room. Display to your audience your... Continue >>
Gesture Pong Game
Gesture Pong Game Build your own motion tracked game and console similar to Kinect or Wii. Inside is code and design helping you make the classic Pong Game. Play the game as you move on your tv or monitor. See step by... Continue >>
Self-Driving Car
Self-Driving Car Robots are smart. Here you transform your old toy car or another vehicle into a bot that follows a wavy line. Use it for shipping goods between unmanned travel ports. Real world uses are endless. Continue >>
Broadcast Your Radio
Broadcast Your Radio Broadcast your music and voice wirelessly. Spread your news with your friends over short distance using radio. It is easy to make, free, and won't get CRT angry at you. Radio podcasts, chatroom uses... Continue >>
Pedometer for Athletes
Pedometer for Athletes Supercharge your shoe! Use it to find issues in your run during basketball, track or soccer. Or, track the distance and stats of your jog. Help keep others keep their walk at constant pace, such as... Continue >>

Maintained by Qusay H. Mahmoud
Content Contributors: Rudy Lang, Michael Lescisin, Rahma Mahmood, Ahmad Shamshiri, Ahmad Touseef, Mirna Zohiry