Printing to a Polaroid Pogo printer from any device via dropbox on Windows

So I’m currently planning my wedding, so it’s only apt that I talk about one of the mini projects that I’ve been working on. It involves a little Bluetooth printer, and difficulties in printing from iOS devices.

The back story:

I’m getting married this summer, and came up with idea of having a small photo printer that people could use to print selfies, or whatever, to stick into the guestbook. I got the idea from a wedding I went to a couple of years back where they had a Polaroid instant camera and a glue stick. This is a techier version of that!

So I came across the Polaroid Pogo and it fit the bill quite well – it prints small, glossy photos, around 75 x 50 mm; it uses thermal ‘zink’ paper, so there would be no worries of ink running out on the day; and, best of all, the photos are self adhesive, so the guests will be able to peel the back off an stick them straight into the book.

They also go for around £30 – £40 on eBay because their Li-Po batteries die, but they’re perfectly usable plugged into the mains.

The only problem is connectivity. Photos can be printed via PictBridge using a USB cable (as pictured) or via Bluetooth using the OBEX file sharing protocol – neither of which iOS devices support. After a quick search I found a couple of tutorials alluding to workarounds, so I bought one anyway.

The workarounds

So there are a couple of ways of getting around this. There are apps that you can download for iOS that claim to be able to do Bluetooth file sharing, but they seem to require jailbreaking and, besides which, I didn’t want to ask my guests to download anything just to get it to work. I wanted to be able to leave a simple, A4 instruction sheet telling people how to get their snaps out.

Another option is to use mail rules and apple scripts to print from an email . This is a great idea, but it’s a little clunky and I don’t have an Apple machine, so I’m not even sure if you could replicate it on a PC.

Luckily, a guy called Brendan Dawes came up with an idea to use Apple Scripts to pick up files from a Dropbox folder an print them to the Pogo.

I liked this idea because it meant that I could have a shared folder that people could shove photos in, and have the printer working away one at a time. I just needed to replicate the process for a Windows machine.

Sharing files via DropBox used to require that everyone wanting to put files in a shared folder had a DropBox account. Luckily, this year, DropBox introduced a new feature called file requests, which allows anyone to upload a file to a shared folder without even having an account. Even better, they can’t see the contents of the folder, they just have an upload button.

I went down a few dead ends, trying to find a simple way of sending files via Bluetooth on Windows. It isn’t as straight-forward as it is on OSX. I naturally looked at C, then C#… there’s a library for C# by 32feet.NET, but my C# skills are rusty to say the least, and I didn’t really want to spend too long on this.

So I thought, on the off-chance, I’d look for a set of command line tools for Bluetooth and (lo and behold!) I found some at http://bluetoothinstaller.com/bluetooth-command-line-tools/ . Once installed, these tools allow you to pair with a Bluetooth device, and send files to it straight from the commandline

Perfect. All I needed was a batch file that searched for files and sent them to the printer.

This gives me a very simple workflow:

  • Guest goes to a short url or scans a QR code
  • They are presented with a ‘choose files’ button
  • They choose their photos, fill in their name and email address (DropBox make you do this so they can send you a confirmation email)
  • Photo goes to dropbox
  • Laptop syncs folder
  • Looping batch script picks up file and sends it to the printer
  • File is moved to a ‘done’ folder, so we have a digital copy of all photos after the wedding

My batch scripting is probably rustier than my C#, but after hitting Stack Overflow several times, I came up with this beauty:

@echo off & setlocal

echo.
echo.
echo Print to Polaroid Pogo script
echo Scans source directory for new jpg files, and prints any that appear
echo Requires bluetooth command line tools from
echo http://bluetoothinstaller.com/bluetooth-command-line-tools/
echo.
echo.

:INIT
	echo working in %~dp0%
	set doneFolder=%~dp0%\done
	set deviceName="Polaroid 1b 16 02"
	set devicePIN="6000"

	if not exist "%doneFolder%" md "%doneFolder%"
	if not exist "FilesList.log" type nul > "FilesList.log"

	echo.
	echo.
	echo checking bluetooth configuration...
	btinfo

