Raspberry Pi Digital Picture Frame
by wiredcav in Circuits > Raspberry Pi
6187 Views, 13 Favorites, 0 Comments
Raspberry Pi Digital Picture Frame
After 10 years, my store-bought digital picture frame failed. I looked for a replacement on-line, and found that a comparable replacement actually cost more than my 10 year old frame. I figured they'd be practically free by now. Obviously I could've just bought a new one, but I figured that's exactly what the man wants me to do! Instead, I could spend a ridiculous amount of time building my own - but also having some fun and learning something along the way. I've been playing with Arduinos for years, and have wanted a good project for the Raspberry Pi, and this seemed like the perfect one. So I did the normal Googling and found that there were a bunch of options for making a digital picture frame based on the Raspberry Pi. Unfortunately, most of them were really not quite what I wanted. In some cases you have to buy software that others wrote, and I kind of didn't want to do that. In the end I found this excellent instructable and based my project on it https://www.instructables.com/id/Easy-Raspberry-Pi...
I wanted a simple digital frame that would simply run through the images on a USB thumb drive. I don't want or need to control it from 1000 miles away, don't need to email it pictures, etc. I'll just put my pics on the thumb drive and it should display them. And that's basically what the above instructable offers - without any proprietary software etc.
I did however want a few minor things that aren't covered in that instructable. I wanted to configure it so the screen would not blank out after a set interval. I wanted a way to safely turn it on and off without a keyboard and mouse (just pulling the power on a Raspberry Pi can corrupt the operating system). With a disturbing amount of research I found out how to do it. It's actually quite easy - I just had to figure out why the various approaches weren't working for me. I also wanted it to autostart so that when it powers up it goes directly into the slideshow without any action from me (again - no keyboard and mouse). And finally, I wanted to be able to control it manually when desired. Basically I wanted to simply be able to step forward and back, and be able to pause on an image. I planned to use three buttons for that hooked up to the GPIO pins. Ultimately I ended up configuring a mouse to do those controls. So I ended up with a mouse after all, but it doesn't need one. Without the mouse it just does its own thing.
What You'll Need
A computer monitor with HDMI input. I got this excellent 21.5" display for $89.99 at Amazon... Acer SB220Q Full HD (1920 x 1080) IPS Ultra-Thin Zero Frame Monitor
Raspberry Pi 3 B+ ($38.30 at Amazon). You can also use the Raspberry Pi 3 B, but there are small differences.
A power supply and cable. Make sure and get one that puts out enough current and get a cable that can carry the current. It turns out that most USB cables are too skinny and give you a low voltage fault. I had one laying around, but you can get a good one from Amazon for $10.99: Raspberry Pi 3 Power Supply 5V 2.5A Micro USB AC Adapter Charger US Plug
An HDMI cable. I got two 6' HDMI cables for $2.49 on Ebay.
A case for the Raspberry Pi (optional - but kind of nice). I got the acrylic "TSV Raspberry Pi 3 Case" from Walmart for $5.04. There are lots of case options. This one worked for me, and had room to mount the startup and shutdown buttons, but acrylic is very brittle. I managed to break 3 of the 4 assembly tabs even trying to be pretty careful with it. I had some acrylic cement laying around, so it wasn't really an issue. But if you get an acrylic case you're probably going to want some acrylic cement or clear tape to hold it together. I would not count on the tabs.
A couple of small push buttons to mount on the case for startup and shutdown. Again, I had a couple lying around, but you can get a dozen of the ones shown above from Amazon for $7.99.
I also used three female pin connector terminals (as shown above) and 1 pin for wiring the buttons to the Raspberry Pi GPIO pins. You can get 200 of the female connectors from Ebay for $0.99 (search: 2.54mm Dupont Jumper Wire Cable Housing Female Pin Connector Terminal). I also used 1 pin to connect the startup button to the Raspberry Pi board (see above). You can get 40 of these from Ebay for $0.99 (search: 2.54mm Male PCB Single Row Straight Header Strip Connector for Arduino). This pin is optional. You can also solder the wire directly to the board.
USB keyboard and mouse. The keyboard is only needed for setup. If you want to be able to control the slideshow manually, you may want to leave the mouse plugged in. I had them lying around, but you can get them dirt cheap at Amazon, Ebay, Walmart...
Micro SD card; I got a 16GB card for $5.44 from Amazon: Kingston Canvas Select microSDHC Class 10
Thumb drive; I got a 32GB USB thumb drive from Amazon for $6.99: Kingston Digital DataTraveler SE9 32GB USB 2.0 Flash Drive
Wood to make a frame for the monitor (optional). I used a piece of 2" x 2" x 8' "white" wood that I got from Home Depot for under $2.00 (also sealer or primer for the wood and some semi gloss black spray paint).
Configuring the Raspberry Pi
Follow this link to download the zip file of "Raspbian Stretch with desktop and recommended software": https://www.raspberrypi.org/downloads/raspbian/
There are three different versions. Make sure you get the one I mention here.
Now follow this installation guide to flash the operating system image to your micro-SD card: https://www.raspberrypi.org/documentation/installa...
Etcher will flash the SD card directly from the .zip file, and no need to format the micro-SD card first.
Plug a USB mouse and USB keyboard into the Raspberry Pi's USB slots (any slot will do).
Plug the Raspberry Pi into the LCD monitor with the HDMI cable, and plug the power supply into the Raspberry Pi to boot it up. When it boots up it should walk you through a process to get the Raspberry Pi talking to your wifi, and will download any necessary updates.
With the Raspberry Pi now on-line and fully updated, it's time to download the display software. To do this you'll need to open an LXTerminal window (click on the icon that looks like a DOS prompt at the top of the desktop).
In the resulting console window enter this command to install the image display software:
sudo apt-get install feh
Next do the same to install the screensaver:
sudo apt-get install xscreensaver
Next we need to set it so the screensaver doesn't timeout and blank the screen...
- Click on "Menu" on the upper-left of the desktop
- Select "Preferences" and then "Screensaver"
- On the screensaver GUI, in the "Mode" drop-down menu, select "Disable Screen Saver"
Next we'll configure the mouse to manually control the slideshow. If you don't wish to have manual control of the slideshow you can skip this.
Create a file called "buttons" (with no extension) in "/home/pi/.config/feh" (you may have to make the "feh" folder).
You can do this from an LXTerminal window.
cd /home/pi/.config (this is Linux speak for "change directory to /home/pi/.config")
ls -la (this will list all files and folders in /home/pi/.config. The -la tells it to use long format and list all files).
If there is not an feh folder in the list (and there probably won't be) you'll need to make one:
mkdir feh
Now get into that folder:
cd feh
Now that we're in that folder, we have to make the "buttons" file.
sudo nano buttons (this is linux for "super user do nano-editor on the file buttons)
You should find yourself in an empty file. Put the following in the file:
# unbind existing controls for the following actions: zoom pan menu prev_img next_img # Now bind these actions to mouse buttons 1, 2 (wheel), and 3 prev_img 1 toggle_pause 2 next_img 3
To save and exit, enter CTRL-o, hit ENTER, and then CTRL-x
Next we'll configure the Raspberry Pi to autostart the slideshow.
Plug the thumb drive into the Raspberry Pi and find out what it's named by navigating to /media/pi
(You should already have put a bunch of pictures in the root level of the thumb drive. You can also have folders of pictures, or even folders in folders. The slideshow will recurse through these folders).
You can find the name of the thumb drive using the file navigator from the top of the Raspberry Pi desktop or in the LXTerminal window with these commands:
cd /media/pi
ls -la
Now make a shell script on the desktop called "startup.sh" (Rt-click on desktop; click on "Create New.../Empty File", Rt-click on the new file and open it with the text editor).
Put the following in this file:
# sleep for a few seconds to give the USB drive a chance to mount before running the slideshow sleep 5 feh -Y -x -q -D 5 -B black -F -Z -r --auto-rotate /media/pi/thumb_drive_name
Don't type "thumb_drive_name" in the above line. Put the actual name of the thumb drive that you found above in there.
Save and exit.
In the LXTerminal window you can also type man feh to learn all the options offered by the feh slideshow (man feh is Linus for - show me the manual page for feh).
Now we want to make this new file executable. In an LXTerminal window:
cd /home/pi/Desktop
chmod 755 startup.sh
Now we need to edit the "autostart" file to tell it to run that shell script on startup.
On the "Raspberry Pi 3 B" the "autostart" file should be found in /home/pi/.config/lxsession/LXDE-pi
On the "Raspberry Pi 3 B+" it should be in /etc/xdg/lxsession/LXDE-pi
In an LXTerminal window:
cd /home/pi/.config/lxsession/LXDE-pi (if you have the Pi 3 B)
or
cd /etc/xdg/lxsession/LXDE-pi (if you have the Pi 3 B+)
From there:
sudo nano autostart
Add this line at the end of the autostart file to execute the above script:
@/home/pi/Desktop/startup.sh
CTRL-o to save (and then hit Enter)
CTRL-x to exit
The Raspberry Pi should now autostart into your slideshow even without a keyboard or mouse.
You'll also want to turn off "overscan" so your picture goes to edge of screen:
From the top of the Raspberry Pi desktop select: Menu/Preferences/Raspberry Pi configuration
Now we want to make it possible to safely shutdown and bootup the Raspberry Pi with button pushes (rather than with keyboard and mouse).
In an LXTerminal window:
sudo nano /boot/config.txt
Add this line:
dtoverlay=gpio-shutdown
CTRL-o to save (and then hit Enter)
CTRL-x to exit
Now you can cause the Raspberry Pi to do a safe shutdown by shorting GPIO Pin 5 (which is GPIO3) to GPIO Pin 6 (which is Ground) on the 40 pin header (we'll set it up to do this with a normally open, temporary contact, pushbutton). See the picture above for pin locations. Pin 1 is the one close to the edge of the board.
For booting back up you can either pull power and plug it back in, or you can short the RUN pin (the pad marked "RUN" right near the end of the 40 pin header) to GND. We'll setup another pushbutton to do that. See the images above to find the "Run" pad on your board.
Adding a Case and Buttons
Now, we can add some optional finishing touches.
It's nice to get a case for the Raspberry Pi and it gives you a place to mount the shutdown and startup buttons. I used the case mentioned, but there are loads of cases available through Amazon, Walmart, Ebay... Pick the one you like, but make sure and get one for the model of Raspberry Pi you have. Some of the cases are pretty form fitting. It might be best to avoid those so you'll have room to mount the shutdown and startup buttons.
Using push-buttons of the type described, drill a couple of holes in the Raspberry Pi case to mount those buttons. Make sure and mount them where they will not bump into the Raspberry Pi board. If you use one of the acrylic cases you'll want to drill the holes with a drill press, very slowly and carefully. It helps to hold the acrylic down against a piece of wood right around the holes you're drilling. Acrylic is very brittle and super easy to crack when drilling. Drill slowly and keep pressure on the acrylic around the holes.
With the push-buttons mounted in the case you'll need to hook them up to the appropriate pins. Connect one of the button terminals to one terminal on the other button (by soldering a wire between them). Now solder a wire to those terminals that will go to GPIO Pin 6 (GND). On the other end of that wire, solder a connector of the type shown at the top of this instructable to slide it onto the GPIO pin. I like to cover the connector with a small piece of heat shrink tubing to keep it from shorting against neighboring pins, and to strain-relieve the wire.
Now solder a wire to the opposite terminal of the shutdown push-button. Put a connector on the opposite end of that wire and push it onto GPIO Pin 5 (GPIO3). This button will now cause a safe shutdown of the Raspberry Pi.
Now solder a wire to the opposite terminal of the startup push-button. You can either solder the opposite end of that wire to the through-hole "Run" pad on the Raspberry Pi board, or you can add a pin to that pad and add a connector to the wire to push onto that pin. I did the latter. This button will now re-start your Raspberry Pi board without the need to pull power and re-power it.
Make a Wooden Frame and Stand
This is also optional. You could leave the monitor on its stand, remove the stand and add a sort of leg so it just sits on the desktop, or remove the stand, add a leg, and add a wooden frame. I chose to go with a wooden frame.
I removed the stand that comes with the computer monitor and removed the metal top, mounting portion. I then made a sort of leg for it out of aluminum and screwed it to the mount hardware. This let me set the display on a desktop more like a picture frame.
I then made a wooden frame out of 1.5" by 1.5" by 8' white wood. I did this using a table saw and miter saw. I then sealed the wood with a painting sealer and gave it a couple of coats of semi-gloss black spray paint. I'm not going into the details here on making a wooden frame, but there's no magic to it. If people ask for it in the comments perhaps I'll add those details.
Using the Finished Frame
So that's it. You can put lots of pictures on the thumb drive at the root level. You can also add folders, and folders within folders. You can pause the slideshow by pressing the center mouse button/wheel, tell it to back up one image at a time by pressing the left mouse button, or tell it to advance one image at a time by pressing the right mouse button.
I hope you have fun building this and enjoy your digital picture frame.
Please feel free to ask questions or make suggestions in the comments. I'll try to answer them and update the instructable as necessary to make it as clear as possible.