...light(s) at the end of the tunnel or how to built a dynamic backlight using a RaspberryPi
At the end of 2014 I stumbled over an article about a selfmade dynamic backlight using a RaspberryPi and capable to be fed with every digital and analog signal....just like the ability of Philips TVs which is called ambilight. This tutorial will show you how I managed to built a dynamic backlight.
Used Components:
RaspberryPi2
WS2801 LEDs (50pcs)
Fushicai Grabber
HDMI2AV converter
HDMI splitter
5V powersource (I would recommend one with 12A)
Openelec 5.x.x
level adjustment circuit from 3.3V to 5V
ferrite core magnet
Hier my shopping list:
https://docs.google.com/spreadsheets/d/1xNyoEcq7h39w9kuLI2XSbrretQxTaGIFlrcACEh4K2k/edit?usp=sharing
level adjustment circuit
All used components can be Found in the shopping list above.
a level adjustent hast to be done because the RaspberryPi's output is just 3.3V but the LEDs control voltage is 5V. Most tutorials and HowTo's will tell you, that a level adjustment isn't needed and maybe they are (half) right because you will be able to control the LEDs anyway BUT a level adjustment will prevent you from one huge problem the so called flickering lights (uncontroled flickering of the LEDs)! I also used a 100uF capacitor to prevent the hole system from voltage peaks/glitches.
Here a screenshot of the level adjustment circuit built by me:
https://drive.google.com/file/d/0B0ZcmO7qPop_NHhkSDRkS0ctSFU/view?usp=sharing
Installation
get Openelec image —> http://openelec.tv/get-openelec
write Openelec to microSD (I'm using Win32Diskimager)
plug in the microSD into your RaspberryPi and start up
Check the grabber
if the grabber isn't recognised properly the rest isn't worth the touble! The grabber is the construction's weakest point, so make sure that it is woking!
check dmesg text
fushicai grabber: dmesg |grep -i fushicai
stk1160 grabber: dmesg |grep -i stk1160
https://drive.google.com/file/d/0B0ZcmO7qPop_QnA3MTI1UDBVYkk/view?usp=sharing
if the grabber doesn't appear, send it back or throw it away and buy a new one!
if it is recognised by the dmsg text proceed with an lsusb command
https://drive.google.com/file/d/0B0ZcmO7qPop_R2RSSjFKZy16NUU/view?usp=sharing
make sure that the grabber is recognised with the full discription like in the screenshot otherwise it's a kind of gambling....sometimes it is woking sometimes it isn't. The final test can only be done by taking a screenshot from the connected source but first we have to instal the I/O-PINs and the Hyperion software
I/O-PINs installation
use the following commands:
mount /flash -o remount,rw
curl -L —output /flash/overlays/enable-spi-overlay.dtb —get https://dl.dropboxusercontent.com/u/3669512/temp/enable-spi-overlay.dtb
vi /flash/config.txt
insert the following line at the end of the config.txt:
device_tree_overlay=overlays/enable-spi-overlay.dtb
reboot the RaspberryPi using the command: reboot
Config XBMC/Kodi
connect the RaspberryPi to your monitor or TV and check if the config wizard appears. If the wizard apperas you have to config the System. Make sure to aktivate SSH and Samba, that will make the following steps a lot easier.
In some images the configuration is already done, in this case you will only have to find out the RaspberryPi's IP
instal hyperion
hyperion is the main component that controls your LEDs and analyses the picture
use the following commands to instal hyperion:
curl -L —output install_hyperion.sh —get https://raw.githubusercontent.com/tvdzwan/hyperion/master/bin/install_hyperion.sh
sh ./install_hyperion.sh
create config
get the config tool from here:
https://raw.github.com/tvdzwan/hypercon/master/deploy/HyperCon.jar
create a config following the description here:
https://github.com/tvdzwan/hyperion/wiki/configuration
thats how my config is looking like (download the exampleconfig):
https://drive.google.com/file/d/0B0ZcmO7qPop_R0Y4NzRqbHBIMFU/view?usp=sharing
Here my example config:
https://drive.google.com/file/d/0B0ZcmO7qPop_eUU5QnVuMTJnU1k/view?usp=sharing
finaly put your config in the config directory on your RaspberryPi by using sFTP or the samba share.
Using the samba share you will find the directory config directly.
the actual location of the config file is /storage/.config
replace the default hyperion.config.jar
stop Hyperion
killall hyperiond
start Hyperion
/storage/hyperion/bin/hyperiond.sh /storage/.config/hyperion.config.json </dev/null >/dev/null 2>&1 &
test Hyperion
/storage/hyperion/bin/hyperion-remote.sh —effect “Rainbow swirl fast” —duration 3000
this command causes a rainbow effect for 3000ms
you can also try this command:
/storage/hyperion/bin/hyperion-remote.sh —priority 50 —color red —duration 5000
it turns all LEDs in red for 5000ms
you can download the Hyperion app for your smartphone. Just type in the IP and have fun
take a screenshot
now the band begins to play! here you will see the result of all your hard work.
change directory to /storage/screenshots:
cd /storage/screebshots
take a screenshot by using this command (first stop hyperion!!)
LD_LIBRARY_PATH=/storage/hyperion/bin /storage/hyperion/bin/hyperion-v4l2 /storage/.config/hyperion.config.json —screenshot
now you should find a screenshot inside the directory (there is also a screenshots directory in the samba share) --> check the screenshot
if the picture is black or green, than your grabber isn't working properly. You can try to find a solution using google but I can tell you, save your time and tears and order a new grabber. Take my advice and order more than one and from different shops until you'll find a working one and then send back the rest. It is the fastes way to finish the project. I've spent many many hours looking for solutins, reading articles and posts.....not a single one really helped.
If your screenshot shows a proper image, than you'll have to crop the edges until only the image is left. Use this additional parameters:
--crop-top 0 --> crops 0 pixels from the top
--crop-bottom 0 ---> crops 0 pixels from the bottom
--crop-left 0 ---> you won't guess...
--crop-right 0
--size-decimator 4 --> shrinks the whole picture and saves perfomance
--frame-decimator 2 --> only every second picture is analysed
Here the whole command:
LD_LIBRARY_PATH=/storage/hyperion/bin /storage/hyperion/bin/hyperion-v4l2 /storage/.config/hyperion.config.json —crop-top 0 —crop-bottom 0 —crop-left 0 —crop-right 0 —size-decimator 4 —frame-decimator 2 —screenshot
if you have found the right parameters for your grabber write them down to the hyperion.config.jar into the section "grabber-v4l2"...that should look like this (using my example):
“grabber-v4l2” : { ”device” : “/dev/video0”, ”input” : 0, ”standard” : “PAL”, ”width” : 640, ”height” : 480, ”frameDecimation” : 4, ”sizeDecimation” : 8, ”priority” : 1100, ”mode” : “2D”, ”cropLeft” : 26, ”cropRight” : 27, ”cropTop” : 20, ”cropBottom” : 20, ”redSignalThreshold” : 0.1, ”greenSignalThreshold” : 0.1, ”blueSignalThreshold” : 0.1 },
“endOfJson” : “endOfJson”
Some additional annotations regarding my example config file:
I commented out the XBMC Section ("xbmcVideoChecker") because I am not using xbmc and I also commented out the section "framegrabber" caus it seems to work better.
If you are done with the config file reboot the system and enjoy you multi source dynamic backlight!!
Finaly I'll write something about the flickering light phenomenon
FLICKERING LIGHTS
to prevent the LEDs from flickering I added the level adjustment circuit and I also connected all ground wires (integrated into the level adjustment circuit). In addition I am using a ferrite core magnet around the clock + data cable.
If your setting has flickering lights anyway than try following things:
use a higher signal-threshold in the config
multiply the bautrate (config "rate" section "device")
use a higher priority for v4l2
Now have fun with your dynamic backlight and upvote my youtube video (showing my setting): http://youtu.be/bMwcsKxD5gk














