Raspberry Pi Photo Booth

I had a thermal printer for a while now, but never used it as part of a project. Recently, I purchased the new Raspberry Pi Touch Screen and decided to make a kind of photo booth. The touch screen would be used for the user input, instead of using (mechanical) buttons. If the user is satisfied with the picture, it can be printed on the spot by the small printer.

It’s certainly not a new idea, but I thought it would be a fun little project to try out.

The main components used in this project are:

  • Raspberry Pi 2 Model B
  • Raspberry Pi Camera
  • Raspberry Pi 7″ Touch Screen Display
  • WiPi USB Dongle
  • Mini Thermal Receipt Printer
  • Raspberry Pi Camera Wide-Angle Lens

Raspberry Pi

For this project, I ended up using a Pi 2. Originally, I tried with the A+, but some software components failed to install (more on that in the “Kivy” paragraph).

For the OS, the latest version of Raspbian was used (2015-09-24 Jessie). It can be downloaded from the official Raspberry Pi website: https://www.raspberrypi.org/downloads/raspbian/
Getting the OS image on a microSD card can be done in several ways depending on your own operating system. In my case, in OSX, I used “dd” to get the image on the micro SD card.

Once the image has been written to the microSD card and the card has been unmounted, it can be removed from the PC and inserted in the Raspberry Pi.

Touch Screen

Connecting and getting the touch screen to work with the Raspberry Pi was super easy using the instructions found right here on element14: http://www.element14.com/community/docs/DOC-78156#installI

Using the latest Raspbian image (2015-09-24 Jessie), the touch screen was plug & play. I did install the additional virtual keyboard by executing following command:

WiPi

Getting wifi to work on the Pi is another one of those plug & play things. Just connect the wifi dongle, select the access point you wish to connect to in the desktop environment and enter the password. That’s all there is to it.

Pi Camera

No photo booth without a camera, right? Let’s see how to connect and enable the camera.

Connecting the camera

To connect the camera to the Pi, open the CSI slot located near the ethernet port and ensure the camera’s flex cable is inserted with the exposed contacts facing away from the ethernet port.

Enabling camera support

By default, the camera support is disabled. To get the camera to work, support needs to be enabled using the “raspi-config” tool.

Open a terminal and enter following command:

A menu will appear. Select option 5: “Enable Camera”, and in the following step, select “Enable”. Reboot the Pi.

1 2

Thermal Printer

