Hardware: Raspberry Pi - Dashboard (Kiosk)
Do You have spare RPi and big monitor / TV ? If yes then let's try to build dashboard. There are several ways how to get "data" on screen. Most common is to use browser to do all rendering and remote connections. This article describe configuration using browser. Browser needs X11 subsystem and there are several ways how to start X11 + browser. I selected two most common options.
- 1 Base OS
- 2 OS configuration
- 3 Option 1 -> Browser started using display manager
- 4 Option 2 -> Browser started using init
- 5 Synthetic F5 (reload)
- 6 (optional) Snapshots
- 7 Dashboard source possibilities
- 8 Modifications
I recommend Rasbian installed using unattended installer. Keyboard is not necessary to perform installation and re-instillation. This article describe re-installation but with small modification you can use it also durring initial installation. Raspbian UA installer can be obtained from release page or homepage.
/boot and replace it with UA installer.
cd /root wget https://github.com/debian-pi/raspbian-ua-netinst/releases/download/v188.8.131.52/raspbian-ua-netinst-v184.108.40.206.zip cd /boot rm -rf * unzip /root/raspbian-ua-netinst-v220.127.116.11.zip
Configure root file system type and hostname / domain. Edit
/boot/installer-config.txt and insert following lines:
hostname=RPi-hostname domainname=localhost.localdomain rootpw=root rootfstype=btrfs
Alter hostname / domainname to fit your installation. Root password stay visible in this configuration file after installation. I recommend do leave it as is here and change it later.
cd / umount /boot reboot -f
For more details review Raspbian UA installer documentation. After installation log-in using ssh and user: root / password: root"
UA installer install only minimum packages and configuration files. It is necessary to "customize" system upon first log-in.
en_GB.UTF-8... en_US.UTF-8... sk_SK.UTF-8...
Base packages installation
Minimum set of tools:
apt-get install raspi-config btrfs-tools apt-utils
Note: separate installation of "apt-utils" will speed up installation of packages later
System tools (may help to diagnose problems):
apt-get install screen htop nload git-core traceroute mc ddrescue rsync vim pydf lsof psmisc unzip util-linux collectl
HDMI port configuration
I highly recommend to disable overscan and properly configure connected TV / Monitor. It is necessary to switch TV aspect to "1:1", "Just", "16:9", "PC" or other mode (depending on vendor) to get 1:1 pixel mapping. Screen may be blurry without this configuration.
Overscan can be disabled by editing
/boot/config.txt. Add following line:
It may be neccesary to tweak it a bit more (depending on age of TV). Check RPiconfig for more details. Configuration is loaded on next reboot.
If You don't like default NTP configuration and/or RPi can't be auto-configured (via DHCP) then configure NTP manually. Here is example how to do this configuration:
NTP daemon should be installed but to be sure:
apt-get install ntp
/etc/ntp.conf. I am using following configuration:
# Name of the servers ntpd should sync with server ntp-server1 server ntp-server2 # local failback in case of network failure server 127.127.1.0 # you should not need to modify the following paths driftfile /var/lib/ntp/ntp.drift logfile /var/log/ntp.log # restriction config restrict default nomodify notrap nopeer noquery restrict 127.0.0.1 nomodify notrap nopeer # EOF
Note: replace ntp-server1 and ntp-server2 with local ntp servers
Restart NTP to load new configuration:
Verify configuration using following command. It may take some time before NTP protocol settle down.
Root Password + accounts
If You don't changed root password yet, then I recommend to do it now:
Add user account(s):
useradd --create-home --shell /bin/bash lukas passwd lukas
Replace "lukas" with your preferred name :o)
Add dashboard user:
useradd --create-home --shell /bin/bash dashboard
(optional) Migrate system to subvolume
One of great benefits of BTRFS is ability to take snapshots. It is necessary to have system in subvolume in order to utilize all its features. Here is step by step guide how to migrate system into subvolume.
Configure boot subvolume. Edit
/boot/cmdline.txt and add following to end of line:
/etc/fstab and modify definition for
/ to looks like:
/dev/mmcblk0p2 / btrfs noatime,subvol=system 0 0
Add entry point for btrfs system. Edit
/etc/fstab and add following line:
/dev/mmcblk0p2 /btrfs btrfs noatime,subvolid=0 0 0
Create mountpoint and try to mount btrfs entry point:
mkdir /btrfs chmod 0 /btrfs mount /btrfs
Create subvolume by using snapshot feature:
btrfs sub snap / /system
Create file that indicate successful boot from subvolume and reboot system:
touch /system/boot_ok.txt shutdown -r now
After reboot check if
boot_ok.txt is directly in
/. If yes then proceed with clenaup of
/btrfs. There should remain only "
system" subvolume / directory.
Option 1 -> Browser started using display manager
Required packages (Op1)
Following packages are required:
apt-get install midori unclutter x11-xserver-utils lightdm lxde
Note: unclutter will make sure that mouse pointer is hidden while input is idle.
Automatic cleanup. This will ensure that there will be no data left over from previous run of system / browser. Edit
/etc/rc.local and add:
find /home/dashboard/ -mindepth 1 -delete
LightDM configuration. Edit
/etc/lightdm/lightdm.conf and replace it with:
[SeatDefaults] xserver-command=/usr/bin/X -s 0 -dpms default-user=dashboard autologin-user=dashboard autologin-user-timeout=0 user-session=LXDE greeter-session=lightdm-gtk-greeter allow-guest=false
/etc/xdg/lxsession/LXDE/autostart and replace it with:
@xset -dpms @xset s off @midori -e Fullscreen -a http://example.com/dashboard
Issue reboot (
shutdown -r now). System should boot-up directly to browser / dashboard.
Pros / Cons (Op1)
- Relatively quick configuration
- Only minor adjustment of system and/or pre-build image is necessary.
- Size -> full LXDE installation
- No automatic restart capability in case of browser failure
Option 2 -> Browser started using init
Required packages (Op2)
Following packages are required:
apt-get install midori unclutter x11-xserver-utils xinit lwm
Note: unclutter will make sure that mouse pointed is hidden while input is idle.
Default security may be too strict to start X11 server from user account. Therefore it is necessary to tweak it a bit. Execute following command and select "
Anybody" from menu:
It is possible to do same by editing
/etc/X11/Xwrapper.config but is not recommended.
This idea use one specific script that handle startup of dashboard. Create
/usr/local/bin/dashboard-start.sh with following content:
#!/bin/bash exec >> /var/log/dashboard.log 2>&1 echo LANG=C date echo echo Cleaning homedir ... find /home/dashboard/ -mindepth 1 -ls -delete echo echo Creating startup file ... ( echo 'xset -dpms' echo 'xset s off' echo 'lwm &' echo 'unclutter &' echo 'exec midori -e Fullscreen -a http://example.com/dashboard' ) > /home/dashboard/.xinitrc cat /home/dashboard/.xinitrc echo echo Starting X11 session ... su - dashboard -c "startx -- tty7 -s 0 dpms" echo echo Waiting before restart ... for a in 60 50 40 30 20 10 00 do echo -n "$a " sleep 10 done echo echo echo Forcing termination of script ... exec sleep 1 # EOF
Recent version of Rasbian use systemd. Therefore we need systemd startup configuration. Create
/etc/systemd/system/dashboard.service with content:
[Unit] Description=RPi dashboard After=getty.target [Service] ExecStart=/usr/local/bin/dashboard-start.sh Restart=always [Install] WantedBy=multi-user.target
Enable execution. Reload configuration. Start service:
chmod +x /usr/local/bin/dashboard-start.sh systemctl daemon-reload systemctl enable dashboard.service systemctl start dashboard.service
Pros / Cons (Op2)
- Automatic restart in case of browser / X11 failure.
- Size -> only essential packages are installed.
- Logging of startup events.
- Configuration may look more complicated.
Synthetic F5 (reload)
I see two reasons why it is good to "hit" F5 on keyboard (at least from time to time). To get latest version of dashboard page and also to clean memory / cache of browser. It is good that this can be accomplished without connecting keyboard. Just install following packages:
apt-get install cron xdotool
Edit corntab using
crontab -e and add following line:
0 * * * * su - dashboard -c "DISPLAY=:0 xdotool key F5" > /dev/null 2>&1
Correct way should be to find browser window and send "F5" only to it. Unfortunately web page can change tile of page / window which break things a bit ..."
This will ensure that page is refreshed each hour.
This dashboard can be easily reinstalled in case of some serious failure. Backup is not necessary but it is handy to have at least snapshots. I recommend btrbk tool. Please note that this tool require system in subvolume.
Tool is not in repository but can be downloaded from gitbub:
cd /root/ git clone https://github.com/digint/btrbk
Tool itself is one file. Copy it to sbin directory:
cp -p btrbk/btrbk /usr/local/sbin/
It need directory for configuration file and snapshots:
mkdir -p /etc/btrbk mkdir -p /btrfs/_snapshot/system
Configuration is located in
/etc/btrbk/btrbk.conf. Here is my configuration file:
# Global configuration transaction_log /var/log/btrbk.log timestamp_format long-iso snapshot_create always preserve_day_of_week monday snapshot_preserve_min 6h snapshot_preserve 16h 14d 4w 3m # Volume configuration volume /btrfs subvolume system snapshot_dir _snapshot/system # EOF
Btrbk create snapshot each time it is invoked with "run" option. Therefore it needs to be scheduled via cron. Invoke cron editor via
crontab -e and add following line:
0 * * * * /usr/local/sbin/btrbk run >> /var/log/btrbk_cron.log 2>&1
Dashboard source possibilities
First of all just try to google it. There are lot of different possibilities and range of product may quickly change after I publish this wiki article.
I am currently testing solution provided by geckoboard (2016-05). I think this is most advanced dashboard solution.
Previously I tested thedash. I think it is good as start but it lack custom widgets.
I will mostly probably do at least some testing of following dashboard product in future:
Ignore CEC init message
When Raspberry Pi get HDMI CEC Init message then it normally respond with source active reply. This may cause channel switch to HDMI port and/or wake-up TV from standby if RPi is rebooted. It is possible to configure RPi to ignore this kind of message. Just edit
/boot/config.txt and insert following line to enable this configuration:
Reboot of RPi is required to enable this configuration
If TV or RPi is still reacting to some of CEC messages then it is possible to disable it completely. This will make sure that CEC messages are not interpreted by RPi and TV think that there is only "dumb" HDMI video source.
/boot/config.txt and add following line to completely disable CEC: