Make: Raspberry Pi Message Frame


The Raspberry Pi Message Frame is a pair of photo frames that can record, send, receive and play audio messages between each other. The frames can be anywhere in the world once they are connected to the Internet. In the background the messages are sent and received over email. Scroll to the very end of this post for a video demo


I have small children in the UK and close family in Ireland. I wanted an easy way for my small children to send sweet short voice messages to their family in Ireland without having to log in, launch an app or even be under my supervision. I also wanted them to be able to send the messages at 6am when they wake up but to be played at 11am when Uncle Al rolls out of bed. And vice versa!


I failed a lot with this project, which is fantastic because I learnt a lot.

Notable fail/learning points:

  1. Pulling out the wires from the button spade connectors. You need the strength of the Incredible Hulk to crimp spade connectors onto wires correctly.
  2. Soldering pins onto the Voice HAT THE.WRONG.WAY.ROUND. Ha, that was a fun one! I learnt how to de-solder after that 🙂
  3. Trying to do the whole project on my own. To start with I had LEDs and resistors attached to breadboards and buttons badly embedded into the frame… then I presented my project to the Preston Raspberry Pi Jam and Ivan from CPC told me about some cool LEDs with built in resistors and some lovely buttons with a longer body and satisfying CLICK. Raspberry Pi is a really great community. I recommend putting your project out there early and asking for help/suggestions.
  4. Trying to do the whole project on the cheap. As I was building 2 frames I really wanted to make everything as cheap as possible. Good quality sound is not easy to add to a raspberry pi zero without an expensive hat. At first I had a cheap 50p speaker with an amp, an audio adapter and a microphone. The speaker was no way loud enough so I was using code to increase the volume which also increased the background noise. It was “good enough” but I was reluctant to finish this project without really good sound. And out of the 3 audio adapters I have, 2 were not working – grrr.


    Frame Mark 1

  5. Then the wonderful people at the MagPi released the Voice HAT for FREE with issue 57 of their magazine! So for £5.99 x 2 I was able to get everything I needed for awesome sound. What did I learn: how to mess around with sound and microphones on the pi and how to increase sound using code.
  6. I really enjoyed learning how to use imap on python – that’s going to be useful for future projects.
  7. I kept mixing up SD cards and connecting to the wrong frame. Proper labelling really helps with a project with multiple pis!


  1. A drill
  2. A soldering iron
  3. Pliers or a crimping tool
  4. A mini HDMI adapter
  5. A HDMI TV
  6. Keyboard/mouse
  7. Wifi Internet

Parts (multiply everything by two to make two frames!)

  1. IKEA Ribba Frame £3.50
  2. MagPi Issue 57 Voice Hat Kit £5.99
  3. Eight female to female jumper wires
  4. Two buttons – red and green
    1. £0.59
    2. £0.59
  5. Four spade connectors
  6. Two LEDs – red and green
    1. £0.18 each
    2. £0.18 each
  7. Raspberry Pi Zero W £9.60
  8. SD Card £5
  9. Power cable and plug for the Pi Zero £2
  10. Header Pins for the Pi Zero £1

Total cost is just under £30.00 per frame. Luckily I had a lot of the tech lying around my house like the USB cables/plug to power the Pi and the jumper wires.

Build: The Pi and the Hat

  1. Setup the Voice Hat, speaker and microphone following step 1 from the Google AIY project:
    1. Ignore step 1.5 – adding the button wire
  2. Setup the SD card following steps 4 and 5 from the Google AIY project:
  3. Split the Voice Hat pin strip into sets of 3
  4. Solder the pins onto the Voice Hat Servo holes
  5. While the iron is hot, solder the pins onto the PiZero
  6. Unleash your inner hulk and crimp the spade connectors onto the buttons. I’m told a crimping tool can help with this


    A beautifully crimped button

  7. Connect the female to female jumper wires to the servo pins 1, 2, 3 and 4. DON’T connect to the buttons or LEDs yet as these need to go in the front of the frame first.

The Google AIY page shows an image of which pins are which:–connecting-additional-sensors