To set up the printer, a complete guide is available over at Adafruit (https://learn.adafruit.com/pi-thermal-printer/overview), only a few steps are relevant for this project though and I will highlight them in the next paragraphs.

Connecting the printer

There are two parts to connect the printer:

  • power, using an external 5V power supply (at least 1.5A for the printer only)
  • data, using the Pi’s GPIO serial interface (including GND)

To easily connect an external power supply, I cut off one end of the provided power cable and screwed on a female DC barrel jack connector. The data cable, even though not ideal, can be connected to the Raspberry Pi’s GPIO. Careful!, the the printer’s TX pin (RX on the Pi’s GPIO) should either be disconnected or have a 10k resistor added to compensate for the level difference (5.0V vs 3.3V).

3

You’ll notice I moved the GND jumper wire from the touch screen to another GND pin, in order to accommodate the printer’s data cable.

Controlling the printer

Start by installing the necessary software components.

In the cmdline.txt file, remove references to ttyAMA0 to avoid conflicts with the printer on the serial interface.

Download the Adafruit python library for the printer, containing some example code.

After the Pi has rebooted, it should be possible to make a test print.

The printer should then output something like this:

4

Kivy

Kivy is an open source Python library used for developing applications making use of user interfaces. Kivy’s official website can be found here: http://kivy.org/#home

The installation steps and some example code are provided via Matt Richardson’s tutorial, in which he used Kivy to control the Pi’s GPIO using the touch screen: http://mattrichardson.com/kivy-gpio-raspberry-pi-touch/index.html

Some notes on my experience, performing the installation:

  • I originally used the Raspberry Pi A+. However during the Cython installation step, it runs out of memory and starts swapping. The installation never finishes as the kswapd0 process takes 100% CPU. Using the Raspberry Pi 2, no problems were encountered.
  • Originally, when trying to edit the Kivy’s config.ini (~/.kivy/config.ini) in order to add touch support, the file didn’t exist. After running an example (~/kivy/examples/demo/pictures/main.py), the file was there and could be edited. [Update: the instructions on Matt’s website have been updated to take this into account]

Project

With all individual components working, it’s time to move on to the project specific topics.

Code

The code is based on Matt Richardson’s example application, which was then adapted to suit my needs. In addition, Adafruit’s thermal printing python library was added to have printing support as well.

I’ve added comments in the code to make easier to understand.

Build

For the frame, I picked something simple: a wooden board holding all the components in place. The result would be a flat and portable photo “booth”.
I started by using some tape to draw on and see how the result would be. Everything looked good, so I started cutting and drilling. A bit of sanding was required to make everything fit.

Demo

Hope you like the project!

48 thoughts on “Raspberry Pi Photo Booth”

  1. What did you use to mount the 7″ display to the board? Looks like custom plastic? I’ve been contemplating what to use to mount the 7″ for another project of mine. I was considering erector set pieces or something similar.

  2. Hey Frederick,

    Cool Projekt. Based in your Projekt I am building oben Booth

    At this Point everything is working but I am missing ins thing. I like to Show a Countdown … For example counting from 10 to 0 before The Image is taken.

    I dont Know how do Display a Countdown in kivy in de Main Screen or maybe on a Popup. Do you have an Idea? Maybe you cam edit this in your Code?

    Greatings from Germany
    Manuel

    1. A countdown sounds interesting. I don’t know how to do it in kivy, so I would have to have a look on how to do it. I suppose it should be that hard, having a function triggered when the “photo” button is pressed that decreases a counter variable and refreshes the screen.

  3. hello sir Fredeick,

    i am graduating student, and our thesis project is about “assessment kiosk machine” we use raspberry pi 2b, thermal printer, touchscreen, and coin acceptor.

    if possible sir, can i see your schematic/circuit diagram of your project? or even the thermal printer to ruspberry pi..

    and if you have any idea how to connect the raspberry pi 2b, coin acceptor, and thermal printer. ca you send me how to do it? 🙂

    we really need your help sir.. thank you in advance 🙂

    1. Hello Jaffer,

      the printer is connected to the serial pins on the GPIO header. Have you looked at the picture in paragraph “Connecting the printer” ? That’s really all there is to it. The printer’s RX pin should be connected to the Pi’s TX pin (Pin 8).
      Also make sure the GND of the printer is connected to the GND of the Pi and that the printer is not powered via the GPIO 5V pin; but straight from the power supply.

      Good luck! 🙂

      1. Thank you sir Frederick,

        i forgot to ask, is there a compatibility between raspberry pi 2b and thermal printer? Are all thermal printer compatible to raspberry pi 2b? I could use any suggestion and recommendation from you sir.

        Thank You very much! again sir. 🙂

        1. Hi Jaffer,

          I only used the Adafruit thermal printer, so I can’t tell for sure about other printers. The one I used though, should be compatible with any model Raspberry Pi I believe.

        1. Hello Jaffer,

          I have no idea. Best is to search the Adafruit website or contact them. But the printer works using a serial interface, so I suppose it shouldn’t be too hard for you to do it in Java ?

          1. What kind of serial interface sir? also sir our raspberry pi appear a log-in box when we open it and the account “pi – raspberry” are cant log-in here, can you help us how to solve this problem?

            Thank you very much sir Frederick for time and helping 🙂

  4. Hello Frederick,

    one more Question my kivy program is running very good but I got one Problem.

    I am starting the program after the raspberry ist loggend in with the user pi.
    On the main Desktop of the OS yessie there is a task bar with the midori, plan signal, time, calendar etc……. when i now start my program on do some touches in the Programm for example on a Button and the button is on that place where on the main screen is the calendar or midori this will also open these programs in the background.

    Hope you know what i Mean….. the clicks also go out of kivy on the OS.

    Sorry for my bad English

    1. Hi Manu,

      I think I know what you mean, but I haven’t experienced this myself. Have you tried searching around and see if anyone else has similar issues using Kivy ?

    1. Hi there!

      I’m using a 5V/4A DC barrel jack power supply which I split to power the Pi, printer and touch screen with. This covers the 5V/1.5A for the printer, and the 5V/2A for the Pi + screen.

      I cut a USB cable, kept micro USB on one side to power the Pi, and soldered the cut end to a female DC barrel jack connector.

      Hope that clarifies!

  5. What kind of serial interface sir? also sir our raspberry pi appear a log-in box when we open it and the account “pi – raspberry” are cant log-in here, can you help us how to solve this problem?

    Thank you very much sir Frederick for time and helping 🙂

  6. Hi Frederick,
    First of all thank you for your great documentation of this awesome project. Unfortunately I’m having some trouble with the printed output. The Printer starts printing but fills some lines of it with cryptic letters or something like this: http://i.imgur.com/ODG6zkSm.jpg. It even fills some lines of this inside the picture. The printerexample from ardafruit works fine. The Sudoku example has the same problem as written above. The weather example does nothing at all. I’ve read something about this issue on this forum (https://forums.adafruit.com/viewtopic.php?f=19&t=90832). Their solution was to replace the printer and get a new one from adafruit. Is this the only way or is there a better solution for my problem?

    Thanks in advance
    Fabian

      1. Strange characters could also come from the serial console. Make sure that is disabled, as anything happening on the serial console may be printed as well.

        Frederick

    1. Update: Fixed it! 🙂
      Just wanted to let you know, what my solution was: I got rid of those strange characters between the picture, just by using a better power supply (5V/5A). Sometimes it’s really that easy.

      Thanks Frederick!

  7. Hello Frederick,

    great job! I´m not shure how to install Kivy and your script. Is there a step-by-step tutorial available?

    Thank u very much!
    Marc

    1. Hi Marc,

      a step by step installation of Kivy is linked in that paragraph. Click the link to Matt Richardson’s website for the instructions! 🙂

      Frederick

      1. Thank you Frederick,

        in the meantime my printer is working, but when I try to start the script, I get the following error:
        IOError: [Errno 2] No such file or directory: ‘/home/pi/photobooth/line-top.png’
        Where can I get this file? Or what have I done wrong?

        1. Ah yes, that is just an image of a decorative line to be printed on top of the photo. If you just need the actual photo, remove this from the code. Otherwise, add your own decorative image and give it that name 🙂

  8. Bonjour Frederic,
    Merci pour ton superbe tutoriel d’abord 🙂
    – J’ai acheté une imprimante ADA597 egalement.
    – J’ai tout installé (sources adafruit)
    – Quand je lance les tests fournis avec adafruit ca imprime parfaitement.
    – Mais quand je veux imprimer une photo (en utilsant une partie de ton source) elle ne s’imprime pas correctement. soit elle est hachée, soit des caracteres apparaissent en plein milieu. il est meme arrivé que l’imprimante s’arrete et plante

    Pourtant je la redimensionne bien (pas plus de 384px de large) j’ai essayé en la passant en niveau de gris, ou en noir et blanc, pareil.

    As-tu eu ce genre de problème ?
    As tu une idée ?
    je vais tester avec une autre alimentation au cas ou .(j’utilise une 5v 2A)

    Merci

    1. Bonjour!

      L’imprimante a besoin de 1.5A à elle toute seule, plus au moins 1A pour le Raspberry, 2A sera trop juste.
      Personnellement, j’utilise 5V/4A et je penses que ca pourrait résoudre ton problème 🙂

  9. Merci Frederic,
    l’imprimante a sa propre alimenation (5V 2A), car je ne voulais pas qu’elle soit partagée avec le raspberry justement.
    j’ai desactiver les communications sur le port serie egalement.

  10. Oui le GND de l’imprimante est branché sur le pi. (c’est bien le fil noir qui va avec le fil jaune TX ?)
    Si je branche le cable jaune (donnée envoyées a l’imprimante ca peut marcher ?

  11. Hey Frederick,

    Thanks again for this project.
    I just noticed, that if you press the print button frequently, a lot of pictures will be printed (of course).

    I’d like to realize, that if you press a button the software waits, untill the printing is ready. Can you give me some keywords I can google for or a line or command i have to use?
    As you have noticed, I’m not that good in coding.
    Thanks a lot in advance for any help 🙂
    Fabian

    1. Hi Fabian,

      What you could do, is disable the “print” button after the first press, and enable it again when the “photo” button is pressed.
      So add the “disable” statement to the pint callback, “enable” to the photo callback function.

      I haven’t done it before, so try searching for “kivy enable disable button”, that should return the commands you need 🙂

      Frederick

  12. Aprés plusieurs experimentatoin ca marche enfin (impression de photos) !!
    j’ai finalement remplacer l’alimentation 5V 1.5Amp par une 9V 2amp et tout fonctionne.
    Je poste bientot des photos de ma réalisation lorsqu’elle sera achevée. Un grand merci à toi Frederick 🙂

  13. Salut, merci pour le partage !
    Tu sais combien de photos à peu près on peut imprimer avec cette imprimante, avant qu’elle arrive à court d’encre ? Ça se recharge facilement ?

    Merci !

    1. Hi Florian,

      l’imprimante n’utilise pas d’encre. C’est du papier thermique qui devient noir quand il est chauffé par l’imprimante. Donc pas de recharges pour l’imprimante, uniquement le papier!

  14. Hello Frederick,
    i like your RaspberryPiBooth.
    I am building a Photobooth with an DSLR and the Rapsberry Pi 3 (Model B) with the 7″ Touchscreen and i like the idea of the little thermal printer. It’s a very good low cost solution for printing the picture, but don’t spend much money on the printer, the paper or the ink.

    Do you know if there is any problem or difference by using the Pi3 (Model B) with python 3 and Tkinter for the GUI?
    For this project it is the first time i am working with the raspberry pi and python.

    Thx for this awesome project and the idea 🙂
    greetings

    1. HI Ben,
      Maybe it’s a bit late to answer you, but I’ve also tried with a Rpi3 B, and one of the big difficulty was trying to have the mini thermal printer work at all. In fact, Adafruit’s library doesn’t work with Rpi 3 B.

      What I did to have the printer work was using this tutorial : http://geekgurldiaries.blogspot.fr/2012/12/little-box-of-geek-project.html
      And in addition, follow those steps (in French but you should get it) : http://forums.framboise314.fr/viewtopic.php?t=2744#p17359

      But I’m not sure if it’ll work with Python 3.

      There is also this other printer library that should work with Python 3, but unfortunately, it did’nt work at all for me : https://github.com/luopio/py-thermal-printer

      So now, my mini printer works with my rpi 3 B, but printing photos really isn’t quite as good as Frederick’s photobooth. I just can’t get it. I’m trying to play with all the printer’s parameters, but untill now, this isn’t working… If anyone has an idea, I’d love to hear it !

      Hope this will help, Ben.

Leave a Reply

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