:TRYPAIR
	echo.
	echo.
	echo Pairing with %deviceName%...

	::-n needs to match the name as it apears in Device Manager -p is the pairing pin code
	btpair -n%deviceName% -p%devicePIN% && (
		echo done.
		goto SUCCESS
		(call )
	) || (
	::Hacky error handling is because the bluetooth tools don't set ERRORLEVEL properly
		echo.
		echo.
		echo unable to pair with %deviceName% - check everything!
		goto TRYPAIR
	)

:SUCCESS

	echo.
	echo.
	echo Scanning for files (press Ctrl+c to quit)...

:MAIN
	set stamp=%date:~-10% at %time:~0,8%
	set cnt=0

	:: Count the number of files in the folder - add file extensions here to support other formats
	for %%j in (*.jpg *.jpeg) do (
		set newfile=%%j
	    	set /A cnt+=1
	)

	if %cnt% gtr 0 (
		echo.

		if %cnt% equ 1 (
			echo 1 file waiting in queue
		) else (
			echo %cnt% files waiting in queue
		)

		echo.%stamp% sending "%newfile%" to printer...

		btobex -n%deviceName% "%newfile%" && (
			:: Files are moved to \done when they print successfully
			echo moving "%newfile%" to the "done" folder
 	   		copy "%newfile%" "%doneFolder%" > nul
	   		del "%newfile%"	

	  		echo.%stamp% %newfile%>> "FilesList.log"
			(call )
		) || (
		::More hacky error handling for the same reason as above
			echo unable to print - does the printer have paper? maybe we're not paired any more
			goto TRYPAIR
		)
		goto SUCCESS
	)

goto MAIN
::loops forever

I made sure that all paths are relative, so there’s nothing to configure there, it will work in any folder you put it in. The only thing to configure is deviceName, which you can find through Device Manager in Windows.

I’ve only tried this with jpegs, but it may work with other files – just add the extension to the filter on line 57.

One thing that tripped me up was that, contrary to the documentation, Bluetooth Commandline Tools don’t always set the ERRORLEVEL variable. In cases where the printer is switched off, or out of paper, it will happily return a non-error value, which would result in the loss of files.

Stack Overflow came to the rescue, and I found this (rather hacky, but it works) technique to catch errors.

This works perfectly. The batch file is run from the folder you’re expecting the files to appear in and, as long as you have an internet connection and dropbox set up to automatically sync, printing is almost instantaneous.

Roll on the big day when I can try it out for real!

Advertisements

6 thoughts on “Printing to a Polaroid Pogo printer from any device via dropbox on Windows

    • Hi, glad you found it useful. I did find when it was running we had some files left in dropbox that weren’t printed. Maybe that was why. At the time I was too busy being married to care :)

  1. Congrats on the wedding :)
    I wonder if there’s a code line that can make file names shorter. I’ll look into it and update if I’ll make it :)

  2. Amazing, thank you so much for sharing this process.
    Ive been looking for a way to print to a zink printer form windows for quote some time. ideally via wifi so I can pool multiple printers.

    1. Do you know if its possible to connect a few printers via bluetooth and have them pool to speed up the printing?

    2. Do you know any zink printers which can print directly from windows pc via usb?

    Thanks so much for the help
    Stu

    • Hi thanks for your comment. In answer to your questions:

      1. I’m not sure, the device name of my printer is “Polaroid 1b 16 02”. If the last part is a unique ID, I can’t see why you couldn’t modify my script to connect to more than one printer. The only difficulty I could see is you don’t get a status back from the printer, so it would be difficult to know which ones were printing and which were available.

      2. If I remember correctly, the Pogo supports PictBridge printing, so you can plug it straight into a camera. If you could find a library to run this from a PC, then you’re away. I think I had a look and couldn’t find one, but there might be something out there. Other zink printers might act as a normal USB printer, I don’t know.

      Let me know how you get on.

Tell me what you think...

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s