DANIEL SLEETH

PERSONAL SITE

Raspberry Pi Digital Signage

This guide will help you turn a Raspberry Pi into a simple slideshow player, perfect for digital signage in schools or small businesses. You can play images and videos on loop and update content remotely. There is not yet an ability to add tickers or webpages to the system, but I am sure with some additional software that would be perfectly feasible.

What you need per display

  • 1 Raspberry Pi (I recommend at least a Pi 3)
  • SD card with Raspberry Pi OS (or similar)
  • Power adapter, HDMI cable and an ethernet cable

Terminology Used

These are some terms I use that you might not be completely familiar with. To avoid any confusion, this is what I mean when I use them:

Machine – Any type of computer such as a PC, Mac or Raspberry Pi
Pi, RPi or Board – Interchangable terms for a Raspberry Pi computer
Local – The computer your are physically connected to via the keyboard and mouse
Remote – The computer your are virtually connected to
Path – A location or address within a computer’s file structure
Syntax – The structure or arrangement of words/letters in a command

Enable SSH for Remote Access

We need to enable SSH on all of our Raspberry Pis. SSH allows you to connect to a computer from another computer (a ‘remote’ connection) and run commands via Terminal. Open Terminal on each Pi and type the folowing to open the configuration tool:

sudo raspi-config

Look for the Interfacing Options and enable SSH. Do this on every machine.

Tip: The default password on Raspberry Pi OS is raspberry and for the sake of this tutorial, we will keep it as that. If you want to change it, do so within this configuration tool, but remember to substitute it each time I type raspberry in a command!

Change Hostname

While in the configuration tool, we can change the Hostname for each Pi. The hostname is the name a computer uses on a network to allow you to identify it easily. This should be unique from any other hostname on the network and should allow you to know which physical machine you are connected to. For example, if one of your computer’s was located in the kitchen, you could set it’s hostname as kitchen.

Press the right arrow key to highlight <Finish> and press return.

Note the IP Addresses

When joining a network, each computer is assigned an IP address by the switch or router controlling the network. This IP address is unique for each client (computer on that network) much like a telephone number.

Open Terminal on one of the Pis and type:

ifconfig

The IP address is a string of numbers that will trail the word inet. I am connected via ethernet (as opposed to WiFi) so I am looking for the inet value under the eth0: section.

eth0: inet 192.168.0.2 netmask 255.255.255.0. broadcast 192.168.0.1

Tip: You are not looking for the loopback address, which is in the same format as an IP address.

Open Terminal on another computer connected to the same network and type the command below in Terminal. Replace the IP address in the example, with the IP address you just noted down in teh previous step.

ssh pi@192.168.0.2

Tip: In the command above, we prefix the IP address with a username that exists on the remote machine. Raspberry Pi OS uses pi as the default username on every installation. If you do not specify a username, it will use the username you are logged in as on your local machine. If that username has not been created/recognised on the remote machine, it will reject your connection request when you type in the password.

When asked to type a password, I type the password for the user I am connecting as ( pi ):

raspberry

Accept any security warnings (usually by typing yes). When you have successfully connected, your Terminal prompt will change to the remote Pi’s Hostname. For example:

pi@localpi:~ $
pi@remotepi:~ $

Considerations: The router controlling your network dictates the IP address for each device connected to it. You may find that if you were to disconnect your Pi and then connect it again (for example, when you move it’s location) the router may assign a different IP address. If that were to happen, you would need to find out what the new address is by connecting a keyboard and mouse to the Pi or by going through your router’s menu. To avoid this, you should look into assigning ‘static IP addresses’ to each machine. A static address is a specific address that is assigned to a specific device, based on it’s hardware ID. Consult your router’s manual to find out how to do this.

rsync

The remote sync command allows us to copy files from a local computer (source) to a remote computer (destination) via Terminal. I am going to copy files from a Raspberry Pi to another Raspberry Pi in this example, but you could easily do this from a PC or Mac providing you know how to change the path in the command appropriately.

In the example below we are using rsync with three arguments (-azr). Archive mode (a) transfers files with all their attributes intact, Compress for Transfer (z) allows the transfer to take place quicker and Recursive (r) will copy any subdirectories within the directory you specify in the command.

rsync -azr pi@192.168.0.2:/home/pi/Pictures/ /home/pi/Pictures/ –progress –delete

After the arguments, you specify a username on the remote (destination) machine, followed by it’s IP address (just like we did with SSH). After the address you give it a :/destination/path/ to where you want the files saved to on that remote machine. Then a space followed by the /source/path/ where the files are currently located. The second path in the example is local (on the machine we are working on), which is why we do not specify a username or IP address. Ensure you have some images or video files in that location otherwise it will have nothing to copy!

After the specifying the destination and source of the files, we tell rsync that we want to see the –progress of this command happening in real-time and to –delete any content on the destination machine if it is no longer present at the source. This is particularly useful for ensuring old content is removed; you can just keep the source directory updated and know that old things will be removed when you remove it from the source.

After running the command, providing no errors were given in Terminal, the files in your source directory should now be in the destination directory.

Tip: If you are using a Mac, your path would look something like: daniel@10.20.10.1:/Users/daniel/Pictures/

Tip: To run unique content on each screen without having to adjust the Terminal command each time, create subfolders within your source directory e.g. /Pictures/screen1/ and /Pictures/screen2/ which will be copied to all of the machines when you rsync /Pictures/ recurrsivly. Then, simply adjust the VLC code below to only play content in the subfolder for that screen e.g. vlc /home/pi/Pictures/screen2/.

Setting Up VLC

