Pi-Powered Thermal Printer Camera

3,923

57

7

Do you miss your old Polaroid instant camera, or your old Gameboy Classic's black and white camera? So do we, when we feel really nostalgic! In this Instructable, we will show you how to make your own instant camera using a Raspberry Pi, a Pi camera and screen and some electronics and a bunch of cardboard!.

Step 1: The Things You'll Need

For this project, we used the following supplies:

  • A Raspberry Pi 3B or 3B+ with microSD card (this model is our go-to for builds, but this project should work with other Raspberry Pi models)
  • A Raspberry Pi camera module
  • A 3 amp, 5V microUSB power supply
  • An official Raspberry Pi touchscreen
  • A USB thermal printer - we used one of Adafruit's tiny thermal 3D printer
  • A switch - we used one of Adafruit's arcade button from a previous project, but any switch will do

We also used the following equipment:

  • A third hand tool, to hold your electronics while you solder
  • Pliers - the flat, needlenose and cutting kinds
  • A wire stripper - to save you time prepping wiring
  • A soldering iron and solder

Step 2: Optional: Prep Your Raspberry Pi for Anything

For this Instructable, we will be using a Raspberry Pi we prepped using our previous tutorial. If you’re starting from scratch, it’s a great way to make sure we are using roughly the same setup.

Feel free to setup your Raspberry Pi with this guide if you want to, then come back here to continue with our Thermal Printer Camera project!

Step 3: Cutting Your Cardboard Camera Frame

We designed a cardboard frame so we can easily move our camera where we need it - for example, if you need better lighting or to take it to an event.

You can download the vector files for laser cutting from Github, or you can use it as a guide to cut your own with an X-acto blade or a box cutter. For this Instructable, we will assume you’re using our cardboard frame!

Step 4: Prepping and Mounting Your Touchscreen

Open your touchscreen box and check that you have:

  • your video cable
  • your mounting screws
  • your DuPont cables
  • your touchscreen

If you have everything, you're ready to go!

  1. Connect the red DuPont cable on the 5V pin on the screen board
  2. Connect the black DuPont cable on the Ground pin on the screen board
  3. Sit your Pi on top of the posts on your touchscreen
  4. Screw your Pi in place
  5. Connect the black DuPont cable to a 5V pin, and the red DuPont cable to a ground pin on your Pi

Power your screen and your Pi through the microUSB port on your screen. If everything went well, the Pi and Screen should both turn on! When you're happy that everything seems to work correctly, turn everything off: we'll get back to your Pi in a moment.

Step 5: Prepping and Mounting Your Camera Module

TIP - The Pi camera module is one of the most sensitive pieces of electronics we’ve worked with and we have seen some get fried just because of static electricity. Ground yourself by touching something big and metallic in the MakerSpace or around your home, like one of the laser cutter, a dishwasher or a radiator!

Open your Pi module box and check that you have:

  • your Pi camera module
  • your Pi camera cable

If you do, great! Time to connect the camera to your Pi:

  • Gently pull up the brown tab on the camera module's port
  • Insert the end of your cable, silver contacts (up? down?)
  • Push the tab back in to secure the cable in place
  • Gently pull the camera port's brown tab up on your Pi
  • Insert the other end of your cable inside the port, silver contacts turned towards the screen port

Finally, secure the Pi camera module in the cardboard frame from the back with a piece of duct tape.

Step 6: Prepping and Mounting Your Thermal Printer

TIP: First time using a soldering iron? Check out Adafruit’s guide to excellent soldering first!

Time to check your printer package! For this step you will need:

  • Your thermal printer
  • Your printer power adapter
  • The connection wires that came with your printer

If you have everything, you're ready to prep your printer for power! Turn on your soldering iron and:

  1. Tin the back and front pins of your barrel plug
  2. Strip and tin some red and black wire
  3. Solder the red wire to the back pin
    Solder the black wire to the front pin (if you want to use some heathshrink tubing to insulate the wires, now is the time to cut it to size and slip it on the wires!)
  4. Solder the red and black wires to the corresponding wires on the power connector that came with your printer (if you used heatshrink tubing, you can heat it now to make it hug, insulate and secure your wires)

Your printer is ready! You can now place it into the frame:

  1. Feed your printer in through the front of the frame, with the door opening down
  2. Connect your power wires and USB cable from the back
  3. Connect the USB cable to the Pi
  4. Connect the power adapter to the barrel plug

Step 7: Prepping and Mounting Your Switch

TIP: If like ours your switch has more than two pins and you don’t know which do what, you can use a multimeter’s continuity mode to identify which pins are connected when you press your switch!

After you identified the switch pins, turn on your soldering iron and:

  1. Tin the switch pins with a little solder
  2. Strip and prep some wires the same way you did for your printer’s power wires, this time using some DuPont wires (or regular wires, in case you just want to solder everything on your Pi’s pins)
  3. Solder them to your switch’s pins
  4. Feed your switch through the hole on your cardboard frame, wires first. Secure your switch from the back with the screw ring, but not all the way
  5. Connect the black DuPont cable to a Ground pin, and the other cable to your Pi’s BCM pin 16 - with the GPIO pins closer to you, that will be the third pin from the left.

