Light effect for any device with Video output based on raspbmc or OpenELEC and RaspberryPi

“Good news, everyone!”. If you succeeded in creating light effect using the previous entry:  https://blog.jokielowie.com/en/2014/02/efekt-swietlny-dla-media-playera-operatego-o-raspberty-pi/ you must’ve noticed that it’s limited to the content being played by raspbmc or OpenELEC. Luckily thanks to constant development by hyperion’s creator (tvdzwan) we’ve just got ability to use the effect with other devices that have video output the http://pl.wikipedia.org/wiki/Composite_video. Usually modern STB, Blu-Ray player or amplituners sport a SCART output or the yellow colored ‘Video’ output. What is important – they allow both HDMI and Composite video outputs to be working simultaneously.

What is needed ?

This time we need to get a cheap $10 ‘TV grabber ‘ or Video DVR’ USB dongle. It has Composite Video and Audio (L+P) inputs, and those sticks are used to transfer to new world movies from old VHS cassettes:

Ikona dla Grabbera
Raspberry Pi – with grabber

Hardware and software configuration

So those $10 dongles with different names (i.e. EzCap) are equipped with two chipsets: STK1160 or Fushicai. To check which is in our dongle issue

sudo lsusb

OpenELEC

Both are supported by latest OpenELEC (Ghost 13), but make sure that lsmod contains (but not limited to) this modules when Fushicai chipet is present:

# lsmod
spi-bcm2708
videobuf2_core
videobuf2_vmalloc
usbtv

When STK1160 is present lsmod contains (but not limited to) this modules:

# lsmod
spi-bcm2708
videobuf2_core
videobuf2_vmalloc
stk1160

The working grabber can be checked in many ways, for starters let’s issue:

ls -al /dev/video

Plese do remeber if you’ve identfied video0 – or maybe video1 this is important for configuration.

So we’re ready to test – lets grab our first video frame:

OpenELEC:~ # LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/storage/hyperion/bin /storage/hyperion/bin/hyperion-v4l2 --screenshot
V4L2 width=720 height=576
V4L2 pixel format=YUYV
V4L2 grabber signal threshold set to: {0,0,0}
V4L2 grabber started
V4L2 grabber stopped

The result should be the screenshoot.png file – you can use the Pictures menu in  OpenELEC to view it or transfer via Filezilla to PC and view it there.

If you don’t have input video the picture is going to look like this:

Brak sygnału Composite
No Composite signal

If the composite input signal is present and OK you will get a greenish picture – just like form the first days of television:

Niezły domyślny sygnał Composite
Good quality Composite signal

So it works! Don’t worry about the greenish tint we will get rid of with by decimating the frame – we don’t need such precision. Now the part of the kernel that takes care of the grabbing is called Video 4 Linux 2 or simply V4L2. This is enough to make it running – please add the new section of the configuration to /storage/.config/hyperion.config.json but before last bracket:

 /// Configuration for the embedded V4L2 grabber
    ///  * device          : The V4L2, you would like to use [default="/dev/video0"]
    ///  * input           : Input of the V4L2 you're going to use [default=0]
    ///  * standard        : Standard Video (no-change/PAL/NTSC) [default="no-change"]
    ///  * width                : Width of the frame for V4L2  [default=-1]
    ///  * height               : Height of the frame  [default=-1]
    ///  * frameDecimation      : Decimation factor klatki [default=2]
    ///  * sizeDecimation       : Decimation value [default=8]
    ///  * priority             : Hyperion priority channel [default=800]
    ///  * mode                 : 3D mode to use 2D/3DSBS/3DTAB (note: no autodetection) [default="2D"]
    ///  * cropLeft             : Cropping from the left [default=0]
    ///  * cropRight            : Cropping from the right [default=0]
    ///  * cropTop              : Cropping from the top [default=0]
    ///  * cropBottom           : Cropping from the bottom [default=0]
    ///  * redSignalThreshold   : Signal threshold for the red channel between 0.0 and 1.0 [default=0.0]
    ///  * greenSignalThreshold : Signal threshold for the green channel between 0.0 and 1.0 [default=0.0]
    ///  * blueSignalThreshold  : Signal threshold for the blue channel between 0.0 and 1.0 [default=0.0]
    "grabber-v4l2" :
    {
        "device" : "/dev/video0",
        "input" : 0,
        "standard" : "PAL",
        "width" : 360,
        "height" : 240,
        "frameDecimation" : 2,
        "sizeDecimation" : 8,
        "priority" : 1000,
        "mode" : "2D",
        "cropLeft" : 26,
        "cropRight" : 27,
        "cropTop" : 20,
        "cropBottom" : 20,
        "redSignalThreshold" : 0.1,
        "greenSignalThreshold" : 0.1,
        "blueSignalThreshold" : 0.1
    },

Now lets allow OpenELEC to use remote controll – menu Settings->Services->Remote Control->Allow other programs to control remotely. This is crucial to tell OpenELEC that we’re in menu or we’re palying a movie using OpenELEC – which will use the proper source for LED control.

