DIY Digital Picture Frame
As you may have noticed, Kaddi and I take lots of photos on our vacations. But what good are vacation photos if you never look at them? So when we redecorated the living room recently, we wanted a way to incorporate our pictures as wall decoration. So we were looking to buy a digital picture frame…
We probably ordered every model Amazon has on offer and holy shit are they crap. Not only are they all cheap plastic, they also have horrible resolutions, weird software and sometimes simply not even work. The only decent model we found was the Nix Advance 10 inch. If you want to buy one, get a Nix model.
However even though the Nix 10“ worked fine, we wanted something we could mount to the wall and that looks like an actual frame. So I built it myself.
I went to AliExpress and ordered a bunch of parts. Delivery was surprisingly fast – after only a month everything had arrived. Only three parts I ordered from German online stores: the Raspberry (because it wasn't cheaper in China), the power supply (because I don't want an accidental fire hazard) and the framing mat (because I needed it custom cut). The latter was not of the quality I would have liked, but it works for now. I also bought the wood and paint in a local hardware store.
Here's the complete part list:
|10.1 IPS Panel||46.75€|
|Raspberry Zero W + shipping||17.61€|
|12V to 5V Converter||4.24€|
|DC Jacks 10x||1.36€|
|DC Jacks 10x||3.61€|
|12V Power Supply||13.99€|
|Framing Mat + shipping||8.90€|
|wood and paint||apprx. 20.00€|
I ended up with nearly exact the same price as the Nix, but with the additional benefit of having WiFi in the frame, which the Nix hasn't.
I didn't take a whole bunch of pictures during the assembly. But it was relatively straight forward.
- assemble the frame
- drill a hole for the PIR sensor
- put in the framing mat
- use some cardboard glued to the framing mat for aligning the display
- use a particle board to attach the electronics
- connect everything
- use pins to fixate the particle board in the fram
On the software side, nothing too special either.
- install Raspian light and set up the wifi
- install some minimal xserver requirements:
sudo apt-get install xserver-xorg xinit x11-xserver-utils lightdm
raspi-configto adjust locales and boot into desktop by default
At that point the raspi should boot into an empty desktop with a single xterm open.
Next, we need two things. First, a script that will switch off the display when no movement has been detected by the PIR sensor for a while. I cobbled the following together:
#!/usr/bin/python2 import RPi.GPIO as GPIO import time import threading from subprocess import call PIR_PIN = 18 TIMER = None TIMEOUT=60*10 def handleEdge(pin): if(GPIO.input(pin) == 1): handleMotion() else: handleAbsense() def handleMotion(): global TIMER stopTimer() call(['vcgencmd','display_power','1']) def handleAbsense(): startTimer() def stopTimer(): global TIMER if TIMER: TIMER.cancel() TIMER = None def startTimer(): global TIMER stopTimer() TIMER = threading.Timer(TIMEOUT, handleShutdown) TIMER.start() def handleShutdown(): global TIMER TIMER.cancel(); TIMER = None call(['vcgencmd','display_power','0']) def main(): GPIO.setmode(GPIO.BCM) GPIO.setup(PIR_PIN, GPIO.IN) GPIO.add_event_detect(PIR_PIN, GPIO.BOTH, callback=handleEdge) # main loop while True: time.sleep(0.1) GPIO.cleanup() if __name__ == "__main__": main()
This assumes the PIR sensor is connected to GPIO 18. It uses the
vcgencmd tool to switch the HDMI display on when motion is detected and off when no motion has been seen for 10 minutes.
Next we need to automatically run a photo slideshow and the above script when the raspi boots. For displaying the pictures we use feh. So install that first:
sudo apt-get install feh.
Then create an
# disable screensaver xset s noblank xset s off xset -dpms # use PIR sensor to turn on/off display /home/pi/pir-control.py & # start slideshow feh -F -Z -z -D 120 --auto-rotate photos/
That's it. Put some pictures into
/home/pi/photos, reboot and you're done.