Introduction

After seeing some videos by DrZzs and others on setting up DIY ambient lighting for your TV, I knew I wanted to have this :)

I took some time to find the correct hardware on AliExpress, noting that I don’t want to downgrade my video from 4K to e.g. 1080P and that I might need to look out for DRM protections (HDCP), I put together my shopping list and the waiting could start …

In this blog post I’ll explain how I set up DIY Ambilight for my TV using Hyperion.

Since I have 2 devices providing video to my television (set-top box for digital television and a OSMC Vero 4K+ for my own video collection), I also needed to add a HDMI switch to the loop.
I specifically looked for a device that could either auto-detect the playing device, or at least came with a remote. The remote I could then link to my Broadlink RM4Pro so that Home Assistant can automatically switch to the correct source.

Logo of HyperBian
HyperBian

Requirements (shopping list)

You can get everything you need from AliExpress.
Get it even cheaper using a welcome coupon.

  • A Raspberry Pi that’ll run Hyperion via HyperBian.
    Some processing power is required for smooth effects, RPi 3B+ should suffice.
  • Micro-SD card with at least 2GB size
  • Individually addressable RGB LED strips.
    I went for WS2812B eco with a black PCB, 60 LEDs/m. 5V suffices for the length we need and it’s easier because the RPi also runs on 5V.
  • Video capture card.
    The 4K 60fps model is only a little bit more expensive than the 4K 30fps one.
  • HDMI cable.
    You’ll need an extra HDMI cable between the HDMI switch and capture card (if applicable) and between the capture card and your television.
    Make sure it supports the max. resolution and framerate your video sources provide. I got HDMI 2.0 cables which support 4K 60fps. HDMI 1.4 suffices for 4K 30fps, and for 8K you should get HDMI 2.1 cables.
  • Power supply unit (PSU) frame style (5V 60W/12A) or power brick style (5V 50W/10A).
    The required power output will depend on how much LEDs you have (length and LED density) and how bright you have them.
  • Electrical wire to connect the power supply, the LED strip, the RPi, …
  • Sacrificial microUSB cable
    We’ll only need to microUSB port for powering the RPi.
  • Wire connectors (different model)
    For wiring power cables for the LED strip and RPi into the power supply.
  • Female-male Dupont wire
    To get the data signal from the RPi to the LED strip.

Optional

These items may be useful, but aren’t required.

I also advise reading the “Lessons Learned” section at the bottom before starting with the project.

LED strip WS2812Beco
LED strip
Power Supply Unit (PSU)
Power supply
Capture card
Capture card
HDMI switch
HDMI switch

Wiring the LED strip

  1. You’ll first want to measure the 4 sides of your television and envision where you want to place the LED strips.
    The LED strips should be on the back of the television, near the edge.
    Take into account any bumps, holes, connections, … that may cause issues for sticking the LED strip.
    Note that the corner connectors take up quite some space.
  2. Cut the LED strips to size.
    Look at the LED strip for the copper pads you can cut in.
    If you want more space on the pads to solder, you could cut at the end of the copper strip and sacrifice a LED at each cut.
  3. Stick the LEDs to the TV. Start from one corner and work your way around the TV.
    Hyperion by default assumes you start in the top-left corner and work clockwise (as seen from the front) but we can change the config later on.
    Take into account where you want to stick the RPi as you’ll need to be able to connect the data wire to your Pi’s GPIO pin. You can solder the corners, use the corner clips I linked above or carefully bend the LED strips.
  4. If you want to inject power, solder an additional power wire at the end of the strip on the + and GND terminals.
    This is only really necessary if you notice a drop in brightness near the end of the strip.

Note: I used some double-sided foam tape to secure the LED strip to the back of the TV, as well as the hardware we’ll be adding later.
This holds quite a bit better than the adhesive the LED-strips come with.

Providing power