Let’s test then! The effect should be visible while you’re in  OpenELEC or raspbmc main menu (so right after start), but please check if Hyperion, is grabbing the frames while in menu. To turn of the grabbing – go to   hyperion.config.json – and change –  “grabMenu” : false,:

"xbmcVideoChecker" :
    {
        "xbmcAddress" : "127.0.0.1",
        "xbmcTcpPort" : 9090,
        "grabVideo" : true,
        "grabPictures" : true,
        "grabAudio" : true,
        "grabMenu" : false,
        "grabScreensaver" : false,
        "enable3DDetection" : true
    },


What’s the stress for Rpi 1 ? Using 96 LED,  Raspberry PI B 256MB (the oldest model available) looks like this:

 293     1 root     R     397m106.4   0 63.9 /usr/lib/xbmc/xbmc.bin --standalone -fs --lircdev /run/lirc/lircd
 401   400 root     S    72328 18.9   0 17.1 /storage/hyperion/bin/hyperiond /storage/.config/hyperion.config.json

But what if you no longer have Composite/AV output from your other devices ? The answers is simple – use HDMI splitter and HDMI to AV converter.



Light effect for Raspberry Pi based media player – raspbmc or OpenELEC/LibreELEC

Raspberry Pi can be easily used as media player. We can choose from many variations, but the one I’d like to focus on is Raspbmc based on XBMC. Raspbmc with hyperion has ability to drive RGB LED strip or daisychain using Raspberry Pi. The important part is that it will lit the RGB LEDs accordingly to the screen borders in realtime. It’s used to make the visible part of the picture more vivid and extend it beyond the display, and it’s simply quite cool:

So, the effect is interesting, but … it doesn’t bother you ? Will my eyes hurt, or am I going to be distracted by it ? What about fast changing scenes ? Well in fact – no worries, you’ll forget about it in 5 minutes, mostly becasue it effects only perephrial vision. Try it out yourself! As it turns out it’s very important to use original Pi board, since Piotr (more in comments) had bad experience with clones – there’s no communication with LEDs!

Let’s begin, our system will not require any soldering!

List of material

  • 1 piece of Raspberry Pi 2,3 or 4B: RaspberryPi shield
  • 10 jumper cables that fit PINs in Raspberry Pi, you’ll need two male-female and two female-female ones: P2210009-small
  • 1 power source 5V 2 to 6A based on the length and type of LED strip. It’s going to power both LED strip and Raspberry Pi.
  • 1 socket with ability to fit the power source and attach jumper cables: OLYMPUS DIGITAL CAMERA
  • 1 piece of RGB LED strip with  WS2801 chip or other form of RGB LED WS2801 enabled “x-mass liights”. 2 meters strip will fine for 24-36″ TV, while 3 metrs will last for 42-46. You might also find strips using GRB configuration, as one of the commenter noticed – software can also support such configuration – see the Software section and HyperCon

Connecting

CAUTION:  RGB LED strip with WS2801 chips is powered via 5V power supply (PSU) and usually will need about 7 Watts  per meter, so be very carefull when calculating the PSU! We’re going to connect power for Raspberry Pi using it’s PIN – not via USB. Why ? Most of the problems with strip comes when using separate PSUs and it also allows to use just one powerfull PSU, without worrying about USB cable with thin lines. But the downside is that we will be bypassing the internal fuse in Raspberry Pi, so choose a very stable PSU!

Should you choose strip or xmass lights ? Each have pros and cons, but let’s deal with that later.

Lets start by preparing our power socket for connection to RaspberryPI and the LED strip:
Connecting Power Wires
The important step now is to connect data & clock signals to proper end of the strip (look at the arrow):

  • PIN 23 – connect to CLOCK on the stip (abbrv. CL)
  • PIN 19 – connect to DATA on the strip (abbrv. DO)
  • PIN 2 – the +5V – to PSU
  • PIN 6 – the GND – to PSU

Let’s properly wire the power to Raspberry Pi:
2. Power Pins Connected
Same wiring for the LED strip:
3. Connected LED Strip
And finally – clock and data wires connected to LED strip:
4. Everything is Connected
Now STOP:  Did you connect the data & clock lines on the correct end of the strip?

Our cabling should looke like this:

Chip WS2801

Software

raspbmc

Let’s start with raspbmc distribution – first we need to log in via ssh to raspbmc running on Pi. User/password are the same as in default Rasbian distribution pi and raspberry (as of January 2014).
Now let’s prepare to install ‘hyperion’.

Wait, what is ‘hyperion’ ?

Well it turns out that raspbmc already includes the support for  RGB LED strips – it’s called  ‘boblight’. This is a very well working software, but it happens to be slow – when using more LEDs (i.e. 150 when using 3 meters strip). So let’s replace it by better and faster software – hyperionem.

First of all we need to install proper libraries to build the software:

sudo apt-get update
sudo apt-get install libqtcore4 libqtgui4 libqt4-network libusb-1.0-0 libprotobuf7 ca-certificates

Now let’s turn off boblight:
sudo /sbin/initctl stop boblight

All that’s left is to install hyperion:
wget -N https://raw.github.com/tvdzwan/hyperion/master/bin/install_hyperion.sh
sudo sh ./install_hyperion.sh

