Matt Richardson

Creative Technologist

Printing photos wirelessly with Raspberry Pi and a LG Pocket Photo printer

Wireless Photo Printing from Raspberry Pi

The LG Pocket Photo printer (model PD233) is a Bluetooth-enabled wireless photo printer meant for printing small 3" x 2" photo prints which are sent to it from a proprietary mobile application. Despite the fact that the mobile app is proprietary, the printer simply accepts files via Bluetooth file transfer and automatically prints them out.

If you equip a Raspberry Pi with a USB Bluetooth adapter, you're able to print photos from the Raspberry Pi directly. This is fantastic for photobooth projects or custom Polaroid-like cameras. If you're not already familiar with how to use a Raspberry Pi, check out Getting Started with Raspberry Pi.

This guide uses:

Throughout this guide, I'm using a fresh install of Raspbian, which was installed with NOOBS. I'm running the following version, but many different versions should work:

pi@raspberrypi ~ $ uname -a
Linux raspberrypi 3.6.11+ #538 PREEMPT Fri Aug 30 20:42:08 BST 2013 armv6l GNU/Linux

Setting up Bluetooth

After inserting the Bluetooth dongle, check to see if it was recognized by the Pi. Do this by executing dmesg on the command line. A lot of text scrolls by, but the most important log entries are at the end:

[  175.722175] usb 1-1.2.3: new full-speed USB device number 8 using dwc_otg
[  176.916559] usb 1-1.2.3: New USB device found, idVendor=0a12, idProduct=0001
[  176.916590] usb 1-1.2.3: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[  177.019917] Bluetooth: Core ver 2.16
[  177.023810] NET: Registered protocol family 31
[  177.023840] Bluetooth: HCI device and connection manager initialized
[  177.023855] Bluetooth: HCI socket layer initialized
[  177.023864] Bluetooth: L2CAP socket layer initialized
[  177.023918] Bluetooth: SCO socket layer initialized
[  177.045934] usbcore: registered new interface driver btusb

The command lsusb is also helpful to see what your system recognizes as connected via USB:

pi@raspberrypi ~ $ lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 2101:8500 ActionStar
Bus 001 Device 005: ID 2101:8501 ActionStar
Bus 001 Device 006: ID 1c4f:0032 SiGma Micro
Bus 001 Device 008: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 001 Device 007: ID 05af:0802 Jing-Mold Enterprise Co., Ltd

That looks like a good sign. The next step is to see if you can see the Bluetooth printer from the Raspberry Pi. Thanks to a hint from David, you'll use apt-get to install the packages bluez, bluez-utils, and obexftp. (As always, run sudo apt-get update first.)

pi@raspberrypi ~ $ sudo apt-get install bluez bluez-utils obexftp

It may take quite a few minutes since there are a lot of dependencies for these packages. That means that bluez, bluez-utils, and obexftp require the resources of other software and code libraries. Luckily for us, apt-get will download the ones you need automatically install them. It wasn't always this easy!

Finding the Printer

When apt-get is done, you have a few new tools. One of them, sdptool is a command line program for browsing Bluetooth devices. You can run the following command, first with the printer off, then with the printer on to determine which device is the printer:

sdptool browse

The idea here is that you want to find the MAC address and channel of the printer so that you can send an image file to it. The MAC address will look something like 00:1F:47:37:7C:02.

If you have a lot of Bluetooth devices nearby, this can kind of be a pain. To make this process easier, try limiting your search by devices that use the OBEX Push service, which is what the printer uses to receive files. Not many other devices use this, so this is a great command to find the MAC address of your printer.

pi@raspberrypi ~ $ sdptool search OPUSH
Inquiring ...
Searching for OPUSH on E0:F8:47:36:AB:C1 ...
Searching for OPUSH on 00:1F:47:37:7C:02 ...
Service Name: OPP
Service RecHandle: 0x10002
Service Class ID List:
  "OBEX Object Push" (0x1105)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 4
  "OBEX" (0x0008)
Profile Descriptor List:
  "OBEX Object Push" (0x1105)
    Version: 0x0100

Failed to connect to SDP server on 00:1E:C2:96:30:D5: Host is down

You can safely ignore that last error if you encounter it. The important thing here is that the line that says Searching for OPUSH on 00:1F:47:37:7C:02 ... right before it spits out all that service information. What happened was sdptool found a few Bluetooth devices in range and then queried each for their available services. The first one was not capable of OPUSH, so it went to the next, our printer, which was. Therefore, the service information is listed after the MAC address.

Printing a Photo from the Command Line

Armed with the printer's MAC address and the channel, you can use obexftp to send a file via OBEX push. Here's how to do it from the command line, assuming you're in a directory where there's a file called photo.jpg:

obexftp --nopath --noconn --uuid none --bluetooth 00:1F:47:37:7C:02 --channel 4 -p photo.jpg

The first three options, --nopath --noconn --uuid none are what allow you to send via OBEX push. Basically, it says you're not going to log in to a particular path on the device, you're just going connect and push a file to it.

--bluetooth 00:1F:47:37:7C:02 is where you'll put your printer's MAC address.

--channel 4 is where you'll put your channel.

-p photo.jpg indicates the name of the file to push to the device.

After executing the command, you'll see some feedback on screen, and the LED around the power button should start blinking. After a few moments, your photo should start printing!

Once you can print from the command line, you know that the set up will work. You can execute this command from any programming language you're using. You can also search around for how people have implemented OBEX in other languages if you want to natively use it within your code.

Printing a Photo from Python

Though I haven't tried it yet, the Python module lightblue has the capability to push files via OBEX.

Photo Tips

Accounting for the bleed