Skip to main content

Real-time twitter map device

The project

The objective of the project is to create a small installation based on an interactive world map where you can view the tweets related to one or various subjects in real time, coded by colors and geographically located by continents.

Specifically, we are building a device that reads all the tweets related to “Raspberry Pi” and “Arduino” in real-time, get the location of those tweets and show them on the back-light  world map model with a color coding (red color for Raspberry Pi and blue color for Arduino).


The project is divided into two parts: the construction of the world map model and the programming. For the construction of the project we will need:

  • 3 sheets of Plywood 4mm / 5mm 30x40cm
  • Approx 25 WS281x RGB LEDs (Neopixel or similar)
  • Cable, tin and soldering iron
  • Masking tape or auto-adhesive vinyl
  • Hot Glue
  • Paint
  • Raspberry Pi Zero W

Building the model step by step

-We will have to cut the model parts using the file with the SVG design that can be found at

– Layer 1:

Base with engraved map

– Layer 2:


– Layer 3:

Top layer with laser cut map & spacers (same of layer 1 but with the map cut instead of engraved)

Next step is about soldering all the LED’s together (like a serial bus) and then connect them to the Raspberry (3 wires):

  • 5V -> 5V
  • D-OUT -> D-IN
  • GND -> GND
Single WS2811 LED


Matrix of LED’s


Mounting the LED’s into the boad to create the backlight effect


When we finish the previous steps, we will start to work on the part of programming in Python. The code is divided into 3 parts:

  1. Twitter connection
  2. Geolocation by continents
  3. LED’s control

To develop the project we will use a Raspberry Pi Zero W with Raspbian installed, but we can use any model, as long as we have an internet connection available.

You can download the code from:

Connection with Twitter

Twitter has an API that allows you to connect to your account through third-party clients. To do this, we must create a new application in and get the keys.

These keys should be added into the script:

# Go to and create an app.
# The consumer key and secret will be generated for you after
consumer_key = “”
consumer_secret = “”

# After the step above, you will be redirected to your app’s page.
# Create an access token under the “Your access token” section
access_token = “”
access_token_secret = “”

To connect with Twiter we will use Tweepy, a Python module for Twitter. We will install it by executing the following:

$ pip install tweepy

The script will listen permanently to the Tweets that match the search criteria that we will find in the search_strings variable:

# This is the string to search in the twitter feed
# May be a word, an #hashtag or a @username

search_strings = [‘arduino’, ‘raspberry pi’, ‘#raspberrypi’, ‘Raspberry Pi’, ‘Raspberry pi’, ‘Raspberry PI’, ‘Arduino’, ‘raspberry PI’, ‘#arduino’, ‘#Arduino’ ]

Geolocation of Tweets

When the script finds a tweet that matches the search criteria, the system returns an array with all the data of the tweet and the user who sent it. Among all the information, we have the location, but this is determined by the user and does not include information about the ‘continent’, itself, so we must use a CSV  file containing approximately 8,000 locations and its respective continent that you can find in the repository.

The script compares the location given by the user with the list of locations availabe, to define the continental area it should display on the map.

LEDs controler

To control the LEDs we will use the rpi_ws281x Adafruit library ,you can install it following those instructions or check the official Adafruit site :

sudo apt-get update
sudo apt-get install build-essential python-dev git scons swig​_
git clone
cd rpi_ws281x
cd python
sudo python install

After installing it, what we must do is edit the configuration parameters in the code to adapt it to our needs (basically the number of LEDs in LED_COUNT, the type of LED in LED_STRIP and the PIN of connection to the Raspberry in LED_PIN):

LED_COUNT = 26 # Number of LED pixels.
LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!).
LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz)
LED_DMA = 10 # DMA channel to use for signal generation (try 10)
LED_BRIGHTNESS = 250 # Set to 0 for darkest and 255 for brightest
LED_INVERT = False # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL = 0 # set to ‘1’ for GPIOs 13, 19, 41, 45 or 53
LED_STRIP = ws.WS2811_STRIP_GRB # Strip type and color ordering

The final result

At the end of the project, we will get a back-light twitter connected real-time world map that allows to show any kind of information we want, you can improve the project showing the tweet itself in the screen (the script also do that):

Leave a Reply

%d bloggers like this: