Knowledge for the World

Build a simple Raspberry Pi LED power/status indicator

This short guide will show you how to add an LED power indicator/status light to your Raspberry Pi, letting you know when it's powered and when it's safe to unplug your Pi. This LED will illuminate when your Pi is running and turn off when your Pi has been successfully shut down. The LED can then be mounted anywhere on your project -- for example, on the outside of your PiCart's NES cartridge/case.

This guide will work with any Raspberry Pi model/version.

In these interests [?]
  • pi
    82 Subscribers Subscribe
1

Why is this useful?

You left your Pi on: This LED will remind you to turn it off.

Safe to unplug: It's unsafe to shut down your Raspberry Pi by pulling the plug since this can lead to data corruption. However, after shutting your Pi down safely, this LED will tell you when it's safe to pull the plug.

2

Methods for adding Pi LED status indicators

There are a few basic methods for illuminating LEDs on your Pi:

1. Software approach:

The LED is connected to one of your Pi's GPIO (general-purpose input/output) pins and you write a bit of code that will monitor and update the LED based on some input -- for example, your Pi running or the temperature outside being higher than 76 degrees.

Pros: You can illuminate LEDs of various colors, or illuminate your LED based on dynamic input -- such as when a battery-powered Pi is running low on juice.

Cons: Requires you to write software that executes at startup, adding a bit of complexity.

2. Serial approach (this guide):

The LED Is connected to your Pi's TxD pin, which monitors the serial console. The LED will flicker a tad while booting, stay solid while your Pi is running, and turn off when it's safe to remove power.

Pros: Simplicity. No code is needed and it just sort of works. Also, this is a great foray into the hardware portion of your Pi.

Cons: Limited to providing information about when the Pi is on or off -- a very binary solution.

Methods for adding Pi LED status indicators
3

Build the LED circuit

This step will require some soldering. I rigged everything up on a breadboard to prototype, but you can go straight to soldering now that we have the circuit figured out.

To build this circuit, we're going to use a 330Ω (ohm) resistor connected to a small LED (about 2V, but one of slightly higher voltage will work well too -- just keep it below 5V). The LED is powered by the Pi's TxD serial output pin and the resistor protects the Pi against your LED requesting high current draws that can fry your Pi.

The LED's "short" (negative/cathode) lead connects to the resistor and your Pi's ground pin, while the "long" (positive/anode) lead connects to the TxD pin.

Use the attached circuit diagram to solder your connections. If you're using a Pi Zero and don't have header pins soldered to your Raspberry Pi, you can solder directly to the Pi itself. Remove your SD card before soldering to your Pi as it is easily damaged by heat. Be sure to leave enough wire for your LED to reach its final destination.

Pinout.xyz is a great resource for learning about and identifying your Pi's GPIO pins.

Build the LED circuit
4

Test the LED circuit

Boot up your Pi -- the LED should illuminate solid once fully booted. Next, safely shut down your Pi and after several seconds the LED should turn off.

Test the LED circuit
5

Install the LED circuit

Now for the fun part -- installing the LED in your case. I used a small drill bit and installed the LED just beneath the thumb-hold on my Pi Cart so that it would illuminate the table just beneath the cartridge.

Route your wires carefully and use hot glue to secure your LED in place.

Install the LED circuit
6

Circuit powered off

Here's a shot of the status LED after the Pi has been powered off. This also shows the installation location I chose. I used a 3mm drill bit to install the LED.

Circuit powered off
7

All finished!

Here's the final product. Works great! If you have any comments or questions, post below and I'll do my best to help you out.

Coming soon: a Raspberry Pi shutdown button guide. Follow us on facebook to get notified of that one! :)

All finished!