daleos
Posts: 1
Joined: Mon Jul 08, 2019 11:23 am

Turn Raspberry Pi on/off with TV

Mon Jul 08, 2019 11:33 am

My Chromecast turns on and off with my TV. It uses USB power from the TV for this to work.

I would like something similar from my Raspberry Pi 4 but as the power requirements of the Pi 4 are more than my TV's USB port can provide, is there another way I can do this? Is there a "wake on USB" function or some sort of project/board I could make/buy that could switch the Pi on and off whenever the TV is on/off?

Like I mentioned, the Chromecast does this by being connected to the USB port on the TV so I imagine I could use a USB port on the TV to signal the Pi (or some other device powering the Pi) to switch on.

drgeoff
Posts: 9899
Joined: Wed Jan 25, 2012 6:39 pm

Re: Turn Raspberry Pi on/off with TV

Mon Jul 08, 2019 7:02 pm

There is rather more to it than just removing power from the RPi. The OS should be shut down first.

Andyroo

Re: Turn Raspberry Pi on/off with TV

Mon Jul 08, 2019 9:20 pm

If the USB ports on the TV have power cut when the TV is turned of you may be able to cable the power from the USB via a level sifter to a Pi GPIO and when that changes you issue the power down command.

DarkElvenAngel
Posts: 182
Joined: Tue Mar 20, 2018 9:53 pm

Re: Turn Raspberry Pi on/off with TV

Thu Aug 01, 2019 3:22 am

Andyroo wrote: If the USB ports on the TV have power cut when the TV is turned of you may be able to cable the power from the USB via a level sifter to a Pi GPIO and when that changes you issue the power down command.
That could work but if you want to turn the pi back on again you need to have some logic. There is an overlay for a power button you could use put

Code: Select all

dtoverlay=gpio-shutdown
In you config.txt file in the boot directory

The following is from the overlay README

Code: Select all

    This overlay only handles shutdown. After shutdown, the system
    can be powered up again by driving GPIO3 low. The default
    configuration uses GPIO3 with a pullup, so if you connect a
    button between GPIO3 and GND (pin 5 and 6 on the 40-pin header),
    you get a shutdown and power-up button.
The key is you only need to drive the pin low momentarily and it only needs to drive low thus you don't need to level shifter just a transistor should do the trick. All this depends on getting a clear power status from the TV.

The USB port isn't the only output that could switch, the 5V pin on the HDMI could also switch.

Hopefully this gives you some idea where to go next.

Good luck.

deepo
Posts: 199
Joined: Sun Dec 30, 2018 8:36 pm

Re: Turn Raspberry Pi on/off with TV

Fri Oct 25, 2019 9:38 pm

I can't make that overlay work...
https://www.raspberrypi.org/forums/view ... 8&t=254003

/Mogens

DarkElvenAngel
Posts: 182
Joined: Tue Mar 20, 2018 9:53 pm

Re: Turn Raspberry Pi on/off with TV

Sat Oct 26, 2019 5:46 pm

deepo wrote: I can't make that overlay work...
https://www.raspberrypi.org/forums/view ... 8&t=254003

/Mogens
I never had any trouble getting that overlay working in stretch with my Pi3B+ you don't need to tell it what pin to use though. I use this on a stretch lite running Kodi and I added this overlay. I'll update with the all the kernel and setting. What sort of switch are you using?

deepo
Posts: 199
Joined: Sun Dec 30, 2018 8:36 pm

Re: Turn Raspberry Pi on/off with TV

Sat Oct 26, 2019 9:23 pm

DarkElvenAngel wrote:
Sat Oct 26, 2019 5:46 pm
deepo wrote: I can't make that overlay work...
https://www.raspberrypi.org/forums/view ... 8&t=254003

/Mogens
I never had any trouble getting that overlay working in stretch with my Pi3B+ you don't need to tell it what pin to use though. I use this on a stretch lite running Kodi and I added this overlay. I'll update with the all the kernel and setting. What sort of switch are you using?
I use a button inserted into the 3.5 mm jack with a wire soldered to pin 5.
The button is a jack plug with a button on the end. It looks great in a Flirc case.
The buttons are for Android phones, but I don’t know their original purpose.
But the button is not the point, because it doesn’t work when i manually connect pin 5 and 6 either.

/Mogens

