TechClicker Clinic: A Functional Raspberry Pi Digital Photo Frame

We’ve written about digital photo frames in the past. While the concept of a digital photo frame is fantastic in this era of ubiquitous personal digital photography, the implementation of these devices by consumer electronics companies has failed to create a market with mass appeal for consumers. The best digital photo frames remain the creations of hobbyists, and even in that realm complications and misinformation can lead even the technically proficient astray.

We’re going to provide a functional and relatively inexpensive way to create a digital photo frame using a Raspberry Pi computer. The Raspberry Pi is an small bare-bones computer that runs a version of the Linux operating system. For those unfamiliar with Linux, use of the Raspberry Pi and its native command line interface could be daunting, but our step-by-step instructions will guide readers through the process of setting up and configuring the Raspberry Pi and its software. Items needed to build this Raspberry Pi digital photo frame include the following (substitutions are acceptable, but the items listed were used when we built our Raspberry Pi digital photo frame):

The Raspberry Pi based digital photo frame described below operates as a wirelessly networked device on the users home network. No photos are stored locally on the the Raspberry Pi digital photo frame. Rather, photos displayed via continuous slideshow on the frame are read from a shared storage location on the users network, such as another computer or NAS device. Having photos stored remotely allows the user to easily update the content of the Raspberry Pi digital photo frame without having to manually handle it once its installed. By simply changing the photos stored in the shared network directory, the digital photo frame contents are updated when the frame is rebooted.

This guide describes the steps required to setup a networked Raspberry Pi digital photo frame. Upon completion, the user will have a system that boots automatically into a slideshow of photos. Packaging the electronics into a presentable frame is left to the creativity of the builder. Enjoy!

Step 1: Prepare the SD Card for use in the Raspberry Pi Digital Photo Frame

It’s important to start with a freshly formatted SD card. Using an SD card reader attached to a PC, it’s easy to format an SD card. There’s a free program called SD Formatter (available here) that detects an SD card and formats it.

After formatting the SD card, download the most recent version of the Debian Linux based Raspberry Pi “Raspbian” operating system (available here) from the official Raspberry Pi website. This site and its moderated forums are an incredible resource for anyone, including beginners, working with a Raspberry Pi.

Under the heading “Raw Images”, download the latest release of the Wheezy Raspbian OS (the filename format is XXXX-XX-XX-wheezy-raspbian.zip). This file is nearly 2GB and will take several minutes to download.

You’ll need software to flash the Raspbian disk image to the SD card. One freely available possibility is Win32 Disk Imager (available here).

After installing Win32 Disk Imager and completing the Raspbian OS image download, you can unzip the Raspbian image file and direct the Win32 Disk Imager software to its path. With the SD card still in the card reader and attached to the PC, make sure it is properly selected as the device. Click the “Write” button and the Raspbian OS image will be written to the SD card. Upon completion, insert the SD card into the appropriate slot on the Raspberry Pi.

The Raspbian OS is pre-configured and ready to boot when installed within the Raspberry Pi.

Step 2: Make Initial Connections to the Raspberry Pi

Before powering up the Raspberry Pi, make all the necessary connections of cables and devices for its proper operation. Install the Edimax EW-7811Un 150Mbps Wireless USB Adapter into one of the two USB ports. Insert the SD card into its slot. Connect the Raspberry Pi to a router via an Ethernet cable (this connection is temporary and only for initial setup). Connect the Raspberry Pi to the HDMI to VGA Converter via an HDMI cable. Connect the LCD monitor to the HDMI to VGA converter via a VGA cable. Connect a micro USB cable to the Raspberry Pi. At this point, power can be applied to both the HDMI to VGA converter and the Raspberry Pi. The Raspberry Pi should begin to boot and display information on the monitor.

We’ve had success with the devices listed, but substitutions may be used. Be aware that non-powered HDMI to VGA converters and poor quality 5V USB power supplies proved troublesome in our initial Raspberry Pi digital photo frame prototypes. For some VGA to HDMI converters, it may be necessary to edit the config.txt file on the SD card (located at /boot/config.txt) to manually set the resolution of the monitor and force HDMI mode. This is done by un-commenting the hdmi_drive, hdmi_group, and hdmi_mode parameters accordingly for your specific application.

Step 3: Get an IP address for the Raspberry Pi and Connect via SSH

