Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
90 lines (70 sloc) 3.4 KB

ledweb: A web service for controlling an LED matrix 💡

This is a Python web service to control an LED matrix such as Adafruit's 64x32 RGB LED matrix.

This app is released under the GPLv2 because its main dependency is also released under the GPLv2.

There are two main components and some auxiliary files:

  • This is a service that listens for messages from a Redis server and controls the LED matrix.

  • This is a Flask app that supports uploading of images and passes commands to ledservice.

  •, ledweb.ini: Simple NGINX WSGI server for ledweb.

  • requirements_ledweb.txt, requirements_ledservice.txt: Python packages required for the respective services.

Because I followed Adafruit's great tutorial on setting up their LED matrices, currently requires Adafruit's fork of Henner Zeller's rpi-rgb-led-matrix library for controlling RGB LED displays. This fork was created 4 years ago (!) in order to add basic Python support, without proper packaging. Hence, has to run within the rpi-rgb-led-matrix directory; copy it and requirements_ledservice.txt into that directory. At some point, I will update this code to use the newer, more structured Python support in the main codebase.

Both and require a number of other Python packages. You'll probably want to use virtualenvs and install all requirements in there.

You can run as a systemd service (e.g. for Raspbian) by creating a file, /etc/systemd/system/ledweb.service, which contains something like this:

Description=uWSGI instance to serve ledweb

WorkingDirectory=<path to ledweb directory>
Environment="PATH=<path to bin/ directory of ledweb's virtualenv>"
ExecStart=<path to bin/ directory of ledweb's virtualenv>/uwsgi --ini ledweb.ini


Enable the service with sudo systemctl enable ledweb.service and start it with sudo systemctl start ledweb.service.

You can then serve the app from NGINX with a config entry like this:

location /led {
        include uwsgi_params;
        uwsgi_pass unix:<path to ledweb directory>/ledweb.sock;
        uwsgi_param SCRIPT_NAME /led;
        uwsgi_modifier1 30;

Unfortunately, my attempts at running as a systemd service have resulted in my Raspberry Pi locking up shortly after the service has started. I'm guessing it's somehow related to execution environment, but as of yet I have been unable to figure out the cause. For now, I run the service in a screen session, as root, from the rpi-rgb-led-matrix directory (see note above about why we have to run from this directory), via venv/bin/python (replace venv/bin with your virtualenv's bin directory if installed somewhere other than venv).

Unfortunately this means that has to be started manually after a reboot. Perhaps switching to the main rpi-rgb-led-matrix codebase will fix this.