Realtime TV Monitroing With RPi
Tutorial: Realtime TV Monitoring with Raspberry Pi
24 Apr, 14
At Parallax we love real-time metrics and have employed an army of Raspberry Pi’s which keep us up to date with site and server metrics, and a page full of cats. We have three large monitors which display various different statistics and are fully automated to wake and sleep with the office. Furthermore, we love being able to give these to our clients so they are able to monitor how they’re doing at any given time of the day.
I’m often asked how to set this up so have put together this tutorial to help those who also want to achieve similar results using the Raspberry Pi. I’ll go through everything from first boot (if you’re struggling with installing an OS please let me know) to automatically opening your dashboard or webpage in fullscreen and hide the mouse pointer.
Raspberry Pi Model A or Model B
Any Case (Simple or Luxurious like Pibow)
SDHC Memory Card (I’d suggest 16GB as they’re not too expensive and will have adequate space for the image)
HDMI cable
Micro USB (USB or Plug)
USB Mouse
USB Keyboard
Ethernet / USB Wifi Adapter
Optional
Vesa Wall Mount
Cable Ties
Getting Started
When the Raspberry Pi boots up for the first time you’ll see a small graphical interface called raspi-config which shows options such as overscan, change_pass and ssh.
Note: This may be different if you purchased a NOOBS prepackaged SD but a simple sudo raspi-config from the terminal will give the same result.
First thing we should do is select the update selection from the menu (if you’re connected to the internet)
Then select overscan option and disable it.
Now go back to the first menu and select the ssh option and enable it.
Select boot_behaviour and select it to always boot to desktop environment when it is turned on, rather than the command line interface.
Select Finish and the Raspberry Pi will reboot and automatically boot to the GUI home screen.
SSH
You can either use a keyboard and mouse connected to the pi for the next part or connect via SSH. (I prefer SSH but please skip to Update if you’d rather do it on the pi)
To connect to your pi via SSH (or using terminal on your pi) use the following:
"ssh pi@youripgoeshere"
On the password prompt enter raspberry unless you’ve changed it
Tip: If you don’t know what the ip of your pi is you can use ifconfig from the Pi or if you have nmap installed you can use:
"sudo nmap -sP (NETMASK_HERE) | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}'"
Note: To install nmap on osx use brew install nmap (requries brew)
Update
First thing you should do before installing anything is update, don’t bother upgrading though as something will no doubt break.
sudo apt-get update
Install Chromium
We now need to install the browser and a few other things to make it look better on TVs. To install Chromium, x11-server-utils and unclutter use the following command.
sudo apt-get install chromium x11-xserver-utils unclutter
You can also add ttf-mscorefonts-installer to this if you want which will make the fonts render better (but its not necessary)
Start Chromium on Boot
In order to start Chromium on boot in full screen we need to do the following. cd and edit autostart
cd /etc/xdg/lxsession/LXDE/ sudo nano autostart
Please remove @xscreensaver line as it’s not needed and add the following:
@xset s off @xset -dpms @xset s noblank @chromium --kiosk --incognito http://urltodashboard.co.uk
Modify and exit the buffer to continue (ctrl+x) then Y
Issue a reboot and you’re good to go!
reboot
Advanced: Automating your dashboard
The following isn’t really necessary but it’s rather useful.
Cron jobs are relatively easy to set up and will allow your TV and Pi to switch itself on and off at a given time. We use cron jobs at Parallax to switch on our dashboards when we arrive in the morning then off again when we leave.
To check to see if there is already cron tabs set up use the following command to list them:
crontab -l
There shouldn’t be but don’t worry if you already have some. Create yourself a script to turn the TV back on
sudo touch /pathtofile/nameoffile.sh
Enter this as the contents
#!/bin/sh tvservice --preferred > /dev/null fbset -depth 8; fbset -depth 16; xrefresh
Now set up the cronjob
crontab -e
Add the following lines
0 18 * * * tvservice -o 0 8 * * 1-5 ./nameandpathofcronjob.sh
This will set the screen to come on everyday at 8am and turn off at 6pm. Please see the diagram below for help with cron syntax.
There you have it, a brief introduction to setting up a Raspberry Pi. As a digital agency, it’s incredibly important for us to meet our objectives and being able to display them on dashboards around the office is a fantastic way of seeing how we’re performing.
Want to know more? Just give us a shout.