How to create a standalone ambilight gadget based on Hyperion and Raspberry Pi
Update 1: Now includes effect engine. Also update Hyperion on Android.
Update 2: The installation script takes care now of startup even, if upstart script is not available. The main difference is that you do not need to use rc.local anymore.
1. What do you need:
- Raspberry Pi
- At least 4GB SD card
- LEDs (I am using WS2801 based one. I’d recommend you to get those one since they are 8 bit. Also remember that WS2811 based one are not supported.)
- USB Video grabber (Use one based on STK1160, since it is supported out of the box in RPi. I assume you can also use one based on UTV007 chip. Somagic based one, do not work under ARM architecture.) This one works eBay link.
- Powered HDMI splitter
- HDMI2AV converter (it converts HDMI to S-Video signal). Be careful that it is HDMI2AV and not AV2HDMI.
- A good power supply (5V 5A for example this)
- Power jack
- Few HDMI cables
- S-video male to male cable or adapter
- Some wires, solder, soldering iron,…
- Optional: If you are going to power LED, RPi and HDMI Splitter from one power supply, you can buy on e-Bay this DC splitter. (always double check polarity +/-)
2. Lets begin….
First download the following image »2013-09-25-wheezy-raspbian.zip« from http://downloads.raspberrypi.org/raspbian_latest and image it to SD card with Win32DiskImager. After that insert newly created SD card into RPi and power it up. Now when RPi is up and on network, SSH into it and execute command:
These two pictures shows, what you need to enable, under advanced settings (SSH and SPI) to get SPI and SSH work.
Then enable root account:
sudo passwd root
You can now insert your USB grabber and check if it is recognized with:
If it is, you should see new port in /dev/video0
(Note: here I am covering only USB grabber based on STK1160 chip. If you have other one, then you have to make it work first, before continuing. Some chip-sets are not working under ARM.)
Now it is time to install pre-requirements:
sudo apt-get update sudo apt-get install libqtcore4 libqtgui4 libqt4-network libusb-1.0-0 libprotobuf7 ca-certificates mplayer
python-devcd /tmp wget -N raw.github.com/tvdzwan/hyperion/master/bin/install_hyperion.sh sudo sh ./install_hyperion.sh sudo rm /etc/init/hyperion.conf
(ignore the error at the end of the script “install_hyperion.sh”. It is upstart script related and we will not use it anyway.)
Ok so hyperion is installed and almost ready to go. We just need to make it autostart.
sudo nano /etc/rc.local
And add the following startup commands in it. You can experiment with mplayer switches to find the sweet spot and feel free to share it:
/usr/bin/gpio2spi </dev/null >/dev/null 2>&1 & /usr/bin/mplayer -tv driver=v4l2:width=72:height=58:device=/dev/video0 -vo fbdev -fs -fps 15 tv:// </dev/null >/dev/null 2>&1 &
The hardest software part is done. Now you need to create configuration file for Hyperion.
Go to https://github.com/tvdzwan/hyperion/wiki/configuration and download config tool. Also read the manual, so that you will know how to create it 🙂
After you have created config file “hyperion.config.json” copy it to /etc/ and replace it with present one. The easiest way to copy file is with WinSCP and root account or. you can copy into /tmp directory and then move it with cli command.
sudo mv /tmp/hyperion.config.json /etc/
If you want you can create additional scripts under /media/scripts/ which you will be able to execute if you would like to use different inputs on USB grabber. For example as standalone ambilight to process TVs internal tuner like DVB-S, C or T. Check connection diagrams for an example. To use S-Video out, your TV must support this feature. You will also need the connector with In/Out switch like this one on the picture below.
Those scripts are easy and they can look like (TV_ambilight.sh):
#!/bin/bash killall mplayer killall hyperiond /usr/bin/mplayer -tv driver=v4l2:width=72:height=58:input=2:device=/dev/video0 -vo fbdev -fs -fps 15 tv:// </dev/null >/dev/null 2>&1 & /usr/bin/hyperiond /etc/hyperion.config.json </dev/null >/dev/null 2>&1 &
Notice the command switch :input=2: This defines the yellow input on USB grabber.
If you own an Android phone, then I’d recommend to download ScriptKitty..
With this app and root access to your RPi you will be able to execute scripts, that you have create under /media/scripts/ with your phone. This way you can switch different video inputs or. make scripts whatever you like to do for you.
For Hyperion there is also a nice app on GooglePlay which allows you to control Ambilight from your phone over network.
I’d also recommend this app to find the perfect light calibration for your leds. You can simulate in real time every settings and later put it into Hyperconf tool to create perfect config file. Also consider buying full version to support developers. Click on icon below to download it.
I will not cover any details on hardware part since it is covered on official Hyperion site https://github.com/tvdzwan/hyperion/wiki/hardware
Since I am using a good power adapter, I am able to power all devices with a single power brick. So I am powering RPi over GPIO pins, HDMI splitter, HDMI2AV does not need any power, since it is juiced over HDMI and of course LEDs.
Note: this should be your last step and make this one when you are certain, that everything is working as it should and triple check wires (polarity +/-) before connecting to power, because you can destroy them easily. Also for every connection use separate GND.or. it is possible that LEDs will flicker.
How can I connect my RPi to WiFi with CLI???
First you need compatible USB Wi-Fi adapter.With the following commands you can connect RPi to your Wi-fi network.
Now lets connect to Wi-Fi over CLI:
wpa_cli > scan > scan_results > add_network > set_network 0 ssid "your_SSiD" > set_network 0 psk "YourPassword" > enable_network 0 > save_config
command will show your current wireless config.
command to show you ip address for the wlan0 interface.
Feel free to buy me a house…
Below are few pictures and links, just to get some ideas….