After power is applied to the Raspberry Pi via the micro USB cable, it will boot automatically into a default state that includes SSH support. Although the boot process can be seen on the monitor, since neither a keyboard nor mouse are connected to the Raspberry Pi, the only way to interface with it is via an SSH connection. This requires an SSH client, such as the freely available Putty client. Download it and run it on the host PC.

The only piece of information required to establish a connection via SSH with the Raspberry Pi is its IP address. The can be obtained directly from the router it is connected to, or via other networking software. There’s free apps for both iOS and Android that will poll a local network for the IP addresses of the devices connected to it. Obtain the Raspberry Pi’s IP address on the network, and enter it into the Host Name field in the Putty SSH client. The port number is 22 if it’s not there by default.

Step 4: Log into and Configure the Raspberry Pi

When connecting to the Raspberry Pi via an SSH client, a login prompt is presented. The default username is “pi” and the default password is “raspberry”. Enter these to gain access to the command prompt. A Linux command prompt can be daunting for those unfamiliar with it, so we’ll provide the exact commands you’ll need to enter to configure the Raspberry Pi digital photo frame.

First, you’ll want to configure some basic aspects of the Raspberry Pi. There’s a configuration menu built in that can be accessed by typing

sudo raspi-config

at the command prompt. Within this menu, select “Expand root partition to fill SD card”. If the SD card onto which the Raspbian OS image file was written is larger than then the 2GB OS image file, this menu selection will automatically expand the usable partition on the SD card to be as large as the actual SD card in use. So if you’re using an 8GB card, all 8GB will be available after initiating this command.

Next select the “Start desktop on boot” menu item, and enable it. This will force the Raspberry Pi to boot into a desktop GUI environment rather than a command prompt similar to the one presented by the SSH client. It’s from this GUI desktop environment that we’ll be launching the slideshow software that will present our images.

Finally, if there are any geographic specific settings such as timezone information, those can be established from this configuration menu. After this initial configuration is complete, select “Finish” to save the settings and return to the command prompt. Reboot the Raspberry Pi by typing

sudo reboot

Step 5: Establish the Raspberry Pi’s Wireless Network Connection

When the Raspberry Pi is finished booting, connect to it again via SSH (see step 4). At the command prompt, type

sudo nano /etc/network/interfaces

The contents of this file should look like the following, where SSID and PASSWORD are replaced by the actual SSID and WPA key for the network into which the Raspberry Pi digital photo frame is being installed. The quotes surrounding the SSID and PASSWORD must be included in the file.

auto lo

iface lo inet loopback

iface eth0 inet dhcp

auto wlan0

allow-hotplug wlan0

iface wlan0 inet dhcp

wpa-ssid "SSID"

wpa-psk "PASSWORD"

To exit the text editor and save the contents of the file, press <CTRL-X> and <S>. At the command prompt, shutdown the Raspberry Pi by typing

sudo shutdown -h now

Remove the Ethernet cable from the Raspberry Pi. Restart the Raspberry Pi by unplugging the micro USB power cable and re-inserting it into the Raspberry Pi. Confirm that the network’s wireless router has given the Raspberry Pi an IP address using the methods and tools described in step 3. If the IP address is different than that used for the wired connection, update the IP address in the SSH client.

A dropped wireless connection can disconnect the Raspberry Pi from the network, making it unreachable via SSH. To make the wireless connection persistent in the event of a brief network outage, we can add and execute a script that checks the wireless connection at short time intervals to confirm its health. Begin by creating a file for the script by typing

sudo nano networkmonitor.sh

from the home directory of the Raspberry Pi. Type the following into the file, referenced from here.

Hit <Ctrl-X> and <S> to save the file. Next, make the file executable by typing

sudo chmod +x networkmonitor.sh

at the command prompt. Add this script to the /etc/rc.local file so that it auto-starts each time the Raspberry Pi boots.

sudo nano /etc/rc.local

Insert

/home/pi/networkmonitor.sh &

towards the end of the file. Exit and save the rc.local file. You can test the network persistence by monitoring the devices connected to the network before and after unplugging the router. If all is functioning properly, the Raspberry Pi should reconnect to the network and obtain an IP address automatically.

Step 6: Mount the Shared Network Folder Containing Photos

