Ambilight with Raspberry Pi and OpenElec (part 2)

In part 1, we saw how to build the hardware and connect all the wires to the Raspberry Pi for our Ambilight kit.

In this article, we will proceed to install and configure the software to make the magic happens.

Choose the software

To control the LEDs, the two most famous software (at least that I am aware of) are Boblight and Hyperion. Boblight is now an official plugin of XBMC and so very easy to install, while Hyperion is more lightweight and efficient. Hyperion is developed with the Raspberry in mind. Here is an extract from the wiki page of the author:

Why choose Hyperion? Hyperion is built with the Raspberry Pi’s limited amount of processing power in mind resulting in an implementation that is about 15x faster. Where Boblight is setup as a client-server, Hyperion is built in a single app. This drops the need to serialize and deserialize all data sent between the video grabber and the led controller

For this reason I chose Hyperion over Boblight and I can confirm that I do not feel any delay in the use of OpenElec after installing it.

Install Hyperion on OpenElec

The first step is to connect to our Raspberry with SSH protocol. If you have a Windows operating system I suggest you to use PUTTY, if, instead, you are on OSX, the Terminal app will do just fine.

 

Connect from Windows

To connect with windows download PUTTY and launch it, no install needed. Fill in with your OpenELEC IP, select SSH connection and then press the “Open” button.

You should have something like the picture below (as you can see, the IP of my OpenElec is 192.168.27.13):

PUTTY Configuration

 

Connect from OSX

To connect to your OpenElec from OSX just open a Terminal and then, from the main menu, select Shell –> Open Remote connection. A new window will open asking to select the connection type and server IP.

Select SSH on the left panel and, in the right one, press the + button on the bottom and insert the IP address. Leave the user name empty for now and press Connect.

You should end up with something like this:

Terminal OSX OpenElec

 

Install

From this step onwards, the procedure and what you will see in the terminal window, will be the same for both Windows and OSX.

If you did everything correctly, you should see the terminal asking for username and password. Insert root for the username and openelec for the password.

These are the default values after a clean install of OpenELEC. So, if you changed it, login with the correct password for the user root.

You should see a screen like this:

OpenElec login

 

What we will do now, is download the script for the first installation of Hyperion.

In the console, write or paste this command:

curl -L --output install_hyperion.sh --get https://raw.githubusercontent.com/tvdzwan/hyperion/master/bin/install_hyperion.sh

When the download completes without errors, execute this command:

sh ./install_hyperion.sh

If everything went as it should, you know have installed Hyperion successfully.

We have already done half of the job. Here is what you should have on your terminal:

Hyperion install done

 

Configure

Before proceeding, from this link, download the program HyperCon. Be sure to have java installed on your machine and then execute it.

Here is a screenshot of the program with my configuration loaded:

HyperCon

As you can see, the configuration is straightforward. Just specify the chip type and the number of leds that you have on the sides of your television.

For our specific setup (see my previous post here), we need to make some adjustments in the Construction section. More precisely:

  • Direction: counter_clockwise;
  • Led in top corners: true;
  • Led in bottom corners: false;
  • Horizontal #: 22;
  • Vertical #: 13;
  • Bottom Gap #: 22;
  • 1st LED offset: 14;

While you change these settings, the main picture on the right should adapt. You should see “led count 50” in the bottom right corner of the window, the first led (with index 0) in the bottom right corner and the last one (with index 49) in the bottom left corner of the black frame.

Vertical # and horizontal # indicate the number of leds on the sides. In my case 13 leds on left and right borders and 22 on the top one. The bottom gap # is the same as the top one, because I do not have leds on it.

Now we just need to create and save the configuration file by pressing Create Hyperion Configuration. When you do that, the program will ask you where to save the file.

Do not change the name and save it where you prefer on your computer. Remember where you saved it, because we will need it in the next step.

 

Important change to the config file

Before copying our file to OpenELEC, we must make a change to the path of the Effects folder in our configuration. It should be /storage/hyperion/effects instead of /opt/hyperion/effects. Hyperion folders on OpenElec are in different paths than the standard ones.

Open your configuration file (hyperion.config.json) with your preferred editor, go to line 366 and do the change.

