1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Powering Hyperion and LEDs Only When TV is On

Discussion in 'Hyperion Hardware' started by The, 29 July 2019.

  1. The

    The New Member

    Messages:
    23
    Hardware:
    RPi2
    While I didn't do a lot of searching on here for similar cases, here's what I did to ensure that Hyperion and the LED array is powered only when the TV is on:

    Issues Solved:
    1. Ambilight when TV is on.
    2. No additional power draw, of any sort, when TV is off. Save $13 USD per year by ensuring my switched power supply is unable to draw power when system is off.
    3. Didn't want a separate remote to enable/disable the system.
    4. Didn't want to toggle power manually in any fashion.
    5. Hassle free. High WAF (wife acceptance factor)
    Approach:
    1. Power the Raspberry Pi 2 (with Hyperion NG installed) from the TV's USB port.
    2. Typical setup of converters, etc. No HDMI splitter as my AVR has a "monitor" port.
    3. RPI is only on when the TV is on. It's unceremoniously powered down when the TV is turned off. Folks suggest that may be bad, but we'll see and fix when/if that happens.
    4. Power the 5 meters of LEDs from a switched power supply.
    5. Use a Relay board to "switch" the 120V load line into the power supply. Relay is normally "open" (off). The RPI pin that tells the board to stay "on" is held voltage high, so when the RPI shuts off, the circuit breaks.
    6. Relay is controlled by pin on RPI. Relay is powered by the 5V from the RPI.
    7. On RPI boot, run a python script (below) to set the relay-board input pin to high, which toggles the relay, which enables power to flow to the power supply, when in turn drives the LEDs.
    Vizio USB Power Note
    [Edit Nov 30 2019] - Just upgraded my TV to a 4K Vizio. I had to search through the menu choices and toggle an option that always sent power to the USB port even when the TV is off. Basically, for my setup, I want no power to the USB port when the TV is off.

    Oddities
    A few minutes after turning the TV off (and supposedly the power if off), the RPI boots back up, LEDs turn back on, then about minute later they shut off again. My bet it's the TV turning on for a firmware check (and/or likely sending usage data to Vizio). Never figured it would power the USB ports, but evidently it does.


    Code/Stuff


    Relay:
    DZS Elec 5V 1 Channel Relay Optocoupler Isolation Module Red Board 3-5V High and 0-1.5V Low Level Triggered Load AC 0-250V / DC 0-30V 10A SCM IO Control

    Relay Enclosure:
    https://www.thingiverse.com/thing:3777041

    Script:

    setPowerPinHigh.py
    Code:
    import RPi.GPIO as GPIO  # import RPi.GPIO module
    from time import sleep  # lets us have a delay
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BCM)  # choose BCM or BOARD
    GPIO.setup(4, GPIO.OUT)  # set GPIO4 as an output
    GPIO.output(4, 1)  # set GPIO4 to 1/GPIO.HIGH/True
    

    Inserted into: /etc/xdg/lxsession/LXDE-pi/autostart
    Code:
    python /home/pi/setPowerPinHigh.py
    
    #Not necessary. Fires up VNC and a compiled version of hyperion
    x11vnc -display :0 -usepw -noxdamage -ncache 10 -ncache_cr -forever
    /home/pi/hyperion/build/bin/hyperiond
    

    Warning
    Proceed at your own risk controlling 120V power. If your house burns down because of this advice, call the fire department.
     
    Last edited: 1 December 2019
    • Like Like x 2
  2. Arakon

    Arakon Member

    Messages:
    151
    Hardware:
    RPi1/Zero, RPi3, +Arduino
    My solution for this was simply using a master-slave power strip. It turns off all other power sources when my AV receiver turns off (so TV, raspberry, LED PSU, lights for the cupboards and subwoofer all go off together).
     
  3. The

    The New Member

    Messages:
    23
    Hardware:
    RPi2
    Nice! Didn't know such a thing existed. That definitely would have been easier, and probably worked for me for the most part. Hopefully your post will help the next user.

    My subwoofer is across the room so that part wouldn't work for me. Also, occasionally I use my AV/R to drive only audio, so that may have caused a conundrum on which device should be the master. Unsure what device Arakon has, but here is a link to a Belkin Conserve Smart AV strip review. I wonder if the strip would fall victim to device auto-firmware update routines, fooling the strip into thinking the master was "on", if only for a few minutes. I'd hope there would be some tolerant minimal power draw to avoid this.

    Regardless, the "relay solution" was a nice foray into a bit of scripting, wiring, and tinkering.
     
  4. Robin Koehler

    Robin Koehler New Member

    Messages:
    8
    Hey The! Nice setup, thanks for sharing :) Almost exactly what I was hoping to achieve as well. I was wondering if you or someone else with experience could guide me a bit. Ordered this little guy:
    https://core-electronics.com.au/5v-single-channel-relay-module-10a.html

    My idea was to also use a USB port from the TV, but I want the relay to control the LEDs directly (Pi is always on with separate power supply).

    The LEDs have their own 5v 10a power. Can I put the relay after the power supply, before the LEDs? How would I have to wire everything up (USB cable from TV to relay, power supply to relay, relay to LEDs)?

    Thanks kindly everyone in advance!

    Robin
     
  5. The

    The New Member

    Messages:
    23
    Hardware:
    RPi2
    Robin, Yeah, the relay will work between the power supply and the LEDs. I'm assuming you want the USB on the TV to "signal" the LEDs to turn on...and when you turn off the TV, you want the LEDs to go off.

    I'm not an electronics guru. I'm making an educated guess. I would dare try this on my own TV after tooling with a volt meter. If you burn your TV up or your house, well, sorry.

    See schematic below and also this.

    The relay takes a 5v input signal, and needs a 5v supply and a ground. I'm assuming your TV energizes the USB cable with +5v when its on. Basically, I think that can be used as the signal to tell the relay to activate. I think the blue and black both would need to be tied to the ground on the relay. The yellow can be fed from the power supply since it's always on (otherwise I think you could feed that from the usb +5v too). The green is used as a circuit breaker to power or de-power the LEDs.

    wireItUp.jpg



    If this worked, I still wouldn't do it this way since I'm comfortable tooling with mains voltage and this method would keep the power supply energized sucking power even when everything is off. I suppose if the RaspberryPi is a media server (powered by the power supply) that would be okay though.
     
  6. Robin Koehler

    Robin Koehler New Member

    Messages:
    8
    Hey The! Thanks so much for such a detailed response with schematics and instructions! Ok, that makes a lot of sense. I got tinkering today and hooked it all up. I can somewhat get the relay to respond to the USB being plugged in to the TV. The relay switches when I press the power button on the TV remote, then after 1 second switches off again, then switches on for 3 seconds, then stays off completely. I am not sure what the problem is at this point, my assumption is that the TV USB port doesn't supply constant 5v under these circumstances, or recognises the relay as an unknown device and then "switches off" the USB port.

    I had a 5v 2 metre LED strip powered directly from the TV before I changed my setup to ambilight and it worked beautifully. I de-soldered the strip from the USB connector and am using that cable (it conveniently only has a black and red wire). I have also salvaged an old USB phone charger cable with 4 wires, identified the power and ground, hooked that up and got the same frustrating result.

    I have ordered another relay https://www.amazon.com.au/gp/product/B01M3TICL9/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1 and will try again next week once it arrives.

    Your info and schematics definitely got me on track and your help is very much appreciated :)

    Robin
     
  7. The

    The New Member

    Messages:
    23
    Hardware:
    RPi2
    You could be right with the way the TV is reacting. Good thought. However, if you saying you powered the 2 meter LED cable off the TV's USB port, prior to this I'd think that the USB isn't shutting down, but more the like the relay isn't seeing or doing what it needs to do. A few thoughts:

    1. I'd attach a volt meter to the USB cable and watch the voltage on the + while the TV is starting/running, and its reaction when turning the TV off.
    2. Your new relay has a little jumper on it that toggles the way the relay reacts to the signal wire. Unsure if trying the other position if the default doesn't work (after reading/understanding its details)
    3. Maybe it thinks there is a short (as a worst case). I wonder if there is some setting buried within the TV menus (probably not) that may solve it.
    4. Try powering the relay from the red wire (as well as feeding it to the signal) instead powering the relay with the 5v yellow one, though I'm most apprehensive about that idea. Maybe the TV is seeing there is no significant voltage being consumed by the port, so it shuts it off. By feeding the relay with it, it may think it's okay.
    5. If you have some detectable voltage from #1, or see a "pattern" that happens when the TV turns on and off, perhaps you can feed that signal to the Raspberry Pi as an input, program some python/code to watch for the pattern, and use another gpio output pin on the Raspberry Pi to control the relay input signal. However, DO NOT FEED the TV's USB 5v into a gpio pin on the Raspberry Pi, as the pins are not 5v tolerant. See https://raspberrypi.stackexchange.com/questions/38973/are-the-spi-pins-5v-tolerant it has a solution for stepping down the 5v to the 3.3v level using a voltage divider (never used one). Of course, that's not worth it unless your can see/parse/understand the signal from the USB.
     
  8. Robin Koehler

    Robin Koehler New Member

    Messages:
    8
    Hey The! Thanks once again for the input and the detailed instructions. We have liftoff!!! I frankensteined two wires to the black one coming off the USB cable to plug into signal and ground, and the red wire goes to the 5v pin (from memory, will have to confirm again when I'm next to it). Relay switches on, then off for a second, but then stays on permanently until I switch off the TV. Everything working as intended, very very happy with the result.

    Will post a wiring diagram later this week, just wanted to express my gratitude and share the positive result :)
     
  9. The

    The New Member

    Messages:
    23
    Hardware:
    RPi2
    Great! Nice work. Be interesting to see the diagram. If it is indeed the black wire to the relay signal, that may explain the "ground driven / active low" in the relay photo, in hindsight.