As mentioned above, we’ll be using a sacrificial micro-USB power cable to power the Raspberry Pi.
This is because the circuit behind the micro-USB port provides overpower protection to the RPi (some RPi models include a fuse).
You can power the RPi using the GPIO pins, but these won’t protect the RPi in case of a voltage or current spike.

  1. Powering the power supply
    • Connect the extension cord to the correct terminals on the input side of the power supply.
      Use ring/spade connectors to provide a secure connection.
    • Plug the extension cord in the wall socket.
      Make sure you don’t touch any exposed terminals while the power supply is powered!
  2. Finetune the output
    The RPi expects a power input of around 5.1V. The LED strips will work with this as well.
    • Hook your multimeter onto the output of the PSU and set it to DC Voltage mode.
    • Use the knob at the right of the terminals to tune the PSU to deliver 5.100-5.150V (a tiny margin for voltage drop).
  3. Unpower the power supply again.
  4. Hook the output of the power supply (the 5V side) up to some Wago style wire connectors.
    • Use a red wire for positive (+V) and a black for negative (-V/GND).
      Ring or fork connectors are advised for a secure connection with the PSU.
      Finish stranded wires with ferrules at the other end to provide a secure connection with the Wagos.
    • Note that this wire will carry the load of the LEDs and RPi, so this needs to be the thickest of the bunch.
  5. Provide power to the Rapsberry Pi
    • Cut the sacrificial micro-USB power cable and expose the 2 power leads (usually black and red).
    • Put the red wire in the wire connector with the positive wires and the black with the gnd/negative.
    • If the wire is too short, solder some extra piece of wire to them. Perhaps using the ‘solderless’ heat shrink tubes linked above.
    • Plug the micro-USB connector into the Raspberry Pi.
  6. Powering the LED strip
    • At the beginning of the LED strip, there’s an additional pair with a red (positive) and white (negative/ground) wire. These can be used to power the strip. Solder an extra length of red/black wire to this pair to extend the wire to get to the power supply.
      However, I prefer to solder some thicker wire directly to the copper pads.
    • If power injection is needed, you can also solder an extra red/black wire onto the copper pads at the end of the strip.
  7. If you now provide power to the Power Supply Unit (PSU) again, the RPi should power on. The LED strip will most likely not turn on, as no signal is received on the data line yet.
Picture of back of TV with everything installed
Everything installed on back of the TV

Everything can be installed on a small board and attached to the VESA mounts on the back of the television. This keeps everything nice and tidy.

Installing Hyperion

Installating Hyperion is extremely easy. You just need to follow the short guide on the Hyperion website.
I went with the HyperBian image as it comes with Hyperion pre-installed.

  1. Download and extract the latest HyperBian image
  2. Write the HyperBian image to your micro-SD card using Raspberry Pi Imager, balenaEtcher, Win32DiskImager, …
  3. Setup WiFi and/or SSH, if needed/wanted You’ll need to add a wpa_supplicant.conf and ssh file to the boot partition of your SD-card before the first boot. We discus this in a different post.
  4. Put the micro-SD card in the Raspberry Pi and provide it with power to boot it up.

Once the RPi has booted and Hyperion has started, you can open the web interface at http://<ip of RPi>:8090 to configure Hyperion.

Logo of Hyperion
Hyperion

Tape the RPi to the back of the television to hide it.

Hooking the RPi up to the LED strip

Use a Dupont wire or some soldering skills to connect the green data wire of the LED strip to GPIO18 (pin 12) on the Raspberry Pi.
The Dupont wire’s male end can be pushed into the middle port of the LED strip’s JST connector.

GPIO18 is the 6th pin from the left on the top/outside row.

Image of pinout on a Raspberry Pi
https://www.raspberrypi-spy.co.uk/2012/06/simple-guide-to-the-rpi-gpio-header-and-pins/

Capturing video

The current setup is still quite boring as we can’t match the colours of the LED strip to the image on our screen.
So lets add the capture card.

Note: If you have multiple HDMI sources for your television, first hook them all up to the HDMI switch linked above.
You can also tape this switch to the back of the television.

  1. Tape the capture card to the back of the television.
  2. Connect the HDMI cable currently running to the HDMI Input of your television to the Input side of the capture card.
  3. Get an additional HDMI cable and connect the Output side of the capture card to the HDMI Input of your television.
  4. Connect the USB cables (one for power and one with the capture feed) of the capture card with the Paspberry Pi.

Configuring Hyperion

With the capture card connected to the Raspberry Pi, we can now setup Hyperion to match the LED string output with the captured video.

  • Open the Hyperion Web UI at http://<IP.of.the.RPi>:8090
  • In the sidebar menu, open the Configuration section
Hyperion sidebar menu
Hyperion sidebar menu

General

  • Under LED Hardware Instance Management give your ambilight instance a name.
    I went for the plain-and-simple Ambilight

LED Hardware

  • LED Controller
    Select the correct Controller Type, RGB byte order and Maximum LED count.
    The LED-strips I’m using are of the ws281x type, with a GRB byte order and I have 180 LEDs in total.
    If you’re using a Raspberry Pi 3, set DMA channel to 10. more info The other settings shouldn’t need to be changed.
  • LED layout
    Enter the amount of LEDs you’ve mounted to the top, bottom, left and right of your TV in the Classic Layout (LED Frame) section.
    The view on this layout is ALWAYS of the FRONT of your TV.
    At the bottom, in the LED Layout Preview you’ll see how Hyperion will address your LED strip.
    Change Input position and Reverse direction so the layout preview matches your actual configuration.

