DANIEL SLEETH

PERSONAL SITE

Raspberry Pi Digital Signage

This is a work in progress. Do not undertake the instructions on this page.

What you need

  • 1 Raspberry Pi to store content to be played – called “assetserver” in this tutorial
  • 1 Raspberry Pi for each signage display – called “player” in this tutorial
  • SD card for each machine with Raspberry Pi OS (or similar)
  • Power adapters, HDMI cables and anything else to use the Pis

Before we begin, I am going to assume you have all of your Raspberry Pis plugged in, turned on (running Raspberry Pi OS) and connected to your network and monitor.

Remote Access

We first need to enable SSH on all of our Raspberry Pis. SSH allows you to connect to remote Pis and run commands via Terminal. We can enable SSH via Terminal with this command (followed by enter):

sudo raspi-config

Look for the Interface menu and enable SSH. Do this on every machine. Note that the default password on all Raspberry Pis is raspberry and for the sake of this tutorial, we will keep it as that.

While in the configuration tool, we should change the Hostname for each Pi. The hostname is the name each Pi presents itself with on the network. Giving them unique names makes life easier when sending commands in Terminal. I will call one “assetserver” and then the rest I will name based on their location in the building e.g. “windowdisplay”.

Finish the configuration tool and reboot if it asks you to.

Now we need to note the IP address of each Raspberry Pi. On each machine, type the following command in Terminal to see information about its network adapters:

ifconfig

If your Pi is connected via ethernet, you are looking for inet under the eth0 section. If you are connected via WiFi, you are looking for inet under the wi0 section. The IP address will look something like 192.168.0.2 or 10.20.18.2 depending on the router they are connecting to. Ignore the lo inet (loopback) address.

To test your remote access, open Terminal and type ssh followed by the IP address of one of the other Pis. For example, if I am on a Pi with the IP address 192.168.0.2, I could type:

ssh 192.168.0.3

When asked to type a password, type:

raspberry

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

pi@asset:~ $
pi@shopwindow:~ $

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 one Pi to another. In this case, we will copy images and video files from our “assets” Pi to one of our “Player” Pis. Before we begin, you need to copy some files onto your assets Pi. A USB stick might be easiest method to achieve this. In Terminal on one of your Player Pis, type:

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

In the example above we are using rsync with three arguments (-azr) archive mode, compress for transfer and recursive. After the arguments, you specify the location of the files (in our case on the remote “assets” Pi) and which user on that machine we want to login as (pi).

After the IP address of the assets Pi, we use : and then specify the file’s location (Pictures directory). We then use a space and type the destination (where we want those files to be copied to). In this case we are saving them in the local machine’s Pictures folder.

The final two parts tell rsync that we want to see the progress of this command in real-time and to delete any content on our current machine if it is no longer on the source. This is particularly useful for ensuring old content is removed. You can just keep the asset Pi up-to-date.

To see this work, you will need to put some files (images or video) into the Pictures folder on your fileserver. After running that command, those files should be in your local Pictures folder too.

Considerations: If you are running multiple players and want different content on each, you could create several directories on the assets Pi, each directory containing content for specific Pis. You would simply change the path in the rsync script for each Pi, so it only copies content intended for itself. You could even add another shared directory and include a second script to also copy content out of the shared folder. This would allow you to give certain content to all machines and specific content for others.

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 /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 /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.

Create a share

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