Saturday 23 January 2016

How To Build A RaspberryPi based (BananaPro) TV Kiosk

We have multiple pairs of TV's in the office with each pair connected to a mac mini running xStand. They simply display a web page on each TV in full screen mode but you could use them any way you like.

We also wanted a solution that could turn itself on and off which would help reduce our energy bill. The mac mini's have the ability to set power on and power off schedules which is quite nice.

We also needed the TV's to turn on before the mac mini and turn off after the mac mini to ensure the web pages are displayed on the correct TV.

Most of the name brand TV's support auto power on/off schedules straight out of the box but it's quite a large price increase, like the kind that could be spent on a couple of USB missile launchers, or maybe parts to build a 3D printer one day.

So we picked up one of the largest (49 inch), cheapest TVs and grabbed a spare mac mini and off we went.

It worked! for a while. Some of the TV's have this stupid home screen when you power it on which can't be disabled. Every time the TV turns on, you have to press the home button to exit and that's super annoying. We'll get to fixing that later.

Obviously, there's a better way to deploy one of these setups and we believe we've found it. Bring on the BananaPro or as we've come to know them as, the DashPi.

Parts Required


Cost (Time Of Writing) Description Typical Use Case Purchasing Link
$84.95 BananaPro circuit board Pro version of the Banana Pi. https://www.gpio.com.au/shop/banana-pro-starter-kits/banana-pro-banana-pi-pro/
$14.95 Clear acrylic case A protective case for the BananaPi. https://www.gpio.com.au/shop/cases-and-sd-cards/clear-acrylic-case-for-the-banana-pro-banana-pi-pro/
$8.38 1m micro USB cable BananaPro power cable. Connects to the TV's USB port.http://www.4cabling.com.au/1m-usb-2-0-am-micro-bm-cable.html
$15.95 8GB MicroSD Card Operating system/data gets written to this. Faster = better. https://www.jbhifi.com.au/cameras/sony/sony-8gb-microsdhc-memory-card-uhs-i-class-10/837496/
$2.04 Network Cable(s) Might need more than 1 if your using a switch. http://www.4cabling.com.au/0-5m-cat-5e-rj45-rj45-network-cable.html
$10.47 2M HDMI Cable Connects the BananaPro to the TV. http://www.4cabling.com.au/2m-hdmi-v1-4-high-speed-with-ethernet-channel-red-braiding.html
$799 49 Inch LED-LCD Full HD TV Output for the BananaPro. https://www.jbhifi.com.au/tv-home-entertainment/hd-televisions/soniq/soniq-s49vt15a-49-full-hd-3d-smart-led-lcd-tv/734918/
$55.44 TV wall bracket To hang the TV on the wall. http://www.4cabling.com.au/ultra-slim-tv-bracket-up-to-55-75kg-black.html
$991.18Total

If you've decided to go it alone and select your own bits and pieces there's a couple of things you should keep in mind;

Multiple USB ports per TV


If the TV you've selected does not have multiple USB ports, you may need a USB hub if you plan to run more than one device from the TV's USB port.

Cost (Time Of Writing) Description Typical Use Case Purchasing Link
$22 USB hub If your TV doesn't have more than one USB port. http://www.auspcmarket.com.au/hi-speed-usb-2-0-4-port-hub-black/

Ethernet Network Ports


If you're like us and only have one network port on the wall to use with your BananaPro but require two, you'll need a network switch to connect your BananaPro's to the network.

But why bother when the BananaPro supports WiFi?

Because WiFi isn't reliable enough and in production, we found that sometimes the time it took to connect to the WiFi network meant the web pages failed to load.

Cost (Time Of Writing) Description Typical Use Case Purchasing Link
$29.95 USB powered network switch If there isn't enough network ports for your BananaPro to connect to. http://www.dual-comm.com/5_Port_LAN_Switch.htm

Assembly


Build The BananaPro Acrylic Case


Why bother writing stuff up, when you can can link to a video.


Connect Everything Up


The video below is a great resource to use if you want a professional looking installation. The first 12 minutes covers everything you need to know but unlike the above, i've also written something up as well. The truth is that i remembered the video AFTER i wrote this section.



Mount the TV bracket base plate to the wall making sure it is nice and level. Luckily, the bracket we selected has a built in bubble level which makes this task quite easy.

You'll want to make sure you screw into the your wall studs. Otherwise, you might come in one morning to see your TV hanging by its cables or worse, smashed on the floor. You have been warned!

Lay down a blanket, rug or use the carpet before you remove the stand from the TV and place the TV face down against your nice, soft. You'll need to attach the wall brackets to the back of the TV.

Before you hang the TV, it's a good idea to connect your cables while you have easy access to the ports. Connect your HDMI cable to HDMI input 1 on the TV and your Micro USB to any available USB port though i prefer to connect USB cables to the most difficult to access ports first.

Take the opportunity to tidy everything up now because once this is all installed, you probably won't touch it again. Use velcro cable wrap to secure the cables where you need them to be so they don't hang down below the TV height and don't get in the way when you try to mount the TV. You could use cable ties, but you'll kick yourself when you have to make changes to your setup.

