Following up to the moderate success of this implementation on a BeagleBone (details and link to follow), I’m giving a Raspberry Pi a try as an alternative. The main benefits for my application are the higher-resolution HDMI support (1080p at 60 Hz) and multiple cores (hopefully to improve Chromium performance with Chronograf). I also understand that hardware graphics acceleration may be available – it remains to be seen if or how much this helps.
I’m using a spare Raspberry Pi 3 Model B V1.2 I happened to have on-hand in the lab.
Write the Image
Obtain the latest release of the Raspberry Pi OS. I’m using the “Lite” version to keep the installation as small as possible.
I’m using a Samsung 32GB PRO Endurance micro SD card. While I haven’t seen a definite answer as to whether these will hold up long-term as a system disk, it appears to be one of the best options (short of going to a full-fledged SSD). I haven’t gotten a clear answer as to whether this device supports wear leveling. Regardless, efforts will be made in the OS and application configuration to minimize writes.
My only PC with a built-in SD card reader happens to run Windows 10, so I’ve opted to use Rufus to write the image to the SD card. This utility has almost always served me well; Win32 Disk Imager is good alternative option.
First Boot
Upon first boot, I encountered intermittent flashing of the lightning bolt icon in the upper left. This was remedied by swapping out a 1 A plug-in USB source for a model capable of supplying 3 A.
Without SSH enabled by default – a keyboard is required.
At least as of this release, the default username and password is “pi” and “raspberry”, respectively.
First, a little housekeeping. Set up the root password:
sudo passwd
Then, add a new user (follow the prompts). Add the user to the sudo group:
adduser newuser
usermod -aG sudo newuser
Log out, then log back in as the new user. Delete the default user:
sudo userdel pi
Finally, enable and start the SSH daemon:
sudo systemctl enable ssh
sudo systemctl start ssh
With luck, the keyboard can be put away at this point and all further configuration can be done via SSH. Once logged back in, update the package list and upgrade the system. Depending upon how recent the installed release is, there may not be much to update at this point (especially if using the “Lite” version).
sudo apt-get update
sudo apt-get upgrade
Next, set the host name (where myhost
is the desired name):
echo [myhost] > /etc/hostname
Then, update /etc/hosts accordingly.
InfluxDB TICK Stack Installation
For the dashboard, I plan to use the full InfluxDB TICK stack – which means I need to install the influxdb, telegraf, chronograf and kapacitor packages. Only influxdb appears to be available in the Raspberry Pi OS standard repository – and it’s not current.
From here, I’ll follow the official guide for installation from the InfluxData website.
Add the InfluxData GPG key:
curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
Our release of Raspberry Pi OS is actually based on Debian Buster (10.7), not Stretch, so I’ve changed the command to add the repo accordingly:
echo "deb https://repos.influxdata.com/debian buster stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
Update the package lists again:
sudo apt-get update
Then, install the TICK stack:
sudo apt-get install influxdb chronograf telegraf kapacitor
Manual Update for Chronograf
I later discovered that the version of Chronograph installed via the Debian stable repo (1.8.5.1) was lacking a fix I needed in 1.8.9.1. Gauges, when lacking data, would periodically flash upon refresh. This is the first item listed under Bug Fixes for the new release.
The latest package is available here. It’s listed for Ubuntu, but I had no issue upgrading (using dpkg -i
) on my system. From what I understand, this practice has the potential to cause issues due to library differences between Ubuntu and Debian. It’s generally not recommended. In this case, it seems to have worked OK.
Kiosk/Dashboard Environment Installation
A fundamental reason I’ve decided to go with the Raspberry Pi over the BeagleBone Black is for its superior capability with respect to running a web browser, especially at HD resolution.
So, next up is the installation of a lightweight display manager (lightdm), window manager (openbox) and web browser (Chromium). The display server (Xorg) is installed as a dependency.
There is a lot of room for alternatives here – but this combination seems to work well:
sudo apt-get install lightdm openbox chromium
Next, it’s time to set up a kiosk (or my case, a “dashboard”) user. Credit to a post on Will Haley’s Blog for the bulk of the configuration between here and a reboot. Create a new user:
sudo useradd -m dashboard-user
Edit /etc/lightdm/lightdm.conf to contain only the following:
[SeatDefaults]
autologin-user=dashboard-user
user-session=openbox
Before a reboot, create the the openbox configuration for dashboard-user:
sudo mkdir -p /home/dashboard-user/.config/openbox
Create an auto-start script. Edit /home/dashboard-user/.config/openbox/autostart to contain the following (we’ll change the URL later). Two X preferences have been added to Will’s configuration to disable DPMS (Energy Star) features and the screensaver – the dashboard should be visible at all times. Use sudo nano:
# Disable DPMS (Energy Star) features.
xset -dpms
# Disable the screensaver.
xset s off
# Start Chromium.
chromium \
--no-first-run \
--disable \
--disable-translate \
--disable-infobars \
--disable-suggestions-service \
--disable-save-password-bubble \
--start-maximized \
--kiosk "http://www.google.com" &
Finally, fix ownership:
sudo chown -R dashboard-user:dashboard-user /home/dashboard-user
Reboot and confirm that Chromium is shown.
Install and Configure Socat
This step is optional. It may be desirable if remote monitoring of serial devices is required in your application – see my WiFi Serial Ports post for background and configuration. For this project, serial devices are accessed via Node-RED (see below) and via the Modbus module in Telegraf.
If socat is needed, install the package as follows:
sudo apt-get install socat
The instructions in the aforementioned post can be followed now, or later (during the rest of the configuration).
Install Node-RED
This step is optional – though perhaps quite useful for a dashboard. Node-RED is “a programming tool for wiring together hardware devices”. In my case, it’s used to interact with a serial device, parse the results (using regular expressions) and insert the results into the database.
The steps below follow the installation procedure on the Node-RED website.
Install the prerequisites:
sudo apt install build-essential git
Then, run the installation script:
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
On my board, this process took about 5 minutes.
Enable and start the Node-RED service:
sudo systemctl enable nodered.service
sudo systemctl start nodered.service
Verify that Node-RED is working by navigating to the IP of the Raspberry Pi, port 1880 via a web browser. If this is a re-installation, at this point the node configuration may be imported via the menu.