Homemade photo frame with RaspberryPi and gmail

I builded a digital photo frame in 2012 with a old TFT-screen 17″ that I had lying around.
Here comes a post about how I did it, and sharing my scripts…

Here is a video and the photo frame have a uptime for three years now.

Guide from clean install of raspbian – using 2015-05-05 version.

pi@fotoram ~ $ sudo apt-get update
pi@fotoram ~ $ sudo apt-get upgrade

Now you have the latest version of your raspbian.

Now we have to install feh. Feh is the program that display the pictures and installing php, because we are using some php-scripts.
And at least, sendmail. Because after we email a picture, we get a respond from the photoframe that the picture is received.

pi@fotoram ~ $ sudo apt-get install feh php5-cli php5-imap sendmail

Download the scripts.

Okey, how does this work? First we have to disable screensaver, otherwise the screen will shutdown.

Stop text terminals from blanking
change in /etc/kbd/config these two:

Stop Xsession from blanking
Add these lines to /etc/xdg/lxsession/LXDE-pi/autostart or /home/pi/.config/lxsession/LXDE-pi/autostart
@xset s noblank
@xset s off
@xset -dpms
and comment out line @xscreensaver -no-splash to
#@xscreensaver -no-splash

In the photoframe.zip file we have a couple of files.

bilder = folder there feh will look for pictures.
display.txt = textfile with information that will display in the bottom corner.
fetch_mail.php = A php script that fetch new pictures from gmail.
get_online_pics.sh = A script that fetch webcam pictures from the internet and put it to the bilder folder.
picslide.sh = Script that start feh at boot.
put_display.sh = Update the information in display.txt file
run_fetch_mail.sh = Script that run fetch_mail.php, I made it because sometimes it take some time to fetch a new picture from gmail. And if the service is running the system hangs. So this script look if the fetch_mail.php is running, and if it does. It won’t start a new one.

Now everything is installed and the scrips are in pi homefolder.

Now add these lines to cron.
First I like pico as a editor insteed of vim.
So change the editor

pi@fotoram ~ $ which pico  # Output /usr/bin/pico
pi@fotoram ~ $ export EDITOR=/usr/bin/pico

Now run

pi@fotoram ~ $ crontab -e

Add following lines:

*/1 * * * * /home/pi/get_online_pics.sh > /dev/null 2>&1 # Get a new pictures from webcam
*/1 * * * * /home/pi/put_display.sh > /dev/null 2>&1 # Update display.txt
*/5 * * * * /home/pi/run_fetch_mail.sh > /dev/null 2>&1 # Get new pictures from Gmail
00 22 * * * /opt/vc/bin/tvservice -o > /dev/null 2>&1 # Shutdown screen at 22:00
00 05 * * * sudo reboot > /dev/null 2>&1 # Reboot the Pi at 05:00 so the screen wakes up

Now we have that running, lets add so feh starts at bootup. Go back to /etc/xdg/lxsession/LXDE-pi/autostart or /home/pi/.config/lxsession/LXDE-pi/autostart and add @/home/pi/picslide.sh at the bottom save and then reboot.

As you can see in my script, that fetch_mail.php the script is only looking for new pictures in label Fotoram. So you have to make a filter in gmail. I using

Match: from:(myemailAndOneFilterforMypartnersEmail@essunga.org)
Do: Jump over Inbox, Use Label "Fotoram"

Do you have any questions or problems, please write a comment.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.