Lastly, mount the TV on the wall. You might need an extra pair of hands in order to get it done. Just remember to keep the other end of the cables you attached where you can reach them. You'll soon need to connect the BananaPro.

BananaPro Configuration


Install The Bananian OS


Next, you'll need to download the Bananian OS. I suppose you could use Ubuntu or Debian (all of which can be downloaded from the lemaker.org website) but we chose Bananian. Not sure why though.. and i don't care. I've provided a link to the download page. http://www.lemaker.org/product-bananapro-resource.html

I have managed to track down a video on installing Lubuntu. The process is essentially the same when installing Bananian.


Connect the BananaPro to the TV


Now that your MicroSD card has its operating system, go ahead and insert it into the MicroSD card slot on the BananaPro.



Connect the network cable, HDMI cable and the Micro USB cable to the BananaPro. It's probably worth connecting a keyboard and mouse as well. We'll need them to perform the final configuration on the BananaPro.

You're now ready to turn your TV on (which will also switch on your BananaPro).

Moar Applications!!


Once your operating system has loaded, open Terminal via the shortcut on your desktop. If you need to enter a username and password, try bananapi / bananapi as your username and password.

Chromium is like your normal Chrome browser. I think Google Chrome shares some kind of link to Chromium but i'm not sure... and i don't care. Moving on, we can use this to load a website or maybe a web based slide show, a youtube playlist - whatever you want.

For us, we have a web server in the office that the BananaPro's all talk to. All BananaPro's load the same page making configuration simple and the webserver uses a spreadsheet (A CSV file if you must know) to figure out what content to display based on the BananaPro's hostname. The reason we use a CSV file is to allow other's to change the contents being displayed. I seriously don't want to know every time this needs to happen.

By loading the content in an Iframe and setting a content refresh meta tag on the loader page, we can change the content being displayed in the Iframe whenever we want without having to physically interact with the BananaPro. In our case, we just wait up to 15 minutes before the loader page refreshes and the content in the iframe reloads. Cool huh?

The BananaPro, just like many other HDMI devices has the ability to send audio over the HDMI cable. We decided to take advantage of this by installing text to speech functionality and combining it with aplay (which is pre-installed) to play mp3s.

Since it's really easy to install, we'll install it right along side chromium as well as configure some Stephen Hawking like text to speech alerts using espeak.

Finally, one of the problems with the Soniq TV's is the fact they come with this stupid home screen which can't be disabled. Every time you turn on the TV, there it is and it requires a button press on the remote to get rid of. Let's take care of this as well using lirc.

Install chromium, espeak, mpg123 and lirc


When you run the following in a terminal window, you'll be asked for a password. If you haven't changed your password, this will still be bananapi. Once you've successfully entered your password, apt-get will install the necessary applications.


sudo apt-get update && sudo apt-get install chromium espeak lirc mpg123

When you dump the following into an open terminal, you'll configure Chromium to load at startup and go straight into Kiosk mode displaying whatever page you tell it to display.

It will also disable any power saving functions like the screensaver.


Remote Controlled Crontab (Scheduled Tasks)

Early on we realised that we'd be asked to create recurring notifications. Obviously, we would use cron to automate this task but when you have 50 million of these buggers floating around, you really don't want to log into every single one of them to make them say "Home time!" at 6pm, Monday to Friday.

Enter remote controlled crontab...

Remote controlled crontab uses one crontab entry, generally deployed during initial configuration of the BananaPro. This cron entry calls a PHP file on a webserver somewhere. In return, the webserver responds with crontab which is then saved to /etc/cron.d/remote_cron. The contents of the BananaPro's crontab is dependant on the its hostname.

Why not just add the entries to /etc/crontab? Because if you break this process (which you probably will), you could destroy /etc/crontab which includes the only crontab entry which is capable of fixing your mistake. Using this system, if you mess up your crontab, the only file you'll destroy is /etc/cron.d/remote_cron but as you'll see soon enough you'll be able to fix it.

This guide won't go through how to set up a linux webserver with PHP installed but once you have done so, you'll need to create the following PHP file in the webservers' document root.


This file simply figures out the hostname of the BananaPro that's trying to talk to it, then opens a file on the webserver using the hostname as its key before returning the contents of that file. Sure, we could have written this code a little better but it's here, so you can do that if you want.

With that done, it's time to give our host a task to execute on a regular basis. How bout some audio notifications and an automated shutdown?

Audio Notifications


We also copied an mp3 which plays a couple of bells before the text to speech kicks in. We'll use mpg123 to play the bells followed by a text to speech notification using espeak.


sdfsdfjsdf

Automated Shutdown


Finally, we need to tell the BananaPro to shutdown overnight. To be honest, it's probably not that necessary given how little current the BananaPro's draw but we're paying for it and there's no need for it so let's tell it to shutdown once the majority of people have gone home for the night.

We could also turn the TV off, which would cut the power to the USB port shutting off the BananaPro. However, because we're cool we'll shut it down via crontab.

USB IR Blaster


Finally, we'll connect a USB IR Blaster between the BananaPro and the TV. This will be used to send certain TV remote signals to the TV to exit the stupid Soniq home screen and ensure the HDMI1 input is selected.

To be honest, this part is a PITA. Surely, there's a better way to do this...

No comments:

Post a Comment