Log into the wirelessly connected Raspberry Pi via the SSH client. The next step involves installing some software onto the Raspberry Pi. Linux uses online repositories from which different programs can be installed – sort of like app stores. The first thing to do is update the repository list by typing

sudo apt-get update

at the command prompt. The Raspberry Pi doesn’t include an SMB network sharing client by default, so one needs to be installed by typing

sudo apt-get install smbclient

at the command prompt. This installs the SMB client software. After the installation process is complete, a local directory to which the shared network location is mapped needs to be created. Type

mkdir /home/pi/pics

to create a local directory. Now we’re ready to use the installed SMB client to automatically map this location to a network folder containing the photos for the Raspberry Pi digital photo frame. Type

sudo nano /etc/rc.local

to bring up a text editor. The “rc.local” file is sort of like the “autoexec.bat” used for old MS DOS PC’s. Enter the following text on the line prior to the line containing “exit 0”, where NAME and PASSWORD are the login credentials for the shared network folder. Additionally, the IP address and path of the network share is required.

Save the “rc.local” file and reboot the Raspberry Pi. After the Raspberry Pi reboots, log into it via the SSH client and confirm that the network share location has been mounted by typing

cd /home/pi/pics

ls

The “cd” command changes the active local directory, and the “ls” command lists the files in that directory. If the network share has mounted properly, a list of all the photo file names stored on the network share should display in the SSH client.

UPDATE: In some Raspberry Pi digital photo frame builds, there have been reports of the network file location not mounting when the Raspberry Pi boots up. While this method as described does often work properly, an alternative method is listed below. If the alternative method is used, follow all the previous steps in section 6 except for adding the mount command to the /etc/rc.local file.

Type <CTRL-X> and <S> to save the file. You can either reboot the Rasbperry Pi or type “mount -a” to test whether mounting the shared location was successful.

UPDATE: Several readers have inquired about an alternative setup for the digital picture frame that doesn’t retrieve pictures from a network share and instead reads pictures from a USB thumb drive connected to the Raspberry Pi. If this use case is desired, simply add the following command to the fstab file in a similar fashion to that listed above.

/dev/sda1 /home/pi/pics vfat rw,defaults 0 0

Make sure your USB thumb drive is FAT formatted. The USB drive can be mounted to any desired path, just make sure that the contents of the slideshow.sh script developed below reflect the path of the files you want your picture frame to display. NTFS and EXT formatting methods can be used, but the fstab entry above will need to reflect this. Next, type the following at the command line.

sudo nano /etc/modprobe.d/raspi-blacklist.conf

Type the following into the contents of this file so that the Raspberry Pi doesn’t try to load the USB drive as a CD-ROM.

blacklist sr_mod

Save the contents of this file. Now remove the USB wireless network adapter and reboot the Raspberry Pi. The USB drive should automatically be mounted upon bootup.

Step 7: Disable Any Screen savers or Power Saving Features

Unless the power saving settings are modified, the LCD screen will go blank after approximately 10 minutes on the Raspberry Pi digital photo frame. To correct this, type

sudo nano /etc/kbd/config

and search for the line containing “blank_time=” and set the “blank_time” parameter equal to 0. Search for the line containing “powerdown_time=” and set the “powerdown_time” parameter equal to 0. Make sure these lines don’t have an “#” in front of them, indicating that they are comments. If there is an “#”, remove it so the parameters set are active. Save the changes to the file and exit to return to the command prompt.

Next, type

sudo nano /etc/lightdm/lightdm.conf

In this file, search for the “[Seat Default]” heading. Add the following line under this heading.

xserver-command=X -s 0 dpms

Save the contents of this file and exit to return to the command prompt.

to install the QIV image viewer. This is the program that displays the photos as a slideshow. To automatically start the slideshow, a simple script must be written that is run each time the Raspberry Pi boots. From the command prompt, type

cd ~/.config

mkdir autostart

cd autostart

sudo nano slideshow.desktop

This last command opens the familiar text editor to a blank file. Enter the following content into the “slideshow.desktop” file and save the file when exiting the text editor.

[Desktop Entry]

Type=Application

Exec=/home/pi/slideshow.sh

Next we’ll create the “slideshow.sh” script that this autostart file references. At the command prompt, type

cd /home/pi

sudo nano slideshow.sh

Enter the following content into the “slideshow.sh” file and save the file when exiting the text editor.