Update 2.0.0-alpha.10
The names of these menus have changes to LED Instances and LED Output.
Before you can enable a Source for your instance, you need to enable it under Capturing Hardware first.

Capturing hardware

Here you can configure whether you want to capture the video output of the RPi itself and/or what’s being captured via USB. A lower Priority means this video input is preferred over the other.

  • Unless you want to capture the display of the RPi itself, I suggest unchecking Enable platform capture.
  • Check the box next to Enable USB Capture and set a number as Priority Channel that’s lower than that of Platform Capture (i.e. higher priorty).
  • Under USB Capture you shouldn’t need to change anything.
  • If you want, you can enable CEC detection and/or Signal detection.
    More info on those settings can be found at the bottom of the settings page.

Update 2.0.0-alpha.10
Capture hardware is now off by default, you need to manually enable them.

Effects

  • Enable Boot Effect/Color if you want to have a nice effect when the RPi is booting.
  • I set Background Effect/Color to a solid black, so that the ambilight is turned off when Hyperion is “idle”. You could pick a different effect (e.g., Cinema dim lights, Cinema brighten lights, Candle, …) if you want some ambient lighting of your TV while nothing’s playing.

Update 2.0.0-alpha.10
This section move to LED Instances

Image Processing

You shouldn’t need to change anything here

Update 2.0.0-alpha.10
This section move to LED Instances

Network Services

Make sure the JSON Server is active if you want to control Hyperion from Home Assistant.

Testing the setup

With everything connected and powered up, you can use the Effects Configurator to test certain effects.

Choose a Template, enter a random Effect Name and press Start test.

For example, running Led Test should give you alternating Red, Green, Blue, White and Black (off).
Increase to sleep time to something like 0.5s to see the colour sequence more clearly.
If the sequence doesn’t match, you may need to change your RGB byte order.
Note that there’s a RGB Byte Order Wizard available if you press the wand symbol at the top right.

Note on using WS281x LEDs

Hyperion uses the Raspberry Pi’s hardware PWM (Pulse-width modulation) controller. To interact with this controller, the software needs to run with root (admin) permissions. Without it, your WS281x LED strip will not work!

You’ll need to disable the Hyperion service running under the default ‘pi’ user and relaunch it as ‘root’.

SSH into your Raspberry Pi and run the following commands:

# ssh pi@<ip.of.raspberry.pi> # password: raspberry

# Run Hyperion service as root
sudo systemctl disable --now hyperion@pi.service
sudo systemctl enable --now hyperion@root.service

# Update Message of the Day to check correct service
sudo sed -i 's/pi.service/root.service/' /etc/update-motd.d/10-hyperbian

Note on security
Running 3rd party software as root is against security good practices!
Do NOT run untrusted software with root/admin privileges!

Pitfalls / Lessons learned

During this project I discovered I ordered some stuff that I didn’t necessarily need for this project. And looking back, there’s some stuff I would have done differently.

Let’s say I made these mistakes so you don’t have to … :)

  • Corner connectors
    These corners, including the connectors for the strip and the corner pieces, are quite big.
    You lose valuable LED space in the corners if you use them.
    In the end I used one of the corner pieces but without the connector. I soldered it instead. Which was fine.
    But in the future I’d just go with soldered connections, reinforced with some heat shrink tubing for piece of mind.
  • JST connectors
    Unless you’re building a huge LED strip and you’re pinned on using the tiny wires for power injection, there’s no need in getting JST connectors.
    I actually cut the wires from the spare connector that came with the strip to make the corner connections.
    I added power injection at the end of the strip, using some 18AWG wire soldered onto the pads (and reinforced with some heat shrink).
  • Double sided tape
    I strongly advise using double sided tape, maybe even foam tape over regular tape.
    The adhesive of the LED strip is good in general. But since I had to reposition the strip a few times, it didn’t stick as well anymore.
    The double sided sticky foam I’m using, is incredibly strong. Maybe a bit too much even, it’ll be a pain to take off again.
    Added advantage of using the foam is that it adds a barrier between the strip and the TV for when you’re soldering connections with the LED strip already taped.
  • Ferrules and Wagos
    I’m using no-brand Wago-style connectors (lever clamps) for this project. They’re rated for mains voltage and I’m only running 5V through them, so I feel comfortable using them.
    Since I’m also using stranded wire, I’m using ferrules to provide a proper connection within the Wago connectors.
    Note that while the connectors may support up to 14 AWG / 2.5mm² wires, a 14 AWG ferrule (with some heat shrink around it) will barely, or most likely not, fit. So make sure you use up to 16 AWG ferrules.