Monitor CPU Usage with 12,288 Individually Addressable LEDs

See how a few RGB matrix panels and OpenGL were used to create these mesmerizing patterns based on CPU temperature.

Evan Rust
4 years agoSensors / Lights / Displays / Art

The Idea

Keeping track of how hot your CPU is running can be quite boring, as staring at a list of changing numbers gets old, quickly. That's why Sebastian from the website There Ought to Be has created a cube with three faces that display CPU usage and temperature statistics. He was inspired to design this when he attended the 36th Chaos Communication Congress and saw the smaller cubes that people were building and using to show particles reacting to changes in the cube's position. Rather than also making his cube battery powered, Sebastian wanted a stationary device that can plug into the wall, which allows for far more LEDs to be used.

Hardware Used

Perhaps the most important part of this project are the three LED panels, which each contain 4,096 LEDs, for a total of 12,288. They rely on a simple serial communication protocol, which sweeps through each row to update the display, and it also allows for multiple panels to be chained together in a series. All of that lighting needs power, which is why Sebastian used a 5V 10A power supply. As for driving the pixels, a Raspberry Pi 2 and Adafruit RGB Matrix Bonnet are responsible for outputting and converting the signals.

How It Works

In very simplified terms, the Raspberry Pi gets its CPU temperature through an API, converts that number into a color and animation, and then pushes it to the display. When stated this way, much of the complexity is hidden, especially when it comes to how the animations get from idea to the matrices, so it will be explored in more detail.

Driving the Panels

The LEDs on the matrix are not like the ones you would find on an LED strip, since they lack dedicated controllers. Rather, it uses many serial demultiplexers that decode the signal and output the appropriate value to the right LED. For a 64 x 64 matrix, 5 bit addressing is required, making the total number of GPIO pins used 13. Each panel can draw up to 5A if every pixel is set to full white (255, 255, 255), so it's important not to exceed the power supply's limit.

Fabrication

The three panels are mounted onto a basic chassis that was 3D printed in black PLA. There is a small are on the bottom to mount the Pi, along with a few cutouts for cable routing. The base has a small tilt for display purposes, but it can cause viewing angle issues.

RGB Matrix Software

The software is where the magic happens. It is a C++ program that first opens a UDP port to receive cpu information from an external script, then it displays the appropriate animation. It uses the rpi-rgb-led-matrix library (the same one Adafruit uses in their Python wrapper) to map the physical pixels onto a software-defined grid and then push them over the physical bus. This abstraction helps to greatly simplify the development process, as you can simply plug in the hardware mapping, timings, and display information to get it started.

Shaders

Sebastian thought that just displaying a GIF or text on the cube would be too boring, so he wanted something dynamically generated instead. The OpenGL program is quite complicated, so here's the basic rundown. The three faces of the cube are rendered as three pairs of triangles, which then get flattened to make a virtual canvas. This way of addressing pixels will cause a shape like a circle to look proper when viewed from the single common vertex in the center.

Getting CPU Stats

All of this preparation has led to the final task of getting the current CPU stats from a PC to the Pi. This is accomplished with a short Python script that takes in CPU die thermal sensor data using the psutil library and then formatting it as a string. It then gets pushed out via a UDP socket to the host Raspberry Pi for decoding.

Wrapping Up

The final result is impressive, as there are complex gradients and shapes moving in different directions constantly. Although extravagant, this project is a great way to showcase what can be done with a few components and some creativity.

Evan Rust
IoT, web, and embedded systems enthusiast. Contact me for product reviews or custom project requests.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles