A camera that prints poems of what it sees.
We started this project as newcomers to the world of hobby electronics. The following instructions are intended for complete beginners, as we were. We simplified some of the design to optimize for easily sourcing and assembling parts; as a result, it's less compact than our photographed versions. If you are comfortable with electronics and coding, we encourage you to experiment and remix even more.
⚠️ These instructions are still in progress. ⚠️ Try it out and let us know what's confusing, or doesn't work.
Raspberry Pis are simplified computers. They are lightweight, cheap, have limited processing power, and are more fragile than typical consumer electronic devices. It's very sensitive to the specific power sources you use — too much power and you'll fry the part, too little power and the software won't run. You also have to manually shut down the software before unplugging the power, to protect the software from being corrupted.
We chose the Pi Zero 2 for its balance of processing power (Pi Zeros are too slow) and compact size (most other Pis on the market are larger). The wire diagrams in this tutorial will apply to all Raspberry Pis, but there may be differences in software and camera compatibility, especially with older devices. We've tested this with a Pi 3b+ and it works fine, but a Pi 4 probably requires too much power to make it a viable portable solution.
Raspberry Pi Zero 2 is often sold without headers (those 2x20 black metal connectors). The headers let you easily connect the Pi to the printer and buttons with plug-in jumper wires. If you buy the Pi without headers, you'll need to separately buy a 2x20 header and solder them on yourself. If you don't want to solder, you can use hammer-on headers and this installation rig.
Raspberry Pis are also recovering from a supply shortage. Check rpilocator.com for live stock notifications on standalone parts (does not list accessory kits).
Mostly straightforward, but be careful of damaging the hardware. The Raspberry Pi camera is delicate and can be easily fried via static. We broke 3 cameras in the process of making this project. Just make sure to always store it in a static-shielding bag when you're not using it.
If you are connecting the camera to a Pi Zero 2, note that the Zero 2's camera connection collar is also very delicate. We broke a Pi Zero 2 camera collar in the process of making this as well and had to just get a new Pi 🥲
We have not tested these instructions with older models of Raspberry Pi cameras.
We used the Adafruit thermal printer line for this project, but they have subsequently been discontinued. Similar printers exist on Amazon and Aliexpress; the ones we've bought work with the same printer drivers (which are also no longer maintained by Adafruit, but still seem to work).
The Nano Thermal Printer or Tiny Thermal Printer are more compact, but have slightly different wiring.
The important thing is that the thermal printer has a TTL serial connection so you can easily connect it to the Pi. Search "TTL embedded thermal printer" on Amazon or Aliexpress to find your parts.
Similar receipt printers on Amazon:
Receipt printer accessories:
If you want your camera to be portable, you'll need some batteries! The Pi requires a steady 5V of power @ 1.2A, while the printer needs 5-9V and draws ~2A while printing.
Recommended power supply: 6xAA batteries
It's not the lightest solution, but it's a beginner-friendly starting point. - 6 x AA battery holder with DC plug - 6 x AA batteries — rechargeable NiMH batteries (e.g., Eneloop) provide 7.2V, non-rechargeable alkaline batteries (e.g., Duracell) provide 9V. Either works. Of course, don't mix batteries! - In-line power switch for DC barrel jack to control flow of power to circuit - DC wire terminal block to connect batteries to circuit - Step-down (buck) converter — 5V @ 3A output steps down the battery voltage to 5V for the Raspberry Pi - MicroUSB shell to power the Pi, or cut open a MicroUSB cable - Soldering iron
Other solutions that could work: - Put the above circuit on a PCB so you just need to plug in the connectors instead of soldering — we did this for our project! Will upload gerber files in the future. - 7.2V lithium batteries, e.g. 2x 18650s - 7.4V NiMH batteries for RC cars - If you don't need it to be super portable, get a portable power station to plug in the Pi and printer - If you don't want to solder, you could power the Pi and printer through two separate batteries. However, we've run into overheating issues with the commonly-recommended PiSugar 3 battery.
Power supplies that DON'T work: - Typical 9V alkaline batteries do not work as they do not provide enough current - Standard phone banks don't provide continuous power to the Raspberry Pi, causing it to shut down after a few minutes - Just plugging both devices in to a single 5V power bank — it can't handle the current draw while printing. Either the Pi shuts down during printing, or the printer doesn't have enough power to print.
Any LED + momentary pushbutton will work for the shutter button. We use the LED as a status indicator for things like ready, loading, etc.
This code currently uses OpenAI's models to turn the image into a poem. It also uses thermal printer drivers from Adafruit's thermal printer Python library.
You'll need to get your own OpenAI account & API key. Each request costs a couple of cents.
Currently, the main.py script running on the Pi:
- Takes a photo when you click the shutter button
- Sends the photo to GPT-4 Vision to caption the photo
- When we receive the caption, we ask GPT-4 to turn the caption into a poem
- When we receive the poem, print the poem out on thermal receipt printer
This was adapted from the following tutorials: - Instant Camera using Raspberry Pi and Thermal Printer - Networked Thermal Printer using Raspberry Pi and CUPS
Connect your Raspberry Pi to your Camera module.
Insert your SD card with a fresh install of any Raspberry Pi OS onto the Pi.
Connect your Pi to a monitor via mini HDMI.
Plug in power. You should see a green light on the Pi, and a start-up screen on the monitor.
Once the Pi is on, open up the Terminal on your Pi to start making changes.
Set up Raspberry Pi hardware to take Camera & Serial inputs:
sudo raspi-config
You'll want to adjust the following settings:
Restart the system as needed.
[Tutorial TODO: include a basic camera test script & show desired behavior]
$ sudo apt-get update
$ sudo apt-get install git cups build-essential libcups2-dev libcupsimage2-dev python3-serial python-pil python-unidecode
$ cd
$ git clone https://github.com/adafruit/zj-58
$ cd zj-58
$ make
$ sudo ./install
$ cd
$ git clone https://github.com/carolynz/poetry-camera-rpi.git
Set up your thermal printer, connecting it to power and your Pi. See diagram and instructions in this tutorial.
Test that it works. Pay attention to your printer's baud rate (e.g. 19200). We will use this later on.
Open our `poetry-camera-rpi
$ claude mcp add poetry-camera-rpi \
-- python -m otcore.mcp_server <graph>