System status lights on your Raspberry Pi using the PiGlow module and systemd


System status lights

Recently I wanted to use my Raspberry Pi, a cheap and small computer device for hobby projects, for making a wireless radio. Wireless at least in the sense that it connects to the internet via a wifi dongle. I like my device to have some kind of interface, but I found a TFT screen a bit too expensive, so I decided to buy a Pimoroni PiGlow. The PiGlow is a small add on board for the Raspberry Pi that provides 18 individually controllable LEDs, which are placed in a three-legged swirling pattern and consists of red, orange, amber, green, blue and white LEDs. Turning these LEDs on and off from the command line is fairly easy using the Wiring Pi library. What I wanted was that when my Pi boots, it shows which services were running using these lights, in the following way:

  • Red lights: Filesystems are enabled
  • Orange lights: Wireless networking is enabled
  • Amber lights: SSH daemon is enabled
  • Green lights: Apache (HTTP) server is enabled


The way I configured this behaviour was by writing my own systemd service scripts. For example, the file below defines the service that lights up the red LEDs when the filesystem is enabled.

Description=PiGlow Enabling Red1 Lights

ExecStart=/usr/local/bin/piglow_color red0 25


Each service scripts has three sections, which are [unit], [service] and [install]. The [unit] section contains a description, it defines a requirement and an order. The requirement keyword ensures that this service starts when the service starts. By defining the after keyword as well, this service will only be started after has started and not simultaneously.

The [service] attribute defines the type of service. Here, I have used the oneshot type. This means that the service is started by running an executable, which immediately exits, in contrast to for instance a daemon service, which keeps running in the background.

Finally, the [install] attribute configures how this service should be installed. Installation is done by

systemctl enable

Note that should be the filename where you have written your service script. Place such files in /etc/systemd/system.

Similarly, for the green LEDs (which light up when the Apache server is enabled), I wrote the following script:

Description=PiGlow Enabling Green Lights

ExecStart=/usr/local/bin/piglow_color green 10


Up next, I want the white LEDs to fade in and out when the device has any sofware updates ready to install. But I will dedicate another post on that topic. :-)

If you have questions or comments, feel free to drop a line! Like what you read? Share this page with your friends and colleagues.


What is the answer to Ten + Four?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
2014-10-05 00:15:27
did you progress more with this script, what else is needed for this, the above script needs more?
What is the answer to Nine + Six?
Please answer with a whole number, i.e. 2, 3, 5, 8,...