Video LAN Client is a free (and awesome) media player available on all platforms and shipped with the full variant of Raspberry Pi OS. We will use this to play our media files on loop. Before we begin, we need to sutomise a few settings, which we can do via the GUI. On each Pi being used as a player, open up VLC from the Sound & Video menu and then open VLC’s Preferences. Go to the Video tab along the top and check Fullscreen. Now in the Subtitles menu, disable (uncheck) Enable OSD, Show media title and turn off Enable subtitles. This prevents any text being overlayed on our signage display.

Click on show ALL settings at the bottom of VLC Preferences and scroll down the the Playlist submenu and look for Ignored extensions. Remove jpg jpeg and png from that list; this will allow VLC to display images as well as video. In that same menu, check Repeat All to ensure VLC loops content forever.

I ran into a glitch where I had to save and reopen Preferences on each page, otherwise VLC would only remember the last page I changed settings on. Reopen Preferences and ensure your changes were saved!

Stick some images and video files into the Pictures folder of the player Pi you are working on. In Terminal, run the following command to ensure VLC plays all of those files on loop:

vlc –loop –fullscreen /home/pi/Pictures/*

Script It

At the moment we can ssh into each player individually to update their content and launch VLC. This is a little time consuming, so we will now create a script that will do all that for us.

On each of the players, open Terminal and type the following command to create a new script called vlc on the Desktop. Nano is the name of a text editor, so it will create the file and then open it for you to add text to:

sudo nano /home/pi/Desktop/vlc.sh

Add the following text to the file. The first bit is called a shebang and just tells the Pi what the file is (a bash script). Then each line under that is a command that we would type into Terminal. They will be executed when the previous command finishes:

#!/bin/bash
rsync -azr pi@192.168.0.2:/home/pi/Pictures/ /home/pi/Pictures/ –progress –delete
vlc –fullscreen –loop /home/pi/Pictures/

Close the file with Ctrl C and press y to confirm the save. In Terminal, we need to make that file executable:

sudo chmod +x /home/pi/Desktop/vlc.sh

We can now test the script with the Terminal command below. If all has gone well, the Pi will update it’s content with rsync and then start VLC up fullscreen on loop!

bash /home/pi/Desktop/vlc.sh

Considerations: Instead of using the vlc command, you could use cvlc, which is a compact interface version of the same thing.

Using the script as it is will be fine for running on reboots (which we cover in the next step), but if you want to be able to manually run the script, you may need to add a line to kill the currently running vlc process. If you do add that line, you can end the command with ” &&” which will tell the script to only run the next command if that command is completed successfully – so only run rsync to update content if vlc has been stopped first.

killall -9 vlc &&

LXDE Autostart

Now that we know the script does what we need it to when executed, we have to tell the Pi to start that script on boot. This allows us to plug the Pi in and let it do it’s thing. We need this to start after the GUI, so we will add it to the autostart file located here:

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

Add a line telling the Pi to execute our script:

## [already in the file] @xscreensaver -no-splash
bash /home/pi/Desktop/vlc.sh

Hopefully, we can reboot the Pi and the script will cause VLC to open almost immediately and play content fullscreen. You can reboot via Terminal witht he following command:

sudo reboot

Troubleshooting

There are several issues you might run in to. Here are some of the most obvious to me.

  • Proxy Settings

If you are using this within a school or business, the network you connect to may use a proxy server. A proxy server is basically a computer that your network traffic has to go through before it reaches its destination. That proxy server will likely require a username and password (typically the credentials you use to sign in to a computer). The actual address of the proxy server will need to be given to you by your IT guy. Without it, when you try to update your Raspberry Pi, you will get errors along the lines of ‘cannot connect to…’.

Run the command below and look for the proxy submenu within the Networking menu:

sudo raspi-config

You may also need to ensure you RPi has the same time and date as other computers on the network, otherwise the server may reject your connection attempt.

  • Closing VNC closes VLC

If you run the VLC command through a VNC connection and then you terminate your VNC connection, you may find VLC will stop running fullscreen and may allow the screensaver to come on. To avoid this, try running the commands via SSH.

Things you might find useful

These are commands or processes you might find useful in order to further customise your setup.

  • Create a shared folder on the network

In this step we are going to use one of the boards as the ‘share’ all other boards get their media from. This particular board will not run a screen (although there is no reason why it couldn’t), it simply hosts videos and images that the other baords will copy. This board needs to be accessible from a machine you can send media from. Run commands by opening the Terminal app on your Pi.

sudo apt-get update && sudo apt-get upgrade

sudo apt-get install samba

Those three commands update your Raspberry Pi and then installs SAMBA (SMB), which allows your board to share a folder with Windows and OSX machines.

We now need to make a folder (directory) that will host your media assets. I am going to call mine “signage” and give full read and write access (which is the 1777 bit).

sudo mkdir -m 1777 /signage

We now need to add some information into the configuration file for samba. Open the file using a text editor (I use nano in the example below):

sudo nano /etc/samba/smb.conf

Now add the following text to the bottom of that file. When you are finished, hold Ctrl and press x then y to confirm. You can leave out the last line if you do not want guest accounts to access the share. Also note 0777 rather than 1777 in the command above.

[share]
comment = Pi shared folder
path = /signage
browsable = yes
writable = yes
only guest = no
create mask = 0777
directory mask = 0777
public = yes
guest ok = yes

We should now add a user that can access that share. I will use the username pi which is the default user when you log into your Raspberry Pi. When you press enter after the command below, you will be asked to type a password and then confirm the password. I will use the password DIGSIG in this example:

sudo smbpasswd -a pi

We now need to restart the service:

sudo /etc/init.d/samba restart

Next Post

© 2021 DANIEL SLEETH

Theme by Anders Norén