Project tutorial

LedMatrix Tweet Visualization © GPL3+

Display tweets with a certain hashtag on a led matrix in real time!

  • 1 comment
  • 23 respects

Components and supplies

Apps and online services

About this project


Display tweets with a certain hashtag on a led-matrix using an Arduino/Genuino Yùn or Yùn-Shield. We will use a Python script to log into twitter and check for updates.

Configuring the Yun101/YunShield 

In order to connect your board to internet you first have to configure some parameters.

Open your Arduino IDE and go to example -> Bridge -> YunFirstConfig

If you are using a YunShield be sure to select the name of the board to which it is attached and not a Yun board!

Upload the sketch and open the Serial monitor. You will see a message as the one in the screenshot below.

Follow a few simple steps and set up a name, a password and a network for your board.

Done! Now you can connect your Yun to internet!

Set up your Twitter

In order to access your own data, you must create an application, and generate your own access token.

Go to this page and click on the Create New App button.

Fill everything but leave the Callback URL empty if you want call the API without setting up a web serverThe API will give us an URL to get an identifier, so we don't need callback.

Now if you click on the Keys and Access Tokens tab you should see your own CONSUMER_KEY and CONSUMER_SECRET. Save those values, we will need them in the next step.

Great, now we only have to generate the OAUTH tokens.

To do so you can run the python script you'll find in the software section of this project. It is the same script that we will upload on our Yun101/yunShield but first we need to make some changes.

Download the script and open it in an advanced text editor. Set the two constants at the top of the code with the CONSUMER_KEY and CONSUMER_SECRET.

Now, to generate also the OAUTH tokens we have to run the script. Open the terminal and use the following commands

sudo pip install requests requests-oauthlib
python Arduino

Now you should have received the ID and the content of the last tweet with hashtag #Arduino.

If you run this script for the first time you could get an URL as a response. Follow that link and copy and paste the identification number you get in the terminal. Now you have your OAUTH_TOKEN and OAUTH_TOKEN_SECRET, set them in the code to complete the authorization process. 

Set Up your YunShield

In order to to download the python libraries we are going to use we can connect to the board via ssh ( be sure your computer is connected to the same network of the yun-shield).

Open your terminal and use the following command to download the libraries.

ssh root@name_of_your_yun.local
opkg update
opkg install python-pip
pip install requests requests-oauthlib
pip install sys

For the next step we will need the IP address of our YunShield.  We can obtain it by using the command ifconfig.

Now that we have the IP we can proceed uploading the script. You can use this command replacing your_path with the folder's path to reach the python script.

scp /your_path/ root@your_Yun_ip_address:

We are done!!!

To test it out you can digit in the terminal while you are connected via ssh:

python Arduino


For this project we used an 8x32 led matrix.

Normally all led matrix comes with three wires. The black one for the ground, the red one for the 5V and the coloured one for the data.

Software and libraries

The led matrix needs some libraries to work. You can easily install them from the Library Manager. 

In the Arduino IDE go to

Sketch -> include library -> manage libraries

And search for:

  • Adafruit_GFX
  • Adafruit_NeoMatrix
  • Adafruit_NeoPixel

For a deepen understanding of the sketch have a look at the NeoMatrix example!


Python scriptPython
# -*- encoding: utf-8 -*-
from __future__ import unicode_literals
import requests
from requests_oauthlib import OAuth1
from urlparse import parse_qs
import sys




def setup_oauth():
    """Authorize your app via identifier."""
    # Request token
    oauth = OAuth1(CONSUMER_KEY, client_secret=CONSUMER_SECRET)
    r =, auth=oauth)
    credentials = parse_qs(r.content)

    resource_owner_key = credentials.get('oauth_token')[0]
    resource_owner_secret = credentials.get('oauth_token_secret')[0]

    # Authorize
    authorize_url = AUTHORIZE_URL + resource_owner_key
    print 'Please go here and authorize: ' + authorize_url

    verifier = raw_input('Please input the verifier: ')
    oauth = OAuth1(CONSUMER_KEY,

    # Finally, Obtain the Access Token
    r =, auth=oauth)
    credentials = parse_qs(r.content)
    token = credentials.get('oauth_token')[0]
    secret = credentials.get('oauth_token_secret')[0]

    return token, secret

def get_oauth():
    oauth = OAuth1(CONSUMER_KEY,
    return oauth

if __name__ == "__main__":
    ashtag = str(sys.argv[1])
    oauth = get_oauth()

    part1 = ""
    part2 = "&count=1"
    r = requests.get(url=part1+ashtag+part2, auth=oauth)

    message_id = r.json()["statuses"][0]["id"]
    text = r.json()["statuses"][0]["text"]

    print message_id
    print text
Arduino Sketch




Similar projects you might like

Arduino Bluetooth Basic Tutorial

by Mayoogh Girish

  • 236 respects

Home Automation Using Raspberry Pi 2 And Windows 10 IoT

Project tutorial by Anurag S. Vasanwala

  • 671 respects

Security Access Using RFID Reader

by Aritro Mukherjee

  • 236 respects


Project in progress by Team Petoi

  • 1,361 respects
Add projectSign up / Login