User avatar
ImaginaryTango
Posts: 64
Joined: Fri Jul 16, 2021 6:51 pm

Shutting Pi Down - LEDs and Best Command

Tue Jul 27, 2021 1:35 am

I've read I can shutdown a Pi (running Raspian), from Python, with os.system("shutdown -s"). However, when I type man shutdown, I don't see '-s' listed as an option. I'm used to using shutdown -r now for rebooting and when I tried shutdown -h, it did halt, but my Pi did not power down.

Related to shutting down, for me, is GPIO connections. I've read about people saying their LEDs controlled by GPIO pins turn off and others say they've had problems with that.

So I have some questions on that:
1) Is it normal for shutdown -h to not power down a system?
2) What can I use to be sure that, when it's done, the system is powered down?
3) If I have my LEDs wired properly, when the Pi goes off, will they turn off completely, or will they drain power even when the Pi is off?

I'm hoping there's an easy way to shut down my Pi completely, including powering it off, from Python, and that shutting it down will take care of turning off any LEDs or other controlled devices that might be drawing power from my Pi.

klricks
Posts: 7979
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Shutting Pi Down - LEDs and Best Command

Tue Jul 27, 2021 2:05 am

There is no -s

There is no command to completely power down a RPi.
The shutdown -h command will halt the RPi but the 5V rail will remain powered until you turn off or remove the power supply.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

User avatar
ImaginaryTango
Posts: 64
Joined: Fri Jul 16, 2021 6:51 pm

Re: Shutting Pi Down - LEDs and Best Command

Tue Jul 27, 2021 2:57 am

klricks wrote:
Tue Jul 27, 2021 2:05 am
There is no -s
I thought so, I couldn't find it, but I guess maybe sometimes I trust Stack Exchange answers more than I should!
There is no command to completely power down a RPi.
The shutdown -h command will halt the RPi but the 5V rail will remain powered until you turn off or remove the power supply.
What about GPIO pins, are are they included when you refer to the rail? In other words, if I used a GPIO pin to turn an LED on, when the Pi is halted, will that Pi remain on or will it go off?

klricks
Posts: 7979
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Shutting Pi Down - LEDs and Best Command

Tue Jul 27, 2021 3:08 am

ImaginaryTango wrote:
Tue Jul 27, 2021 2:57 am
klricks wrote:
Tue Jul 27, 2021 2:05 am
There is no -s
I thought so, I couldn't find it, but I guess maybe sometimes I trust Stack Exchange answers more than I should!

There is no command to completely power down a RPi.
The shutdown -h command will halt the RPi but the 5V rail will remain powered until you turn off or remove the power supply.


What about GPIO pins, are are they included when you refer to the rail? In other words, if I used a GPIO pin to turn an LED on, when the Pi is halted, will that Pi remain on or will it go off?
Don't know how you have things wired?
The 5V GPIO pins 2 and 4 and anything connected to them will still be powered after shutdown.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

katesimon123
Posts: 41
Joined: Sun Jun 13, 2021 2:45 am

Re: Shutting Pi Down - LEDs and Best Command

Tue Jul 27, 2021 9:27 am

I use these commands and they work fine:

"sudo poweroff" shuts down;
"sudo reboot" reboots

pcmanbob
Posts: 11675
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Shutting Pi Down - LEDs and Best Command

Tue Jul 27, 2021 9:36 am

What about GPIO pins, are are they included when you refer to the rail? In other words, if I used a GPIO pin to turn an LED on, when the Pi is halted, will that Pi remain on or will it go off?
GPIO pins revert to being inputs which is the default start state, assuming you have not changed that in config.txt, so if a gpio pin has a default pull up as an input, which some have you will have that pull up present on shutdown which could affect things like LED's if connected to these pins.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
davidcoton
Posts: 6524
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Shutting Pi Down - LEDs and Best Command

Tue Jul 27, 2021 10:05 am

pcmanbob wrote:
Tue Jul 27, 2021 9:36 am
What about GPIO pins, are are they included when you refer to the rail? In other words, if I used a GPIO pin to turn an LED on, when the Pi is halted, will that Pi remain on or will it go off?
GPIO pins revert to being inputs which is the default start state, assuming you have not changed that in config.txt, so if a gpio pin has a default pull up as an input, which some have you will have that pull up present on shutdown which could affect things like LED's if connected to these pins.
I haven't checked, but on shutdown the 3V3 supply is off, so all GPIO pins will appear low, and may therefore sink a small current through the default pull-up or pull-down. I'm not certain that the defined default state is operative while the SOC is powered down, though, only that it appears during the boot process.
Location: 345th cell on the right of the 210th row of L2 cache

alphanumeric
Posts: 3003
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Shutting Pi Down - LEDs and Best Command

Tue Jul 27, 2021 10:20 am

Things that use smart LED's will often remain on. The Smart LED's remain in the last state they were in as long as they have power. The Sense Hat for example does this. I run sense.clear() before I do the shutdown now. My Unicorn Hat and Blinkt do the same thing if I don't clear them first.

User avatar
Burngate
Posts: 6473
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Shutting Pi Down - LEDs and Best Command

Tue Jul 27, 2021 5:23 pm

davidcoton wrote:
Tue Jul 27, 2021 10:05 am
I haven't checked, but on shutdown the 3V3 supply is off, so all GPIO pins will appear low, and may therefore sink a small current through the default pull-up or pull-down.
Doesn't the pull-up or -down require a fet to be on, which would require the 3v3 to be present?

alphanumeric
Posts: 3003
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Shutting Pi Down - LEDs and Best Command

Tue Jul 27, 2021 6:35 pm

Just A FYI post. On a Pi 400, on shutdown all power is removed from the GPIO header, and the USB ports. I really like that it does that. I have some Pimoroni Breakout Garden stuff hooked up to the GPIO header. On shutdown the LCD goes blank and the backlight goes off. No having to add extra code to clear it and or turn it off. And I can shut down with Fn F10 and have it all turn off.

Return to “Beginners”