Build: The Frame

  1. Take apart the frame into its five pieces: the mount, the inner box, the outer frame, the backing card and the glass. You won’t need the glass, dispose of it safely.
  2. Drill two 9mm holes into the mount for the buttons
  3. Drill two 3mm holes into the mount for the LEDS
  4. Push the buttons into the 9mm holes – my buttons are too long so actually stick out a little bit.
  5. Push the LEDs into the 3mm holes
  6. Place the mount into the frame box first, then the inner box. This holds the mount to the front of the frame.
  7. Place the Voice Hat into the frame box.
  8. Place the LEDs and buttons into the front of the mount.
  9. Attach the other end of the female to female jumper wires to the buttons and the LEDs as follows:
    1. Servo1 (GPIO 6) and GND – Red button
    2. Servo2 (GPIO13) and GND – Green button
    3. Servo3 (GPIO 5) – Green LED long leg
    4. GND – Green LED short leg
    5. Servo4 (GPIO 12) – Red LED long leg
    6. GND – Red LED short leg
  10. For now leave the backing card off

Code – Testing

  1. Login to the PiZero and add the file to /home/pi
  2. Run
    1. python3
  3. Press the red button, make sure the red LED comes on and check the screen for “RED Button Pressed”
  4. Press the green button, make sure the green LED comes on and check the screen for “Green Button Pressed”

If any of the buttons/LEDs don’t work: check the connections from the button/light, check the connections to the voice HAT, make sure you’ve connected the short leg of the LED to GND.

Code – Setup Gmail

You don’t have to create a gmail email account especially for this project, once the messages are downloaded they are deleted from your email. But if it’s not fast enough you might get notifications of new emails.

To use imap from the raspberry pi you need to turn on 2 step authentication for your Google account and then get a special application password. This keeps everything really secure.

  1. Turn on 2 step authentication. Go here: and follow the steps to turn on 2 step authentication for your Google account
  2. Get an application password by going here: and selecting “Select app” > Other. Enter your own name for the application, e.g. myframe and select “Generate”
  3. Make a record of the password

Code – Frame

  1. On the Pi create two folders in home/pi called piframe_in and piframe_out
  2. Add these files to home/pi:,,
  3. Create two blank files called last_id and errors.log
  4. Change the text in
    1. toaddr – the email address of the other frame/person you want to send the voice messages to
    2. me – the email address you just setup
    3. The application password you generated above
  5. Add the following lines to crontab so they run all the time and on reboot. Make sure you run
  6. sudo crontab -e


Code: How it works

frame_out runs all the time waiting for a button press or new voice messages. When you press the red button, the red LED turns on to indicate recording. Record your message by speaking at the frame. Press the red button to stop recording. After around 20 seconds the green light will flash to indicate the message has been sent. frame_out creates a wav file of your recording and gives it a unique name of the current date/time. It saves it into piframe_out folder then it emails it. Once the file has been emailed it is deleted from the piframe_out folder.

frame_in runs every minute, checking gmail for new messages. It looks for the unique subject word “piFrame” and it keeps track of the ID of the last email it downloaded in the file last_id; so it doesn’t download old messages that it has already played. When it finds a new message it downloads the attachment to the piframe_in folder and deletes it from the email account.

frame_out also checks the piframe_in folder for new messages. Once a new message appears, it lights up the green LED. When you press the green button it will play the message through the speaker then it will delete the file from the folder.

I recommend having the to and from address the same to start off, so you can do all your testing on one frame by sending messages to yourself.

None of the out files or in files are kept on the raspberry pi, but they are still in the email accounts in both the sent folder and the trash of each account.


Once everything is working, put a lovely picture in the mount. The frame is not a standard UK photo size. It’s 5×5. I had to chop up a 7×5 inch photo to fit it in the mount. I stuck the microphone to the back of the mount, facing outwards but it got loose and wandered around. It didn’t seem to affect the quality of the recording. Everything does fit in between the mount and the backing card, but can be quite fiddly to get it to close. And the damn jumper wires like to wander too – run when you’ve sealed it to make sure everything is still connected behind the photo!

Seal up the frame. The back board has a handy hole in it for the power cable to run out:


Power cable slips out nicely

Make another frame, set it up in your grandma’s house in Australia and start sending her voice messages!

What next?

With more money you could add a camera and a screen to the frames and send each other video messages (don’t get weird)

What about three frames – one for you, one for grandma and one for nana? Your frame has a toggle switch between grandma and nana that allows you to choose which favourite grandmother (nana) you want to send your message to. Grandma and nana’s frames can only talk to your frame.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s