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.
Re: Turn Raspberry Pi on/off with TV
There is rather more to it than just removing power from the RPi. The OS should be shut down first.
Quis custodiet ipsos custodes?
Re: Turn Raspberry Pi on/off with TV
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.
-
- Posts: 2164
- Joined: Tue Mar 20, 2018 9:53 pm
Re: Turn Raspberry Pi on/off with TV
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 putAndyroo 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.
Code: Select all
dtoverlay=gpio-shutdown
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 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.
-
- Posts: 2164
- Joined: Tue Mar 20, 2018 9:53 pm
Re: Turn Raspberry Pi on/off with TV
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 wrote: I can't make that overlay work...
https://www.raspberrypi.org/forums/view ... 8&t=254003
/Mogens
Re: Turn Raspberry Pi on/off with TV
I use a button inserted into the 3.5 mm jack with a wire soldered to pin 5.DarkElvenAngel wrote: ↑Sat Oct 26, 2019 5:46 pmI 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 wrote: I can't make that overlay work...
https://www.raspberrypi.org/forums/view ... 8&t=254003
/Mogens
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
-
- Posts: 2164
- Joined: Tue Mar 20, 2018 9:53 pm
Re: Turn Raspberry Pi on/off with TV
Well I'm running kernel 4.19.57-7v+
And my config.txt entry reads
I have the button connected to the gpio header and I press it and it shuts down.
Gpio header
And my config.txt entry reads
Code: Select all
dtoverlay=gpio-shutdown
Gpio header
Code: Select all
::|::::::::::::::::: [USB PORTS
^ power button across here 5 and 6
Re: Turn Raspberry Pi on/off with TV
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
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
-
- Posts: 2164
- Joined: Tue Mar 20, 2018 9:53 pm
Re: Turn Raspberry Pi on/off with TV
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?deepo wrote: ↑Sun Oct 27, 2019 4:22 pmIt 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
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.
Re: Turn Raspberry Pi on/off with TV
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.DarkElvenAngel wrote: ↑Sun Oct 27, 2019 6:52 pmThat'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?deepo wrote: ↑Sun Oct 27, 2019 4:22 pmIt 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
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.
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
Re: Turn Raspberry Pi on/off with TV
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
Has anybody got a working script detecting change on pin 5?
/Mogens
-
- Posts: 2164
- Joined: Tue Mar 20, 2018 9:53 pm
Re: Turn Raspberry Pi on/off with TV
Post your code, it's easier to help you if I can see it.
Re: Turn Raspberry Pi on/off with TV
I started a thread here:DarkElvenAngel wrote: ↑Tue Oct 29, 2019 3:14 amPost your code, it's easier to help you if I can see it.
https://www.raspberrypi.org/forums/view ... 2&t=255561
/Mogens