Displaying dashboard screens on a TV is a very common case, especially in IT companies. TVs in the offices display business dashboards or the status of applications or infrastructure. Although there are multiple options to do it, in Adform we are mostly using RaspberryPi 2 to display Kibana, Grafana, Zabbix, or other screens.
RaspberryPi 1 is too weak to display Kibana screens properly, therefore we had tried other alternatives as well. Google Chromecast devices, which are easy to use and cheaper than Raspberries, were dropping connections periodically, so they were unsuitable for the day-to-day use. Other options, like MiniPCs, are really good, but they are much more expensive.
RaspberryPi 2 are more powerful than its predecessor and can handle “heavier” dashboards. They are pretty reliable, yet quite cheap, therefore we stuck to these devices.
However, RaspberryPi 2 needs to be configured properly in order to satisfy the following needs:
- The screen should be fully filled with the view.
- After booting, the predefined screen should be loaded automatically.
- The screen should not sleep after some period of time.
- The mouse cursor should not be visible in the screen.
- Menus and the taskbar should not be visible.
- After an unclean reboot (i.e. after power outage), there should be no browser warning about the unclean shutdown.
- It should be possible to connect to the device remotely to reload or change the view.
What You Need
Here is the equipment you need to display dashboard screens on a TV:
- RaspberryPi 2;
- 8GB microSD card (preferrably with microSD -> SD adapter);
- RaspberryPi case (preferrably);
- DC charger with 5V output of 2 Amperes and with micro USB jack (very common nowadays, as it is used for charging smartphones and tablets);
- USB keyboard for configuration; mouse is not necessary.
Download OS for the RaspberryPi
The RaspberryPi comes with no operating system and with no internal storage. Therefore, it is necessary to download the Operating system and install it to the microSD card. The officially supported OS is Debian-based Raspbian, although there are 3rd party OS images available as well.
Although there is a so-called easy installation method, “Noobs”, the regular Raspbian image was downloaded and copied to the SD card.
For this tutorial I was using Raspbian Wheezy. Note that there might be some nuances with the newer versions of Raspbian. Please, share your feedback if you are using Jessie or newer versions of Raspbian.
Copy Image to the SD Card:
Burning SD card from image using Windows can be done with Win32 disk imager application.
From Linux, dd utility is used. Firstly, it is necessary to unmount all partitions from the SD card, if they are mounted. The next step is copying the image to the SD card using the following command:
The dd command parameters are these:
- if - the input file (downloaded image).
- of - the output file (destination). Important: the path might depend on your hardware. It must be a path to the device, but not to the partition. I.e. not /dev/mmcblk0p1(partition), but /dev/mmcblk0 (device).
- bs - the size of a block. If not provided, the default 512 bytes block size is used for copying. Bigger block sizes ensure a better performance up to some level. Providing at least 4 kilobytes (bs=4k) gives the optimal performance.
See also: Raspbian installation guide
After the SD card is prepared, it is necessary to simply plug it in, connect the power and Ethernet cables, and plug the HDMI cable to the RaspberryPi and TV set. The RaspberryPi will boot to the command line.
Firstly, perform basic configuration actions by launching raspi-config utility as a root user:
paulius@pcpaulesl1:~$ sudo raspi-config
Expanding Filesystem to the SD Card
In order to use the full capacity of the SD card, it is necessary to expand the filesystem:
Booting to the GUI Instead of Command Line
In order to fill the TV screen fully with the view, it might be necessary to disable the Overscan:
Connecting via SSH
All this and further configuration can be done by connecting to the RaspberryPi from a remote computer via the SSH:
The default user is pi, password is raspberry.
The one thing that needs to be known is which IP to connect to. This information can be obtained with the ifconfig command (run from the RaspberyPi command line).
Run the following commands to update the system:
sudo apt-get update
sudo apt-get upgrade
The following applications are going to be used:
- chromium web browser;
- unclutter to hide the mouse cursor;
- xscreensaver to disable screen from sleeping.
It is possible to install them from a repository using the following commands:
$ sudo apt-get install chromium-browser unclutter xscreensaver
It is necessary to setup the unclutter to run automatically by writing the following text to file ~/.config/autostart/unclutter.desktop
Exec=unclutter -idle 1 -root
To disable the screensaver, i.e.a screen becoming blank when inactive, it is necessary to create a file ~/.xscreensaver with the content:
We will run chrome by executing the ~/run_chromium.sh script. The only thing that needs to be changed is the URL that has to be opened. Create ~/run_chromium.sh with content:
It uses the custom user directory in order to prevent unclean shutdown errors. --incognito flag should be enough, but if the user profile directory gets corrupted, this is the easiest way to bypass any errors.
--kiosk will run browser in the “Kiosk” mode, i.e. full-screen with some other restrictions.
--disable-translate will not suggest to translate the websites.
In case it is necessary to restart the Chromium (i.e. if it gets stuck or the dashboard URL needs to be changed), it is possible to use the ~/restart_chromium.sh script. It works well when being connected via SSH, so there is no need to plug keyboard or mouse to the RaspberryPi to restart it.
Create ~/restart_chromium.sh with content:
Making Chromium Auto-run
Create ~/.config/autostart/chromium desktop with the content:
Cloning SD Card
After the single SD card is configured, it might be necessary to clone it to run multiple instances of Chromium on multiple TVs. It can be done using the same dd command.
Create an image from the SD card:
$ sudo dd if=/dev/mmcblk0 of=~/sdcard.img bs=4M
Clone the image to the card:
Credits and Further Reading
Big thanks to Julius Vitkauskas for aggregating the best ideas.