DarkElvenAngel
Posts: 182
Joined: Tue Mar 20, 2018 9:53 pm

Re: Turn Raspberry Pi on/off with TV

Sun Oct 27, 2019 1:10 am

Well I'm running kernel 4.19.57-7v+

And my config.txt entry reads

Code: Select all

dtoverlay=gpio-shutdown
I have the button connected to the gpio header and I press it and it shuts down.

Gpio header

Code: Select all

::|:::::::::::::::::         [USB PORTS
  ^ power button across here 5 and 6

deepo
Posts: 199
Joined: Sun Dec 30, 2018 8:36 pm

Re: Turn Raspberry Pi on/off with TV

Sun Oct 27, 2019 4:22 pm

It turns out that a monitor plugged into the HDMI port is required for the gpio-shutdown overlay to work.
I did some testing today, and moved my RPi into the living room and connected it to my TV, then it worked fine.
I then shut it down, disconnected the monitor, and tried again, and it worked fine.
I have updated my original thread on this problem.

/Mogens

DarkElvenAngel
Posts: 182
Joined: Tue Mar 20, 2018 9:53 pm

Re: Turn Raspberry Pi on/off with TV

Sun Oct 27, 2019 6:52 pm

deepo wrote:
Sun Oct 27, 2019 4:22 pm
It turns out that a monitor plugged into the HDMI port is required for the gpio-shutdown overlay to work.
I did some testing today, and moved my RPi into the living room and connected it to my TV, then it worked fine.
I then shut it down, disconnected the monitor, and tried again, and it worked fine.
I have updated my original thread on this problem.

/Mogens
That's odd I use the official touch screen with no HDMI monitor ever and it works perfectly. If you shutdown the pi will it reboot if you press the button no matter if a screen is attached or not?

I am thinking if that works maybe you could use something different to read the button and trigger the shutdown. I only suggested that overlay because it was supposed to be simple and easy. But you can use a python script to watch for the button press and preform a safe shutdown.

deepo
Posts: 199
Joined: Sun Dec 30, 2018 8:36 pm

Re: Turn Raspberry Pi on/off with TV

Sun Oct 27, 2019 6:56 pm

DarkElvenAngel wrote:
Sun Oct 27, 2019 6:52 pm
deepo wrote:
Sun Oct 27, 2019 4:22 pm
It turns out that a monitor plugged into the HDMI port is required for the gpio-shutdown overlay to work.
I did some testing today, and moved my RPi into the living room and connected it to my TV, then it worked fine.
I then shut it down, disconnected the monitor, and tried again, and it worked fine.
I have updated my original thread on this problem.

/Mogens
That's odd I use the official touch screen with no HDMI monitor ever and it works perfectly. If you shutdown the pi will it reboot if you press the button no matter if a screen is attached or not?

I am thinking if that works maybe you could use something different to read the button and trigger the shutdown. I only suggested that overlay because it was supposed to be simple and easy. But you can use a python script to watch for the button press and preform a safe shutdown.
The RPi I was testing on sits next to my main computer, and I use it for tinkering with bluetooth on. So I mainly connect to it using SSH.

I chose the gpio-shutdown overlay exactly for the reasons you list. It's official software and simple to configure.
I'll try the python method to detect button press, thanks.

/Mogens

deepo
Posts: 199
Joined: Sun Dec 30, 2018 8:36 pm

Re: Turn Raspberry Pi on/off with TV

Mon Oct 28, 2019 5:39 pm

I just can't get any python script to work with pin5 GPIO3 on my RPI 3B+...
Has anybody got a working script detecting change on pin 5?

/Mogens

DarkElvenAngel
Posts: 182
Joined: Tue Mar 20, 2018 9:53 pm

Re: Turn Raspberry Pi on/off with TV

Tue Oct 29, 2019 3:14 am

Post your code, it's easier to help you if I can see it.

deepo
Posts: 199
Joined: Sun Dec 30, 2018 8:36 pm

Re: Turn Raspberry Pi on/off with TV

Tue Oct 29, 2019 4:28 pm

DarkElvenAngel wrote:
Tue Oct 29, 2019 3:14 am
Post your code, it's easier to help you if I can see it.
I started a thread here:
https://www.raspberrypi.org/forums/view ... 2&t=255561

/Mogens

Return to “Media centres”