From this:

edit_hyperion_config_before

to this:

edit_hyperion_config_after

 

Copy the configuration to OpenElec

We are almost done, we just need to send our configuration file to OpenElec and then test if everything works as it should.

To copy the file, use your preferred file manager and copy the hyperion.config.json to the Configfiles folder. In this folder, should be already present a file with the same name. In case, just overwrite it.

In the below picture I used Total Commander, but I think you will understand what you need to do with your file manager:

TotalCmd_HyperionConfig_Copy

Restart your Raspberry Pi and Hyperion will be ready.

If everything went right, while OpenElec load the XBMC, you should see the Hyperion’s rainbow effect executing.

 

Test our setup

To be sure that Hyperion is configured correctly, you can use this YouTube video. To do that, you can download the video and copy it to a USB pen, or install the YouTube add-on of XBMC. The result should be like my video here:

If you want to do more testing, connect to OpenELEC and launch one of these commands:

/storage/hyperion/bin/hyperion-remote.sh --priority 50 --color red --duration 5000
/storage/hyperion/bin/hyperion-remote.sh --effect "Rainbow swirl fast" --duration 5000

The first command will light the leds with color red for 5 second, while the second will execute the rainbow effect for 5 seconds.

Final notes

If you need it, here you can download the config file generated by HyperCon and used in this post.

That is it, now you have a cool ambient lighting for your Raspberry Pi.

 

Update

