Configuring a Raspberry Pi as a Dashboard display
May 12, 2016 3 Comments
A while ago my TV died. I say it died, my wife called to say it had a funny blank line running through it, and rather than investigate I took it as a signal that the Universe wanted me to buy a new TV, and you can’t argue with the power of the Universe.
As it turns out there was nothing wrong with it, but who wants to keep a seven year old TV when you can upgrade to a 40” Smart TV with Netflix and Wi-Fi built-in?
Anyway, this led to me having a spare TV, and as my wife ‘wanted that thing out of the house’ I was left with no choice but to take it to the office.
Paul, the owner at IT Authority, then wanted to know ‘what that thing’ was doing in his office. Not wanting to reveal my secret plan to install an Xbox into the office, I said I had donated it to put on the wall to display our dashboards.
Honestly looking back I don’t know where that idea came from, but I was stuck with the task of making it work.
Usually when I find myself in these situations, I turn to my friend Tim Barrett who rarely has his finger on the pulse of technology, never the less, I asked him for his opinion.
I had been thinking about getting a Raspberry Pi because they seem fashionable and this seemed like it might be a good way to use one and when Tim suggested he had used a Pi and ‘Screenly’ as Digital Signage for clients, I was sold on the idea.
I got a Pi starter kit from Amazon for £50, and Screenly is a free download from their website.
For those that don’t know, the Pi comes with, or uses, a Micro SD card with the OS on it. You need a piece of software to extract the IMG file onto the SD Card, but once that is done you pop it in and the Pi boots up.
Screenly
Screenly is a great piece of software, I had it up and running in literally minutes.
Once you have signed up for an account, you need to add a ‘screen’. This is done by booting the Pi and noting down the PIN that is displayed on the screen, and then entering that PIN into your Screenly account.
At this point you can add ‘Assets’ which are URLS, images or videos, and then you add assets into playlists, which your device will show.
As I said I literally had this up and running in a few minutes, and you can see that this is potentially very powerful, given the right content.
Therein lies the problem at this point, for me at least, in that the content I want to display is difficult, if not impossible to display via Screenly because it is behind authenticated pages.
If you are competent with API development you may be able to build custom pages for Screenly to display. As I am not, and I didn’t have the budget to pay one, I decided to just try a ‘normal’ Pi OS.
Raspbian Jessie
I downloaded ‘Raspbian Jessie’ which is the latest, and seeminly greatest (what do I know?) Pi OS.
I used various guides to get up and running, so I will note down my steps and link to as many as I can.
Step 1
Install Jessie and boot up.
Expand the file system to use your full SD card.
Open the Terminal, enter:
sudo raspi-config
Choose the option to expand the file system. Your Pi will reboot.
Step 2
Next I followed Dan Purdy’s guide to setting up a Kiosk Pi.
Again in the terminal,
sudo apt-get update && sudo apt-get upgrade -y
Then, which I have changed slightly from Dan’s guide.
sudo apt-get install x11-xserver-utils unclutter xdotool
Step 3
Next I configured SSH, again following Dan’s guide.
sudo raspi-config
Under Advanced Options, choose to enable SSH.
Now I can control the Pi from my workstation using SSH rather than sitting at it directly. Which is great because the screen is up on the wall and it was a strain to read it, let alone typing out all these commands!
Step 4
Install Chromium, I found another guide linked to by Dan’s commenters here.
From the Terminal, or SSH
wget https://dl.dropboxusercontent.com/u/87113035/chromium-browser-l10n_45.0.2454.85-0ubuntu0.15.04.1.1181_all.deb
wget https://dl.dropboxusercontent.com/u/87113035/chromium-browser_45.0.2454.85-0ubuntu0.15.04.1.1181_armhf.deb
wget https://dl.dropboxusercontent.com/u/87113035/chromium-codecs-ffmpeg-extra_45.0.2454.85-0ubuntu0.15.04.1.1181_armhf.deb
sudo dpkg -I chromium-codecs-ffmpeg-extra_45.0.2454.85-0ubuntu0.15.04.1.1181_armhf.deb
sudo dpkg -I chromium-browser-l10n_45.0.2454.85-0ubuntu0.15.04.1.1181_all.deb chromium-browser_45.0.2454.85-0ubuntu0.15.04.1.1181_armhf.deb
At this point, you should have Chromium installed!
Step 5
Back to Dan’s guide we need to configure our Pi to do certain things at start-up.
In Terminal or SSH
sudo nano ~/.config/lxsession/LXDE-pi/autostart
This opens up a configuration file, which we want to edit. You can read about what these changes do, but for brevity we are basically turning off the Power Management and screen saver, and telling the Pi to start Chromium at boot in Kiosk mode which is ‘full screen’.
@lxpanel –profile LXDE-pi
@pcmanfm –desktop –profile LXDE-pi
#@xscreensaver -no-splash
@xset s off
@xset -dpms
@xset s noblank
@sed -I ‘s/”exited_cleanly”: false/”exited_cleanly”: true/’ ~/.config/chromium/Default/Preferences
# Launch Chromium
@/usr/bin/chromium-browser –noerrdialogs –kiosk –incognito
To save, press Ctrl-O and Enter, then Ctrl-X
Now, what I did slightly differently to Dan is tell Chromium itself which tabs to open, which is the same as setting multiple homepages on normal Chrome or IE configuration. You need a keyboard and a mouse of course to sit at the Pi and manually setup your pages/tabs.
Step 6
Next, for the ‘clever’ part. To get the Pi to switch between tabs.
For this we use the XDOTool we installed earlier, that, and a Cron job
In the Terminal or SSH
crontab -e
It may ask you if you want to use a particular editor, I just chose to use nano.
Add a new cron by adding this line at the bottom.
*/3 * * * 1-5 /bin/bash /home/pi/rotate_tab.sh
This tells the Pi to run the command ‘rotate_tab.sh’ every three minutes. Five days a week.
To save, press Ctrl-O and Enter, then Ctrl-X
Now we need to actually create that script.
In the Terminal or SSH
sudo nano /home/pi/rotate_tab.sh
Again this launches a text editor and inside this script we will enter two lines,
export DISPLAY=’:0.0′
xdotool key ctrl+Tab
To save, press Ctrl-O and Enter, then Ctrl-X
We now have a Raspberry Pi that will auto launch Chromium to your ‘home pages’ at bootup and a script running every three minutes to switch between tabs.
All we have to do is login to each tab (where required) to launch the right content when the Pi first starts up.
For example on my Pi, I am displaying the GFI Max Dashboard, Autotask Service Manager Wall chart and some custom web pages I have created for this project. They contain local weather and travel as well as incorporating news headlines and a clock!
Another cool customisation a commenter in Dan’s page added was to turn the display of the Pi on and off via schedule.
To do that we need two additional cron jobs and two scripts.
In the Terminal or SSH
crontab -e
Add two lines
00 08 * * 1-5 /bin/bash /home/pi/screen_on.sh
00 18 * * 1-5 /bin/bash /home/pi/screen_off.sh
These turn ON the screen at 8am, and OFF at 6pm.
Contents of Screen_On.Sh
#Turn Display On
#!/bin/sh
export DISPLAY=:0
tvservice -p
fbset -depth 8; fbset -depth 16; xrefresh
Contents of Screen_Off.sh
# Turn Off Display
tvservice –off > /dev/null
As I said I copied most of the instructions off of other pages, however a lot of them were out of date and needed tweaking. These are the steps I took to make my Pi function in the way I wanted it to.
Having been using this for a few weeks I have found using SSH to control it invaluable as continually getting a keyboard and mouse out to connect to the Pi would be very annoying. However for some things I have not found a way to control the Pi via SSH, for example logging into a website after a reboot.
For that I have used x11vnc. I looked this up and found the first recommendation was to use TightVNC, however whilst this did indeed connect me to a gui on the Pi, it was displaying a second desktop, so not a true mirror of the display outputted to my TV. x11vnc worked perfectly for my requirements.
x11vnc is simply the server running on the Pi, you still require a normal VNC viewer like TightVNC to connect.
In the short time we have been using the PI as a dashboard we have found increased responsiveness to alerts and a reduction in our ticket queues.
I hope you find this as useful as we have.
Nice guide, thanks! Having the multiple tabs is something we haven’t got working at the moment.
We recently went through something similar. I ended up using a distribution called FullPageOS:
https://guysoft.wordpress.com/2015/10/17/fullpageos-out-of-the-box-kiosk-mode-for-the-raspberrypi/
Then we had some of our devs customise a dashboard for us, using the http://dashing.io/ framework. This would grab details from weather, twitter (traffic reports) and ticket/monitoring information.
I used the TV’s built in on/off scheduler to power it on and off at suitable times.
Excellent guide! I couldn’t figure out the rotation either, so I had to build that into our pages. As a workaround, I pass a parameter to handle a header generation to force refresh.
I pass the ?cycle=true
and it writes a header on all our pages like:
This will load the page in that URL after 30 seconds. Notice I keep the cycle=true going to the next page.
Thinking I’m going to take this out and look at your method! Thanks!
Not sure why the code was left out.. .But here is my header:
meta http-equiv=”refresh” content=”30;URL=’/dashboard/get_nifi_stats.php?cycle=true'”