2025-06-16, 07:52 PM
? 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
, the LED turns off — so I know it's safe to cut the main power to the boat.
✅ What it does
? What you need
? Wiring
Connect your LED as follows:
less
KopiërenBewerken
⚙️ Software setup with
1. Turn on the LED at boot
Create the script:
bash
KopiërenBewerken
Content:
python
KopiërenBewerken
Make it executable:
bash
KopiërenBewerken
Create a systemd service:
bash
KopiërenBewerken
Content:
ini
KopiërenBewerken
Enable it:
bash
KopiërenBewerken
2. Turn off the LED during shutdown
Create the script:
bash
KopiërenBewerken
Content:
python
KopiërenBewerken
Make it executable:
bash
KopiërenBewerken
Create the shutdown service:
bash
KopiërenBewerken
Content:
ini
KopiërenBewerken
Enable the shutdown service:
bash
KopiërenBewerken
✅ 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
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
✅ 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
Create the script:
bash
KopiërenBewerken
Code:
sudo nano /usr/local/bin/led_on.py
python
KopiërenBewerken
Code:
#!/usr/bin/env python3
from gpiozero import LED
import time
led = LED(22)
led.on()
while True:
time.sleep(60)
bash
KopiërenBewerken
Code:
sudo chmod +x /usr/local/bin/led_on.py
bash
KopiërenBewerken
Code:
sudo nano /etc/systemd/system/boot-led.service
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
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
python
KopiërenBewerken
Code:
#!/usr/bin/env python3
from gpiozero import LED
led = LED(22)
led.off()
bash
KopiërenBewerken
Code:
sudo chmod +x /usr/local/bin/led_off.py
bash
KopiërenBewerken
Code:
sudo nano /etc/systemd/system/led-off.service
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
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