Michael Lohr
Michi's Blog

Michi's Blog

Digital Signage Using a Raspberry Pi (Automated Setup)

Michael Lohr's photo
Michael Lohr
·Apr 10, 2020·

3 min read

Digital Signage Using a Raspberry Pi (Automated Setup)

Subscribe to my newsletter and never miss my upcoming articles

Introduction

I was asked to develop a system for digital signage based on a Raspberry Pi 4, displaying upcoming events of a club based in Munich.

One requirement was to implement an automated setup pipeline so that it could be quickly deployed to new devices.

After a bit of research, I found DietPi, which is a lightweight OS based on Debian. DietPi is configured using a config file. In there, system settings can be configured. DietPi will then set up your system on the first run using those settings. It is also possible to automatically launch a Chromium instance on a specific URL after starting up.

Our digital sign is implemented using Vue.js and a simple Bootstrap slider that cycles through images. It is served on a publicly accessible URL.

Digital Signage

Configuration

You can adjust the standard Raspberry Pi config file to your needs. In most cases, you want to disable the overscan using disable_overscan=1 and disable the splash screen with disable_splash=1. If you are using a Raspberry Pi 4, you also want to switch to the new graphics driver by setting dtoverlay=vc4-fkms-v3d.

You can create a dietpi-wifi.txt file to specify a WiFi network, the Pi should automatically connect to:

The most important configuration is done in the dietpi.txt. Here you want to define a static IP, set an SSH server to launch for maintenance, and set the Pi to wait for a network with CONFIG_BOOT_WAIT_FOR_NETWORK=2. To enable the automatic setup, define AUTO_SETUP_AUTOMATED=1, AUTO_SETUP_AUTOSTART_LOGIN_USER=root and AUTO_SETUP_INSTALL_SOFTWARE_ID=113 (the 113 instructs DietPi to install chromium, see here). Chromium will be automatically launched in kiosk mode by setting AUTO_SETUP_AUTOSTART_TARGET_INDEX=11.

Then configure Chromium. E.g.:

Custom Automation Script

You can also define a script that runs once at the setup. This is useful if you want to pass custom arguments to the chromium executable and handle other logic automatically turning off the display during nighttime.

To be able to use a custom script, set AUTO_SETUP_AUTOSTART_TARGET_INDEX=7 and AUTO_SETUP_CUSTOM_SCRIPT_EXEC=0.

Then create a new shell script called Automation_Custom_Script.sh. Add the following to that script to automatically run a script during startup:

These commands will also create the custom startup script, which will disable the screensaver and run Chromium on the URL specified in the dietpi.txt as before. The chromium arguments will launch Chromium in fullscreen app mode and block any messages from appearing.

Turn the Screen off During the Night

To turn the screen off during certain times, add and adjust the following to the Automation_Custom_Script.sh:

Install the Raspberry Pi

So let's set up the Raspberry Pi:

Prepare the SD card

  1. Download the DietPi image
  2. Unzip the image
  3. Insert SD card
  4. Use balenaEtcher to patch the image onto the SD card.
  5. A) Put the config.txt, dietpi.txt, dietpi-wifi.txt, and Automation_Custom_Script.sh in the root (/) folder on the SD card. You might want to modify dietpi-wifi.txt, to adjust the WiFi credentials.

Setup

  1. Safely eject the SD card and put it in the Raspberry Pi
  2. Plug all your cables into the Raspberry Pi (making sure the power cable is last).
  3. Let the setup run. You have to interact once and accept software terms by pressing enter. The website should open after the setup is finished.
 
Share this

Impressum