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 server. The 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_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
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 YunTwitter.py 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_SECRET, set them in the code to complete the authorization process.
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
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/YunTumblr.py 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 YunTwitter.py 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.
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:
For a deepen understanding of the sketch have a look at the NeoMatrix example!