Next project
Outreach Initiatives and Community Awareness


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

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 a Raspberry Pi in Python. They will get involved in the world of embedded Linux and understand how to use the Twitter OAuth API.

The Raspberry Pi was chosen because of its low price and active community. The Raspberry Pi has built-in Ethernet and a 26 pin general purpose input/output (GPIO) header. These features allow the engineering student to connect to the Internet and connect to a HD44780 compatible LCD display. Furthermore, the Raspberry Pi runs Linux so it's compatible with a wide variety of software.

Python was chosen as the programming language 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.

Description of project:

This project uses the OAuth API to get tweets from a users Twitter feed. It then sends them as signals on the GPIO header to the LCD where they are displayed. 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 were 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. Cutting a breadboard wire short will allow the student to connect it to the GPIO header on the Raspberry Pi.

Software Components:

Tools:

  • Soldering tool, solder and flux – for connecting wires to the LCD
  • Wire stripper – for removing insulation from wires
  • A way to communicate with the Raspberry Pi – either ssh connection from a computer or external monitor, keyboard and mouse

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
      screen
  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 accessaccount
  5. Install tweepy on Raspberry Pi – in Linux terminal on Raspberry Pi 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. Copy twitter_lab_test.py onto the Raspberry Pi.
    4. Open the directory on the Raspberry Pi. Type: python twitter_lab_test.py and press enter. If your tweet is displayed in the terminal, everything is working.
  8. Solder wires to 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 Raspberry Pi – Refer to the pinout. Do this with the Raspberry Pi unplugged.

GPIOS
http://elinux.org/RPi_Low-level_peripherals

  1. 1. Connect the wire from LCD pin 1 (Vss) to GND on the Raspberry Pi by going through the breadboard.
  2. Connect the wire from LCD pin 2 (VDD) to 5V on the Raspberry Pi by going through the breadboard.
  3. Connect the 5kΩ trimmer 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.
    Trimmer
  5. This should look as follows
  6. Connect the wire from LCD pin 4 (RS) to Raspberry Pi GPIO07.
  7. Connect the wire from LCD pin 5 (R/W) to Raspberry Pi GND.
  8. Connect the wire from LCD pin 6 (E) to Raspberry Pi GPIO08.
  9. Connect the wire from LCD pin 11 (D4) to Raspberry Pi GPIO25.
  10. Connect the wire from LCD pin 12 (D5) to Raspberry Pi GPIO24.
  11. Connect the wire from LCD pin 13 (D6) to Raspberry Pi GPIO23 .
  12. Connect the wire from LCD pin 14 (D7) to Raspberry Pi GPIO14.
  13. This should look as follows:
    schamatic LCD
  14. Prepare the Raspberry Pi Software
    1. Copy the file config_pins.py to the Raspberry Pi under the directory /etc/init.d
    2. Run the command: sudo update-rc.d config_pins.py defaults 100
    3. This will make the required GPIO pins available to non-root userspace.
    4. Reboot the Raspberry Pi to make the changes effective.
  15. Make it display tweets.
    1. Open the file Twitter_LCD_noroot.py in a programming IDE.
    2. Repeat the steps from step 5 for entering the keys.
    3. Copy the file Twitter_LCD_noroot.py to the Raspberry Pi.
    4. Copy the file SafeGPIO.py to the Raspberry Pi, under the same directory as Twitter_LCD_noroot.py
    5. Open the directory where Twitter_LCD_noroot.py is found in a terminal and type: python Twitter_LCD_noroot.py
    6. With a flat-tip screwdriver turn the trimmer until the LCD display becomes readable.
    7. 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.
  16. Make it automatic.
    1. Make the file Twitter_LCD_noroot.py executable. Open it's directory in a terminal and type: chmod 755 Twitter_LCD_noroot.py
    2. Create the “lcdtwitter” user. Run the command sudo adduser lcdtwitter on the Raspberry Pi.
    3. Login as “lcdtwitter” and type the command crontab -e
    4. Add the following line:
      */1 * * * * /<path>/<to>/Twitter_LCD_noroot.py replacing <path>/<to>/ with the path to Twitter_LCD_noroot.py
    5. Press Ctrl+O.
    6. Press enter.
    7. Press Ctrl+X
    8. The LCD will now be automatically updated every minute.

Final Product:
Raspberry PI twitter project

breadboard schamatic

 

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:

• 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.
• 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.
• Adding a color and graphical LCD screen would be more aesthetically pleasing.
• Remove the solderless breadboard by soldering everything on a regular breadboard and use a header to plug into the Raspberry Pi.

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
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 >>
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 >>
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 >>
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 >>
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 >>
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 >>
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 >>
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 >>
Arduino Tweets to my Door Arduino Tweets to my Door Arduino connected through wire to display. Show your twitter updates on a screen attached to your door at school's club office, classroom, treehouse room. Display to your audience your location at the... 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 >>
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 >>
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 >>

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