For a solution that accepts any video source, look at part three

 

  • Pingback: Ambilight with Raspberry Pi and Openelec()

  • slidvendetta

    Is there any way to configure this with a capture card to support other inputs?

  • Daniel

    thanks

  • Pingback: max()

  • Ayman Kampoori

    hello, when i want to complete the first installation of hyperion, it does not let me as it says its a read only file system. please help. thanks

    • Hi, are you sure to be connected to your raspberry with the root privileges?

      • Ayman Kampoori

        Yes, thanks. i have solved the problem now, i forgot to use root privileges. also, can i connect the led lights directly to the GPIO pins or do i have to use the DC jack?

        • As wrote in part 1, I suggest you to not do that, because you may risk to burn your board

  • Andy Bailey

    thanks for the tip on changing the path value, once I did that my hyperion android app was able to show the list of effects

  • Pingback: Ambilight from any video source with a Raspberry (part 3)()

  • Pingback: Configuring an IR remote control with OpenElec 5.0()

  • Guest

    I have already installed Raspbmc, how do I unstall it? I want to install Openelec instead. Or can I just install Openelec and it will overwrite Raspbmc?

  • gregory

    Fallowed all the instructions except every time I try load my custom config with 98 it always load default one with 50 LED

    • Hi, if you try to turn on all the leds from the command line everything works (see at the end of this post on how to do it)? Can you double check that your config file is in the right folder?

      • Javier Sanz

        Hi, I have the same problem. I’m using a RPI2 and always works only first 50

        • Javier Sanz

          forgot this reply… I didn’t read the previus post… 🙁

          • Ondrej Sokol

            Hi Javier, how did you solve the problem? I have the same problem that only 50 leds are ON. My config file is OK and I upload it to /storage/hyperion/config
            did you make any changes in /storage/hyperion/init.d ? I tried also change this file anyway no success. thanks

          • Javier Sanz

            Hi Ondrej,

            You have to copy the config file in /storage/.config. In this location there is another config file that you must delete and replace for yourself file.

          • Ondrej Sokol

            Hi, of course I changed original file with my new config. Anyway did you make any changes in init.d folder?

          • Javier Sanz

            You have to copy the config file in /storage/.config instead of /storage/hyperion/config and it’s not necessary modify ane in init.d folder

          • Ondrej Sokol

            thanks Javier, everything works perfect

  • Travis

    Great site lots of useful information! If anyone can please help stuck on config file with open elec (Gotham) and Hyperion. Have Hyperion installed on raspberry pi and correct path changed on both hypercon tool and verified in config file using text edit. Problem I’m having is when altering file (50 led) to something more or less and overwriting, config File defaults back to 50. Tests listed here (red led) and rainbow swirl work but again only with 50 LEDs. Any help would be greatly appreciated feel I am close not sure what I’m missing. Thanks in advance

    • Maybe you do not save the config file in the correct directory?. Can you double check the path and that the file is effectively overwritten? Also, after updating the file try to reboot your pi, just to be sure.

      • Travis

        Thank you for response back. Yes config file is in storage/Hyperion/config (only file in that folder is Hyperion.config.jsor) which is overwritten with mine. Also used somba as per the tutorial above to check all config files which is also matching. If it helps I am using a lightberry lightpack purchased from lightberry.eu and raspberry b+. Tried again last night still displaying 50 led on startup where as my setup calls for more like 130 led

        • Another stupid question, are you using OpenElec 4+? Because with different distros (raspbmc for example) the path where to save the hyperion config file may change. Also, if you completely wipeout the config file, hyperion give you an error or you are able to light up the led anyway?

          • Travis

            Not a stupid question at all. Yes I’m using open elec 4+. Can actually boot from either Raspbmc or open elec on my pi and yes path would be different between the two (Raspbmc would have opt in path I believe where open elec is in path storage/Hyperion/effects) which is confirmed. Have not tried wiping out config file and booting pi on open elec to confirm no led startup. Appreciate all the help. Kinda stumped.

          • That’s strange. Let ‘see what happen when you erase the configuration file

          • Travis

            Hey!

            Sorry for the delayed response back getting pretty deep into this thing! As an update I cleared everything out reinstalled disk images and now have pi solely running open elec only (used for just Hyperion/led setup) you were 100% right config file was not in right directory (had to find hidden .config folder and change file) boot screen now works with all LEDs in rainbow swirl effect and in kodi 14,2 with open elec 5.0.3 lights react to change in screen.

            New problem: trying to use your references for installing stk1160 usb grabber into config file to use with other hdmi sources. Upon editing with default values (before screenshot) boot screen still goes as usual but when loaded in openelec I get wild fast rainbow effect with all LEDs. Tried to run command to get screenshot with grabber but I get “frame to small” error nonstop.

            Sorry for lengthy response but I’m so close! Last step need your advice! As always thanks for your help, much appreciated!

          • The “frame too small” is a know problem. The USB is the bottleneck. Are you connecting just the grabber to the Pi? Have you tried with a powered USB? also try playing with the –frame-decimator and –size-decimator. Also look at this page for some more insight: https://github.com/tvdzwan/hyperion/issues/41
            As a last resort, change the grabber and try with a fushicai chip.
            Hope it helps.

  • RazorHD

    Complete newbie here:
    I have everything installed, followed your guide to the letter. None of my LEDs are responding to anything. My wiring is good. If I unplug and plug back in the LED strand, sometimes a few will light, sometimes the first LED will light. Random colors.

    This is a brand new Pi and I’m new at this, so: Do I need to enable the SPI pins with PuTTY or is this something that hyperion did without me knowing?

    • OpenElec enable the SPIs automatically, so you do not need to do anything.
      Here are the stupid questions:
      have you double checked that you have connected the correct pins (the random colors when you power up the strand, happened to me when I misplaced the connectors)?
      Are you sure you placed the config file in the right path?
      If you execute the command to turn all the leds red, you get an error message or simply nothing heppens?

      • RazorHD

        I have 5V to pin 9, DI to pin 19, and CI to pin 23.
        I need to double check the correct path for config file.
        When I run a command to check the lights nothing happens.

        • I am not at home, but from what your are writing you should connect the ground and not the 5v. Connecting the 5v AFAIK can brick your pi.
          Double check the image on part 1, the numbers do not ring a bell. sorry I can not be of more help

          • RazorHD

            I meant GND.
            I’m at work as well. Thanks though.

  • lierez

    hi
    i downloaded the hypercon but i cant open it.
    i received this message when i double click the .jar file
    “The file ‘/home/lierez/Downloads/HyperCon.jar’ is not marked as executable. If this was downloaded or copied from an untrusted source, it may be dangerous to run. For more details, read about the executable bit.”

    i have java installed on my machine (i am using ubuntu, there is a way to do this on windows?)
    thank you for your help.

    • The jar file is like a Zip archive. To execue it you must have java installed. On windows it will simply execute. In linux other than having java installed, you must mark as executable the jar file and it should works

      • lierez

        i used “java -jar HayperCon.jar” to open it in windows with the command prompt in the folder i downlaoded it.

        thank you
        now i just need to wait for the leds…

  • Miguiza

    First all many thanks for the tutorial. I have bougth ws2812s leds instead of the ones used here. I guess that hyperion configuration should be changed to control them and that the pins used may be different. Any clue about this?thanks!

    • The pins of the raspberry do not change as far as I know. To know if Hyperion supports your specific leds, you should check the wiki on github, I never used them so I can not help you directly, but I suppose that, if Hyperion support your leds, nothing should change in the steps of this tutorial.

  • Rick

    hi, nice explanation and very clear 🙂
    i just have one problem and that is that my ws2801 led strip doesnt react at all.
    When i connect it directly to the power supply only the first led gives white light and this change color when i bend the strip.
    Would it be possible that my led strip is defect?

    • Have you double checked the pins connection? If you try to send the command to turn all the leds red what happens?

      • Rick

        this is the way i connect it: https://christianmoser.me/wp-content/uploads/2014/02/diagram.png

        I have Raspian and Openelec 5.08 and hyperion installed.
        to test i used your configuration in hypercon, after saving i edit the /opt/hyperion/effects in to /storage/hyperion/effects
        after that i used total commander to place the file in the config files folder so basically i did all as explained here.
        After restart nothing happends but few minutes later as im typing this message the 2nd and 5ft led went green 😐

        Oh yeah i have the full 5mtr (160 leds) hooked up as im still testing.

        /opt/hyperion/effects

        • Rick

          when i open openelec with putty and run the command to turn all the leds red nothing happends, just get this message:
          Connected to localhost:19444
          Set color to 255 0 0

          • Rick

            i feel kinda stupid, i used the pins as shown for pi model B and i have the pi2 B
            changed it allready (5v tp pin 2, gnd to pin 6, DI to pin 19, and CI to pin 23)
            still nothing

          • What comes to mind is that the 5v pin can not supply enough power to your leds. I suggest you to not use the 5v pin of your board, but instead a power supply with the correct amperage.

          • Rick

            I was using a 5v 10amp power supply.
            So can i use the original mini usb power supply for the pi and the led strip only on the other power supply while di and ci are still on pin 19 & 23?

          • I will definitely try that. Remember to connect also the GND. At the end of part 1 (http://alessandrocolla.com/ambilight-raspberry-pi-openelec-part-1/) there is the list of the pins of Pi2. if you need it.

          • Rick

            so when the led strip is on external 5v and raspberry gnd pin, nothing happends whit the leds. When i connect the led strip gnd to the external power supply some leds flicker.
            Now with CI & DI on the raspberry just 4 leds start flickering different colors. When i bend the strip, touch any wire or disconnect either CI or DI all kinds of leds start to flicker.
            When i disconnect either CI or DI the leds stop flickering and just burns different colors.

          • ABBA

            Rick, keep in mind that the Raspberry Pi 2 B uses 3.3V on its IO pins. To use a 5V I2C bus (which WS2801 is) you’ll need to put a level shifter in between the Pi and the LED strip. This is a known issue when using different voltage levels on an I2C bus.

          • Rick
  • Carmo Sardinha

    After struggling for an entire night finally figured out how to get this to work with Raspberry Pi 2 OpenElec.

    The spi is not enabled by default. We have to enable it first.

    1) ssh to openelec
    type the following commands

    2) mount -o remount,rw /flash

    3) cd /flash

    4) nano config.txt

    add the following line :
    dtparam=spi=on

    save the file by pressing ctrl+x or ctrl+w (I don’t quite remember)

    Also configuration generated by Hypercon didn’t work for me..

    I used the lightberry hypercon configurator

    http://raspberry-at-home.com/kodi-plugin-hyperion-configurator/

    • That’s odd, I never manually activate the SPI with a fresh installation of openelec (at least with their iso image)

      • Carmo Sardinha

        Are you using a RPi2?? Btw.. I need your help.. After getting the leds to work the colours are not quite right..for eg..The red colour shows up as blue on my leds..What could be the problem..I’m thinking its the cobfiguration file..What are your thoughts??

        • Check the hyperion configurator GUI. You can specify the color sequence. RGB, BGR etc.

          • Carmo Sardinha

            Ok..Thanks..I’ll try that..

          • Carmo Sardinha

            Just changed the sequence to BGR and it now works like a charm.. Thanks a ton dude..

          • Glad it did the trick 🙂

          • Carmo Sardinha

            Had another issue..The bottom LEDs don’t light up.. I have set the bottom gap at 0 in the Hypercon configuration tool..What could be the issue??

          • If you create a new configuration, without gap or anything, and send the command to turn all of them red, it works?

        • You are right I am not using Rpi2 ma the hummingboard. I will try what you wrote. Thanks for your time!

  • Pablinho

    Hi! I dont have a ws2801 led strip, i configure hyperion using None as the type device, but, what raspberry gpios should i connect to the strip?

  • Roy

    Thanks a lot Alessandro! Great site!! I’ve followed your instructions, and my ambilight is now working
    perfect!

    When working with Raspberry Pi2 Model B + WS2801 led strip: I had to manually activate the SPI by “dtparam=spi=on”. And i had to Change the RGB to BGR because red was blue and otherwise!
    After that everything is working fine. Thanks 🙂

    • I am glad it helped. I plan to write a post with all the changes for the pi2 and some other quick fixes that have arose in the comments in the last year

      • Roy

        Today i tried to install the hdmi support without the leds connector. When I came home i plugged the leds to the pi.
        A few random leds are blinking but the leds doesnt respond at all.

        All the connecties are ok. And the pi config is fine. I put the Original Json file back but it doesnt work anymore.

        Any idea?

        • Nothing come to mind, sorry. Are you sure you overwrite the right config file? if you send the command to turn all the leds red, what happens?

          • Roy

            Fixed it already. Was a bad connection between de GPIO and the leds.
            But i’m stuck at part 3 at the moment… 🙁

  • shay

    hi

    thanks for the great instruction.

    i did all the steps just like you showed but the led dont work at all.

    i tried the leds with an arduino board and all of them worked fine.

    i got a raspberry pi 2 and when i send the test commend i get

    Connected to localhost:19444

    Set color to 255 0 0

    but nothing happens with the leds.

    please help me this is really frustrating.

    • Hi, with raspberry pi2 the gpios are not on by default. Open the file config.txt on the sd card from you pc and add the following line: dtparam=spi=on
      Let me know if it worked. I will soon prepare e post with all this kind of things.

  • PuckStar32

    hi there, maybe you know the answer.
    I connected 90 WS2801 leds and have 6A to power it. Strangely only half of the leds work.
    They work fine, change color with the video etc. but any idea why the other half is not working?
    I tested if there is power coming through and that’s the case. 5,2V.
    Also the last led keeps burning the same color. so it’s not a connection issue I guess.

    Any help appreciated.

    • Two things come to to mind:
      1) The leds are configured properly via hypercon?
      2) Maybe one led is faulty and is shortcircuiting. As a last resort you can try to cut it away

      • PuckStar32

        Solved!!!!
        It was the hyperion config. Apparently (in the new version you can SSH the config straight from Hyperion on your pc to the pi) the config file was not sent to the proper directory. So the config file never got properly updated.

        Now it’s working!!!!

        BTW thanks for your quick reply!

        • Glad you solved it

          • PuckStar32

            Yeah. But now i’m trying to get the right values because often the leds are flickering. Unfortunately there is no clear documentation of what all the settings do so I’m just trying all kinds.
            If you have a tip…. 🙂

          • For the flickering try to look for the timeout option. I do not remember where it is excatly in hyperconfig, but I am quite sure is there 🙂

          • PuckStar32

            after spending hours to get proper lighting (I want it to be subtle and as accurate as possible) and trying to get rid of the flickering I thought of connecting a ground wire at the end of the led strip to the same ground of the power supply. So now it’s grounded from both sides, and guess what? That solved the flickering!!!!
            So apparently with 90 leds it’s needed (at least in my experience) to also connect a ground wire at the very end of the led strip.

            I’m putting up a webpage of my own with some info on how I managed to get ambilight working and I’m sure gonna mention this as well.

            thanks for your help though.

          • Me too I am preparing something like that, but in the last months work completely absorbed my time :/
            Enjoy your new ambilight mate

        • Kozakievich

          Hi, I’ve the same issue as you. Please tell me where do you place a config file? And how I can do it?

          • PuckStar32

            I will let you know soon!

          • Kozakievich

            Ok, thank you! I’ll be waiting for it.

          • PuckStar32

            Ok I don’t really time now but looked it up for you :).
            I have it in this location as a shortcut: /etc/
            and the shortcut goes to: /opt/hyperion/config/hyperion.config.json

            But did you write it down after you installed hyperion?
            “sudo sh ./install_hyperion.sh

            Press enter and after the installation is finished (may take a few minutes) write down the path of the config file!”
            As I described it on my website: http://www.puckstar.com/ambilight-for-kodi-osmc/
            Note that I didn’t update this site after hyperion was also updated, so it may well be that updating the config file through hyperion works well now.

            Let me know if you succeed.

          • Kozakievich

            Thank you very much, I’ll try it.
            I’ve one thing to tell you, I’m using OSMC… I’ll try instalation by that tut https://hyperion-project.org/threads/raspberry-pi-3-mediacenter-hyperion-ambilight-no-soldering.77/ but it fail and i’ve problem with 50 light up leds, rest of it (82) isn’t works.

          • PuckStar32

            I use OSMC also. I’m quite sure the other leds are not working because you are not updating the correct config file.
            So indeed try the location I told you.
            Good luck and you can also chat with me via gitter, nickname PuckStar

  • Pingback: Ruksis780()

  • Pingback: How To Arduino Ambilight | enjoyhowto.com()

  • Peter

    Hi there. I have some trouble getting the grabber to work. When I take a screenshot, it was at first a lot of colored stripes like a rainbow. So i changed the hdmi2av and now my screenshots are all black or all green. My grabber (logilink with fushicai chip) is connected directly to my pi.
    The pi finds it as a easycap fushicai. On the hyperion site they say that logilink grabbers do not work, but i have seen many tutorials where one like mine is used. I do not have a usb hub, but should i buy one? Or is it my grabber or still my hdmi2av.
    My pi is powed by my tv in a 1A usb, and i put a usb_max_current=1 in my config.txt

    I’m running openelec 6

    Have been working on this for 3 days now, so help is much appreaciated

    • I do not have direct experience with Logilink grabber, but the USB hub will not change how it works. The only thing that comes to mind is that, maybe, your pi is under powered. If you power it up with at least 2A (for pi2/3 https://www.raspberrypi.org/documentation/hardware/raspberrypi/power/README.md) what happens?

      • Peter

        It’s only a pi b+
        I can try using an ipad charger. Do you know if the pi can take the extra amps?

        • It should handle it, but I am not 100% sure.

          • Peter
          • Then the problem lie with the grabber I am afraid. The last resource is to try with another grabber. Sorry I can not be of more help

          • Peter

            Do you have a link for one that works. I’m from denmark, so it must be from Europe.

          • The one I link in my blog works fine for me and my friends

          • Peter

            It is not possible to order the one you link to. I don’t speak italian, so i can’t understand why? Could you find alle link for a simular?

          • Peter

            The grabber from lightberry should work i think. It says it has the utv007 chipset. That is the fushicai right?

          • It should work. Concerning the EasyCap, maybe you can not buy form amazon italy, becasue they do not ship that particular item to your adress. Anyway you can easily find it on amazon.com by searching for the item called EasyCap. Beware that, as I wrote in my post, there is no guarantee (remote but there is) that you will not get a fushicai chip. At least from the testimonials you can find on google

  • Matthew Dewey

    A question, have you ever configured the hyperion.config.js on file with the led type APA102 http://www.ledlightinghut.com/apa102-digital-led-strip.html?