Let’s test the connection to the strip – lit some LEDs!
hyperion-remote --priority 50 --color red --duration 5000

Now all you need to do is to configure hyperion according to your LED positions and quantity and enjoy the view!
Hyperion manual gives us Java program (), which looks like this:

hypercon_mainscreen_01

So it’s quite easy to select proper number of LED, their placement, clockwise orientation, etc. It’s also the place to check right configuration of the color coding on the strip – RGB or GRB.
Leave all other to defaults and save the file as hyperion.conf.json

Now using scp or FTP – upload the hyperion.config.json file to Raspberry Pi running RASPBMC. Then, login via ssh onto RASPBMC and issue:

sudo cp hyperion.config.json /etc/hyperion.config.json

That’s it!

OpenELEC

Now, OpenELEC is very XBMC-centric distribution, with little overhead of operating system. This comes down to simpler installation, but still I’d like you to go and read the raspbmc paraghraph, as we will need it for configuration.

Hyperion installation is similar, after logging in via SSH – you’ll get direct root access with root password openelec – you need to issue in console:

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

Next please store your config file here:

/storage/hyperion/effects

That’s it!

How to uninstall

But what if we would like to return to boblight and uninstall hyperion ?

sudo /sbin/initctl start boblight

and:
sudo /sbin/initctl stop hyperion
rm /etc/init/hyperion.config.json

SDR using Raspberry Pi: Tracking airplanes above our heads – recieving ADS-B data with visualization using DVB-T dongle

Raspberry Pi SDR

 

Note: There’s a newer version of this entry – updated with latest tests, much easier to install: https://blog.jokielowie.com/en/2017/01/sledzimy-samoloty-cz-2-ads-b-i-mlat-najtanszy-odbiornik-dla-flightaware-oraz-flightradar-24/.

Last time I’ve shared with you the Raspberry Pi “computer for a buck”. Unless you’re are learning Python or playing Minecraft – or better – you’re already bored – I have a new thing fro you. It’s a very nice idea that you can use as your graduation or school project – and it’s all about tracking airplanes high in the sky. From hardware point – you will need a DVB-T/DAB USB dongle – quite easy to obtain and also – quite cheap. We will be aiming to build a very cheap platform to send data back to Flight Radar 24 (and for us too), which gives us premium access and increases coverage of this particular service. So what’s it all about ?

  • spotting – it’s basically taking photos of the airplanes (regular airlines) that are travelling at RNAV. To take a photo – you need to know exactly when they are gonna fly-by and you need to know who’s flying – where to, where from etc.
  • receiving radio signal – we need to receive a specially modulated signal that airplanes are sending and interpret it – I’ll get back to this
  • drawing on the map the up to date position of the airplane and sharing this over local network
  • you can also try to listen to classic FM radio
  • as well as CB, TAXI corporations chatter
  • tracking amateur baloons that go up high into stratosphere
  • if you live near the airport you can also listen to chatter just like LiveATC.net does
  • basically listening to any radio from 50MHz to 2GHz, and demodulating digital signals
  • feeding FlightRadar24 with data and getting premium access

Continue reading SDR using Raspberry Pi: Tracking airplanes above our heads – recieving ADS-B data with visualization using DVB-T dongle

RaspberryPI – best & cheapest computer out there for everybody

pi-unbox There’s no doubt that non-profit organization behind http://www.raspberrypi.org/, the $25  computer (well let’s just say $35 + some xtras) had a huge success and is the next big thing for every computer enthusiast. Raspberry Pi is a full blown computer based on the ARM  architecture  that allows to run different sorts of operating systems. Today we have a choice of many Linux distributions, and the one to start and one to stay with is the Rasbian, based on another famous Linux distribution – the Debian. This little computer is designed in a very smart way allowing you to display video both on Composite only monitors (just back when I had Atari ST in the ’90, and every other Atari/Amstrad/Commodore C4 or Amiga) but also HDMI output, that you can optionally configure to work with any screen. Most HDMI->VGA converters do also work just fine. Raspberry Pi is now shipped in few variants – the classic 512MB RAM in model B is only available as used (just as the A model, that lacked Ethernet port), but previously they had – A i B just 256MB RAM. Today as of 2015 we have still B+ and A+ models – redesigned to allow better power management and distribution as well as the factor of outputs. The flagship today is of course the Raspberry Pi 2 and 3 – 1GB RAM, four cores and backward compatibility, while the version 3 has also WiFi and BLuetooth (LE) onboard, and the cores have been updated to A53 1,2GHz, 64-bit.  To continue the sound is also being transferred over  HDMI, which allows for decoding – but also you can choose analog (it’s on the jack along with composite video). For multimedia player enthusiast – this device is AVC hardware-decoding capable – way up to 1080p with sound – but there’s not default MPEG-2 license – you can order it separately. The original A, A+,  B and B+ had a CPU horsepower comparable to old Pentium II 350MHz, but don’t forget that GPU is 1080p capable. Just to start Raspbery Pi offers: Continue reading RaspberryPI – best & cheapest computer out there for everybody