Build a Kiosk with Pi Zero OTG and a Digital Frame

Facebooktwittergoogle_plusredditpinterestlinkedinmail

In this second instalment on how to reuse an old digital photo frame with a Pi Zero OTG and get it to be a bit more useful and interactive.

I am going to use a number of boards and gizmos to transform the digital frame into a digital Kiosk. The end goal is for a series of pictures onto the frame and get them played in a slide show on a regular base to show information downloaded and chosen by the Pi Zero.

So in the end I could have the Kiosk showing the BBC news, the weather page, my Google calendar, etc.

Overview-Annotations

What do we need

Well we know with need a Pi Zero and a digital photo frame; it says that in the title.

But let’s be more specific:

Parts-Annotations

Putting it all together

The biggest problem when using OTG with a Pi Zero is that you loose the possibility to connect the Pi to your LAN let alone the internet where the most interesting stuff is.

We solve the problem by using a enc82j60 based board which provides Ethernet via SPI. You can find a rather detailed article from Alex on his website RasPi.Tv

The 3V3 rail from the Pi has limited amperage that’s why I have included a regulator to be connected to the 5V rail and power the enc82j60 board.

In the picture below you can see how things get connected to the GPIO.

RasPiOPortsplus-Connections-Labels

I have also used Ryanteck Debug Clip which I have slightly modified by soldering a pass through header that allows me to have serial debug and access the whole of my GPIO for the enc28j60 and my Bright Pi from PiSupply

DebugClipMod-Annotations

having the additional header allows me to remove the Debug Clip and easily painlessly re-plug all the connections to the Pi.

Configuration snippets

Here are the relevant parts of the changes required to the standard Raspbian configuration in order to enable the Ethernet board, the Bright Pi, the OTG mass storage, ——

Thankfully the latest Raspbian  has made OTG a lot simpler to setup. As you start you OS up update it to the latest release.

sudo apt-get update && sudo apt-get upgrade

Make sure to enable SPI and I2C at boot. SPI is needed for the Ethernet enc82j60 and I2C for the Bright Pi.

in /boot/config.txt add these lines

dtoverlay=dwc2
dtoverlay=enc28j60,int_pin=25,speed=12000000

The first is for the OTG, the second for the enc28j60. Depending on the board you’ll get you can change the speed to higher, check the clock installed to know the maximum speed you can get.

The network card will tend to always get a new IP at every restart as it gets a random MAC address. It is a long story as to why, thankfully you can mend this by creating a new file called mac.sh under /etc/init.d with the following content

#! /bin/sh
ifconfig eth0 down hw ether 00:00:00:00:00:00
ifconfig eth0 up

replace the 00:00:00:00:00:00 with a meaningful MAC of your choice (maybe the first one the card got when you first booted) then execute

sudo chmod +x /etc/init.d/mac.sh

sudo update-rc.d mac.sh defaults

From now on your DHCP server should always give your Pi the same IP.

in /etc/modules add

dwc2
g_mass_storage

These enable the OTG mass storage.

We now need to prepare the file that will be used as storage.

sudo dd if=/dev/zero of=/piusb.bin bs=1024 count=102400

Once you restart your Pi everything should be ready for the next step.

After you login run

sudo modprobe g_mass_storage file=/piusb.bin stall=0

OTGConnection

and if you plug your Pi via its data port into a PC you should get it recognised as a USB mass storage device.

Do something with it

This time around we are going to use this setup to get some useful websites to be displayed on the digital frame.

A prerequisite to this is to run tightvncserver on the Pi and execute the script from a VNC session directly in a terminal within the GUI.

For this script I have used a mix of software tools

  • scrot
  • wmctrl

I have created a simple script in Bash which unload the g_mass_storage module, starts Epiphany on a specific URL, takes a screenshot, start another URL, takes another screenshot, etc. All these pictures are saved in the file system folder that is then used for the OTG mass storage.

sudo modprobe -r g_mass_storage
sudo mount -t msdos -o loop,offset=65536,umask=0022,gid=1000,uid=1000 /piusb.bin /home/pi/Pictures/
epiphany http://www.bbc.co.uk/weather/br7 &
scrot -b -d 15 /home/pi/Pictures/Weather.jpg
epiphany -n http://www.bbc.co.uk/news &
scrot -b -d 15 /home/pi/Pictures/News.jpg
sleep 10
sudo umount /home/pi/Pictures/
sudo modprobe g_mass_storage file=/piusb.bin stall=0
wmctrl -c BBC

Once the g_mass_storage module is loaded the pictures are presented as contents for the Pi Zero emulating a USB device and connected to the digital frame.

After a number of seconds the frame will start its autoplay and you can enjoy reading the headlines and watch the weather forecast through this otherwise rather dumb device, neat!

WeatherBR7

The script ends by closing Epiphany via wmctrl and the process can start all over again on a crontab job.

Next?

On the second part of this article I shall put together the rest needed to add some monitoring capabilities to our frame by using the new Raspberry Pi cam and the Bright Pi together with an LDR to check whether or not the Bright Pi should shine some light on our intruders 🙂

Stay tuned falks!

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.