Displaying Weather on a 32x16 LED Matrix

Bradley Dettmer
5 min readApr 23, 2018
Sunny weather forecasted onto LED matrix panel

Using a Raspberry Pi, HUB75 Connector, 32x16 LED matrix, Dark Sky API, Pillow and some sample code

In California, you can usually be sure it’s not going to rain for the rest of the day if the sky looks clear. Additionally, since it rains so rarely, if it’s going to rain, people are usually talking about it at least a day in advance. Also, California has a strong car culture, you can usually just hop in your car, so the chance of getting caught outdoors with the wrong attire in bad weather is pretty rare. I never checked the weather until I moved to New York.

In New York, you can be caught off guard by rain, snow, or really cold, windy weather. I’ve been caught a few times in the bad weather, to the point where I’ve started checking the weather forecast before leaving the house.

A friend told me about Dark Sky and told me it was the best weather app. I’ve been using Dark Sky but am annoyed by having to use my phone to get the weather forecast. Having an LED matrix display the weather would be more convenient to look at.

I’ve played around with Raspberry Pis in the past and Adafruit’s LED Matrix panel seemed like a good medium to view the weather on before going outside.

The Raspberry Pi is a small computer available for as little as $10. Adafruit’s LED matrix uses a HUB75 display driver. The HUB75 has 16 pins, 6 for specifying the color of an LED, 4 — A, B,C and D — for selecting line address, 3 ground, 1 OE / output enabled, 1 clock pin and 1 strobe pin. I used the HUB75 to interface between the Raspberry Pi and the LED matrix panel.

32x16 LED matrix panel with HUB75 connector interface

First, I needed the weather. Instead of attaching temperature and humidity sensors to my Raspberry Pi, I decided to get the forecast from the Dark Sky API because I was already using their app, and the forecasts seemed accurate enough.

As a programmer who commits code publicly, I try to avoid adding literal API keys to my source code. A straightforward way of passing API keys to source code is by creating a bash script that assigns your key to an environment variable, and sourcing it at setup or runtime. I set the API_KEY as an environment variable, and sourced it in my startup script.

What good is an LED matrix panel without the ability to turn the LEDs on? I wired up my Raspberry Pi, and connected it to the HUB75 using Henner Zeller’s wiring instructions.

The HUB75 expects 5V communication, but the Raspberry Pi only outputs 3.5V through its GPIO pins. At first, I didn’t believe this, and wired the Raspberry Pi pins directly to the HUB75. But the signal strength wasn’t strong enough, so I picked up 4 level converters and soldered them to the breakaway headers that connected to my breadboard. Each level converter boosted the voltage from 3.5V to 5V for 4 pins, so 4 converters allowed me to boost the signal for up to 16 pins. Alternatively, the MPC1073 and a CR1220 battery would have done the trick.

mess of wires

When debugging code, you can look at log files and console output, but how do you debug hardware? One way is by using a multimeter. A friend at the Recurse Center let me borrow Saleae’s logic analyzer to verify the connections and voltages. After connecting some pins to the analyzer and ground, I verified that 5V was being sent to the HUB75 on all GPIO pins.

There are many ways one could envision projecting the weather onto a grid of LEDs. One approach is to map pixels to LEDs, turn LEDs on corresponding to pixels. Kindly, Ari Zilnik created some images, which I shrunk to a height of 16 pixels, corresponding to the height of the LED matrix panel, and converted to Portable Pixmap format. While PPM is an uncompressed and inefficient format, it allows you to easily map every entry to a LED on the grid.

Magnified weather icons created by Ari
Ari’s cloud image scrolling on the LED Matrix panel

I found some sample code online, and wrote a bash script that executes the code so the weather images could be ingested and rendered on the LED matrix panel. I wrote the script to re-execute every time the image changed, a form of reactive programming.

It’s really nice to be able to plug in the Raspberry Pi, connect it to the LED matrix panel, and have it display the weather without having to interact with it.

To make the code run on boot and to prevent polling the API too often, I created a crontab to manage the code on the Raspberry Pi.

Useful weather information can come in the form of images and text. To display text, I considered creating a PPM file for every character, and pasting them together to form words, but then I decided that would be too tedious. Instead I found Pillow library that lets you draw text onto an image, and found a font that shrinks well to draw text on the 32x16 matrix panel.

weather banner

Currently, more detailed weather information is sent to the LED matrix, but it could easily be expanded in the future to display any other bit of information!

--

--