Step 8: Installing Your Printer

Now that your printer is ready for use, let's work on the software side of things. First off, let's make sure your Rapsberry Pi operating system is up to date. In your Terminal, type:

sudo apt-get update
sudo apt-get upgrade

This might take a little while, but once everything is up to date we can install printer support on your Pi. Still in your Terminal:

sudo apt-get install git cups wiringpi build-essential libcups2-dev libcupsimage2-dev

This will install all the software you need to support your printer. Next, let's add the capacity for your printer to print raster graphics. Still in your Terminal:

git clone https://github.com/adafruit/zj-58
cd  zj-58
sudo make
sudo ./install

Execute each command one after the other, giving them time to finish.

You should have a test print in your printer's box: you should find a BAUDRATE value on it. Keep it handy, because we need it for this next step! In your Terminal, create a profile for your USB printer with:

sudo lpadmin -p ZJ-58 -E -v serial:/dev/ttyUSB0?baud=YOUR BAUDRATE VALUE HERE -m zjiang/ZJ-58.ppd

Then, make this new printer your default printer with:

sudo lpoptions -d ZJ-58

That's it! Your printer should be ready to go.

Step 9: Install the Picture-Taking Script

To install the picture-taking script, you can just copy the code we made available on Github. It's a simplified and commented version of Philip Burgess' original script, automatically setting up the exposure for the camera. In your terminal, type:

git clone https://github.com/jocolibrarymakerspace/thermal_printer_camera

This will create a thermal_printer_camera folder and download all the necessary files there.

To test your setup now, go to the thermal_printer_camera folder:

cd /home/pi/thermal_printer_camera

Give yourself the permissions to run the instant camera script:

sudo chmod +rx thermal_printer_camera.sh

Run the script:

./thermal_printer_camera

When you press your switch, your screen will display a preview of what the camera can see, give you a few seconds to pose and print out the picture to your thermal camera!

Step 10: ​ Starting the Camera Software on Boot

Finally, let's have the picture-taking script start automatically when we turn the Pi on! In your terminal, type:

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

to edit the file that manages programs on desktop startup. This will open the text files that lists the commands to execute on startup, regardless of who is logged in. Use the arrow keys or your mouse to navigate to the end of the second line and press Enter for a new line. Then, add the following:

/home/pi/thermal_printer_camera/thermal_printer_camera.sh

This will start the camera software up with your Raspberry Pi on boot. Press CTRL+X to exit, confirming changes with Y and Enter.

Now is a good time to reboot your Pi and test it out! Nothing special should show up on your screen, but when you press the switch the camera should activate, and the Pi will give you a preview on your screen for a few seconds before printing out your picture!

Step 11: Would You Like to Know More?

This design was inspired by Phillip Burgess's tutorial "Instant Camera using Raspberry Pi and Thermal Printer"

at https://learn.adafruit.com/instant-camera-using-raspberry-pi-and-thermal-printer?view=all

We used this camera and a fancy laser cut wood frame for our 2018 Library Lets Loose fundraising event, and are already gearing up for the next! Find out more on the Johnson County Library Foundation website at https://www.jocolibraryfoundation.org/

Share

    Recommendations

    • Beauty Tips Contest

      Beauty Tips Contest
    • Sensors Contest

      Sensors Contest
    • Growing Beyond Earth Maker Contest

      Growing Beyond Earth Maker Contest

    7 Discussions

    0
    None
    AAndy

    4 months ago

    why do I have to use a model 3? I have several spare model 2's lying around, will they be sufficient? thanks
    Well written instructable...

    2 replies
    0
    None
    jocomakerspaceAAndy

    Reply 4 months ago

    Thanks Aandy! We used a Pi Model 3 because that is our go to, but you are welcome to give this project a try on a Pi 2. Facilitator Thomas thinks it should work - let us know how it turns out for you!
    0
    None
    MrBulp

    4 months ago

    how to add image to ascii script for output ? its kinda more unique than the normal black & white image. :)

    1 reply
    0
    None
    jocomakerspaceMrBulp

    Reply 4 months ago

    Hi MrBulp,
    Thomas says he will look into it and get back to you soon!

    0
    None
    OculumForamen

    4 months ago

    Your instructable is really good, one thing though, you don't have the Pi camera listed in the parts. Are they including a Pi camera when you buy a Pi 3B or 3B+? I'm also fairly sure you could use a Pi 2B+ and a 3rd party touch screen, you would just have to make sure you have the Drivers, right? Let me know if I'm in error on this. Love the way you set up the camera. You could have the camera connected by wires to the printer, say in a case with a cover? So you can take pictures with the Pi and camera assembly, and the printer is in it's own case protected from the elements while it print thems off?

    1 reply
    0
    None
    jocomakerspaceOculumForamen

    Reply 4 months ago

    Hi there OculumForamen!
    We forgot to list the Pi Camera Module in the list of materials, and are adding it in.
    You should be able to use a Model 2B+ and a third party screen, as long as you have the necessary drivers: we just like the official Pi Foundation screen.
    You can connect the printer to the Pi however you like, as long as it is correctly connected.
    Thanks for your comment!