This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Raspberry Pi Shutdown Indicator LED
#1
? Raspberry Pi Shutdown Indicator LED using GPIO22 (OpenPlotter + MacArthur HAT)
For those running OpenPlotter on a Raspberry Pi 5 with a MacArthur HAT:
I've added a simple but super useful status LED to one of the GPIO pins. The LED indicates whether the Pi is still running. After issuing a
Code:
sudo shutdown now
, the LED turns off — so I know it's safe to cut the main power to the boat.

✅ What it does
  • ? LED ON = Raspberry Pi is running
  • LED OFF = Raspberry Pi has shut down cleanly → you can turn off the boat’s main power

? What you need
  • 1x green LED
  • 1x 220 Ω resistor
  • Jumper wires or Dupont cables
  • A free GPIO pin (I used GPIO22 = physical pin 15)
  • Raspberry Pi 5 with OpenPlotter and MacArthur HAT

? Wiring
Connect your LED as follows:
less
KopiërenBewerken
Code:
GPIO22 (pin 15) ──[220Ω]──>|── GND (pin 6)
                          LED
  • The long leg of the LED (anode) goes to the resistor
  • The short leg (cathode) goes to ground

⚙️ Software setup with
Code:
systemd
1. Turn on the LED at boot
Create the script:
bash
KopiërenBewerken
Code:
sudo nano /usr/local/bin/led_on.py
Content:
python
KopiërenBewerken
Code:
#!/usr/bin/env python3
from gpiozero import LED
import time

led = LED(22)
led.on()

while True:
    time.sleep(60)
Make it executable:
bash
KopiërenBewerken
Code:
sudo chmod +x /usr/local/bin/led_on.py
Create a systemd service:
bash
KopiërenBewerken
Code:
sudo nano /etc/systemd/system/boot-led.service
Content:
ini
KopiërenBewerken
Code:
[Unit]
Description=Turn on LED at boot
After=multi-user.target

[Service]
ExecStart=/usr/bin/python3 /usr/local/bin/led_on.py
Restart=always

[Install]
WantedBy=multi-user.target
Enable it:
bash
KopiërenBewerken
Code:
sudo systemctl enable boot-led.service
sudo systemctl start boot-led.service

2. Turn off the LED during shutdown
Create the script:
bash
KopiërenBewerken
Code:
sudo nano /usr/local/bin/led_off.py
Content:
python
KopiërenBewerken
Code:
#!/usr/bin/env python3
from gpiozero import LED

led = LED(22)
led.off()
Make it executable:
bash
KopiërenBewerken
Code:
sudo chmod +x /usr/local/bin/led_off.py
Create the shutdown service:
bash
KopiërenBewerken
Code:
sudo nano /etc/systemd/system/led-off.service
Content:
ini
KopiërenBewerken
Code:
[Unit]
Description=Turn off LED at shutdown
DefaultDependencies=no
Before=shutdown.target

[Service]
ExecStart=/usr/bin/python3 /usr/local/bin/led_off.py
Type=oneshot

[Install]
WantedBy=shutdown.target
Enable the shutdown service:
bash
KopiërenBewerken
Code:
sudo systemctl enable led-off.service

✅ Result
Your LED now gives you clear visual feedback:
Pi State
LEDRunning
? ON
Shut down
⚫ OFF
Safe to power off?
✅ Yes, when LED is OFF


ℹ️ Notes
  • Tested on Raspberry Pi 5 + MacArthur HAT + OpenPlotter
  • GPIO22 was free in my setup (double-check your own!)
  • The LED is green, powered via GPIO with a 220 Ω resistor — safe and bright
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)