#!/bin/bash

#slideshow script

sleep 15

export DISPLAY=:0.0

qiv -f -R -s -r -d 180 -t -i -m /home/pi/pics/*.[jJ][pP][gG]

It is important to note that the *.jpg extension is case sensitive, thus the bracketed expression in the wildcard statement above allows either capital or lowercase file extensions.

In the last line of the “slideshow.sh” file, the 180 is the time in seconds that each picture will be displayed. This can be any number to suit this Raspberry Pi digital photo frame builder’s preference. Notice that the path referenced in the last line of the “slideshow.sh” file is the local path that we earlier mapped to the shared network location in which the photos are stored.

After saving and exiting the “slideshow.sh” file, type the following at the command prompt to make this script executable.

sudo chmod +x /home/pi/slideshow.sh

This will give the file the necessary permissions so that it can be run automatically when the Raspberry Pi boots.

Step 9: Protect the SD Card from Corruption

Raspberry Pi SD cards are notorious for becoming corrupted from unplanned power failures and write errors, thus requiring re-installation of the operating system and software. To help combat this, we can limit and actually disable how the filesystem swaps information to and from memory. To do this, edit the file systems table by typing

sudo nano /etc/fstab

at the command prompt. Change the default contents of this file to that listed below.

Reboot the Raspberry Pi. At this point it is a good idea to use the same Win32DiskImager flashing utility from Step 1 to create an image of the SD card you’ve setup for your Raspberry Pi Digital Photo Frame. Simply insert the card into a card reader, select the device drive letter of the SD card, and choose “Read” to copy an image of the SD card onto your computer’s hard drive. Now, in the event of an SD card failure or system corruption, the backup image can be loaded onto a spare SD card and installed into the Raspberry Pi, without the need for the lengthy setup process detailed in these instructions.

Conclusion

At this point, an automated slideshow of image files stored remotely on the network is displayed when the Raspberry Pi boots. If the collection of photos needs to be changed, simply update the contents of the directory in which the photos are stored and reboot the Raspberry Pi digital photo frame.

Post navigation

Hi – great guide, best I’ve found. Just need to query why we need to boot into “start desktop on bootup”? Being that QIV is not reliant upon the GUI, and we’re not launching the slideshow from the GUI… it has confused me. Can we not leave that bit out?

I’ll have to double check this. Originally, prior to posting this guide, I was implementing the “FEH” image viewer, but had trouble getting it working with a network share on a 64-bit machine, and I believe that FEH needed the GUI. I may have just kept this step in when I switched to the QIV viewer which seems more stable across the network.

But certainly if it works on your system without invoking the GUI, you can omit that step and everything else should be the same. Let us know how it goes!

I’ve checked and double checked for errors on the bash script and see none. The samba share auto mounts on boot but the slide show does not start. How would I use crontab to start that bash slideshow.sh. Would this be a good work around?

Can you clarify what you mean? I did not startx, is this dependent on startx?im using hdmi for output. I get boot sequence but never starts slideshow. thanks for your tutorial and your time answering our questions.

The script as described in the article is run after the GUI starts (the GUI desktop autostarts via an option in the raspi-config menu) and uses the autostart folder created to run the command script, so you have to load the GUI for the script to run.

This totally solves my issue then. I was running from command line. Ok so raspi-config and find outo start GUI. Got it. Thanks again for all your time showing me the way and answering my questions. Do you have more tutorials on rpi projects? I’ll just have a look around. Thanks!

It apparently plays both pictures and movies and is free. It is a stand alone image that is flashed to the RPi SD card. It may be more polished than this tutorial, but again, I haven’t had a chance to try it yet.

I realize this is a year old, and i apologize, i’m running into a bit of an issue and I was hoping someone may have some insight. I’m running pretty much this exact set-up using a network share on our domain and everything is working as advertised. The issue is I was wanting to force qiv to recheck the network share to look for new images. I have my share being mounted through cifs to /home/pi/pics in fstab, and if i navigate on the pi itself to the directory it does see the new images however qiv does not display them. (if i remove them qiv sees that and can not display them.) I’ve created a cron job ‘qiv restart’ and have it running every minute for testing purposes. It doesn’t work. I’m trying to avoid having to do a reboot in order for qiv to see the new images. any help would be greatly appreciated.