16

I am running my Pi headless connected to my wireless router using a ethernet cable. I wanted to shut down the pi remotely even when I am not connected to it using SSH/Putty to shut it down exclusively.

I put a question here: Shutting down my Pi safely and following the solution provided.

Now is there a way to verify that the Pi is shut down when the router is switched off? Any LED indication possible?

UPDATE:

I tried to observe the LED on the attached USB HDD and saw no change (it was already in a standby mode).

I just saw this: http://www.raspberrypi.org/forums/viewtopic.php?f=72&t=58098

Is there anybody in this site who have tried and tested this? I do not have a ready jumper to test it now. But once I do, I shall update this.

Additional Update

I finally stopped working on an implementation to create the indicator to show that the Pi is shut down. This is because, I have trust on the cron and I have checked it visually multiple times. So within two minutes of shutting down the router (eth=down), I see the 10 steady blinking of the ACT LED and the Pi goes to halt. I am so happy. I feel sorry that I had a doubt on my cute Pi!

6
  • Can you be even more explicit about what you want? What i think youre saying is you want a hardware version of safe shutdown. Is that correct? and you want that to be router controlled somehow? Are there other conditions? everything is possible, but im not sure what you want.
    – j0h
    Commented Aug 5, 2014 at 14:30
  • I am just want to know if a visual inspection on the Pi may let me know whether it has been shut down already. As I am running headless, I do not get any indication.
    – Kangkan
    Commented Aug 6, 2014 at 4:46
  • I will say yes, you can do this, with external logic.
    – j0h
    Commented Aug 6, 2014 at 13:15
  • @j0h: Would you be able to add an answer with adequate detailing? Or is this just a gut feel?
    – Kangkan
    Commented Aug 6, 2014 at 15:02
  • Yes, but i need to take some measurements, and draw a logic diagram. I am away from my pi at the moment, so I cant do it. Also, do you plan to have this "node off" light on multiple nodes? if so, how many?
    – j0h
    Commented Aug 6, 2014 at 15:36

4 Answers 4

9

Your solution is simple, use an inverter, and a start up script. When The script runs, have an IO pin go high, which will force the LED off. When the OS is off, and the script driving the IO pin is off, the LED will illuminate.

I still haven't made it back to my Pi location, but it may be possible to do this without an inverter.

You would add you script to run by setting up

sudo vim /etc/rc.local

At the bottom, just above exit 0 we’ll add a call to our script.

python /home/pi/run.py

Your script would look something like this:

import RPi.GPIO as GPIO
pinNum = 8
GPIO.setup(pinNum,GPIO.OUT) 
GPIO.output(pinNum,GPIO.HIGH)

Indent that last line.

You can see I am assuming the name run.py and that you have a user directory named /home/pi

Here is a picture of the schematic.

Invert output

Now, if you wanted to get a little extra fancy, you could have a green and red LED, one on either side of the inverter. When the OS is on, one led would be driving high the green LED, and low on the RED LED low. then when the OS were off, the green led would be off, and the red led, on. (I think that would be neat.) or not. do whatever you like.

5
  • for the love of god where the heck is the code button in this forum? can someone step in here and format the code block properly for me?
    – j0h
    Commented Aug 8, 2014 at 12:23
  • Thanks! Also added the code block as in your comment (the two curly braces work as the code button.
    – Kangkan
    Commented Aug 8, 2014 at 12:39
  • I just built and tested this solution and it seems to work as requested.
    – j0h
    Commented Aug 9, 2014 at 6:11
  • This is not a forum but a Q&A :) Unfortunately there is no code block (please use pre formatted text instead) and changes cant be made until the Q&A is out of Beta. Please submit your suggestions in Pi Meta for it to be considered.
    – Piotr Kula
    Commented Aug 9, 2014 at 14:09
  • Duely noted ppumkin
    – j0h
    Commented Aug 9, 2014 at 22:42
5

In Raspberry Pi 3 you can trun off the PWR LED with

echo 0 | sudo tee /sys/class/leds/led0/brightness

If the Pi is shut down, the LED will turn on again.

1
  • 1
    In my case the PWR LED (red) is led1. led0 is the I/O (green). Commented Mar 13, 2018 at 5:58
2

No, here are the leds and explanation. http://www.adafruit.com/blog/2013/02/15/raspberry-pi-status-leds-explained-piday-raspberrypi-raspberry_pi/

You could just add your own led to one of the pins. I believe they all go low on shutdown. At least all my relays shut off when the pi shuts down.

Searching finds this video, I haven't tested it. https://www.youtube.com/watch?v=ZwHxg92BXfs

1

Strictly no, unless you actually witness the shutdown in which case you see the ACT light brink rapidly a several times (10 I think) at a stable interval.

If you mean you want to be able to look at the Pi and tell if is booted or not then the fact that the power LED (red) is on but the network LEDs are all off is usually a good indication (providing that the network device the Pi is connected to has fairly stable uptime).

Reading your original question it seems that the second case will not be applicable, and the first is more likely.

1
  • The other LEDs switch off when I switch off the connected router. And the Pi is supposed to sense the status of the eth0 and shut down if it is down. So, I am in a fix.
    – Kangkan
    Commented Aug 6, 2014 at 4:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.