For fun and enjoyment I’ve built an Android/RaspPi based twitter printer, just because I could. This is a little bit of documenting the experience and sharing. Not a beginner build as these aren’t step by step instructions and assume you know enough about linux, python, etc to be able to put this together.
So if you fancy printing your tweets from your Android phone then here’s what you’ll need:
1. A thermal till receipt printer (Epson TM-P88IV serial for £30 off eBay)
2. A Raspberry Pi + SD Card combo
3. USB Wifi Dongle
4. USB Serial port + Cables (Printer is serial, I loath RS232, so messy)
5. An Android Handset (My trusty Nexus 5)
Some of this junk I had lying around in cupboards and some was purchased on the cheap on eBay.
Setting up the Pi, I only had an old 2GB Micro SD and so used the build here: https://minibianpi.wordpress.com/ it only uses about 600MB but after I’d reloaded packages for Python, etc I’m using about 920MB of the 2GB card, still better than having to buy another SD just for this. ( Just in case I forget the default user is root and the password is raspberry.) Follow the instructions and get the Pi Working.
Be very careful buying the USB Serial adapter, my life was made hell by a “QinHeng Electronics HL-340 USB-Serial adapter”, cost £2.50 off eBay and gets detected/installed for Linux automatically but just doesn’t work, it outputs rubbish and wastes tons of paper and also wasted 1/2 a day of my time debugging it. Just google “HL-340 linux driver” and you’ll see it’s been broken for around 6 years by the look of it and nobody has bothered to fix it (Me neither), the provided windows drivers work just fine though! So in the end I dug deeper in the crap pile and found an old FT232 based one and that works just peachy. Some of this is why I loath RS232. If you have a windows machine around you hook the printer up to that with the provided python script. All the Pi/WiFi/Serial combo is doing is hooking the serial printer to a UDP socket that Android can talk to over WiFi (or bluetooth).
The python script (tcp_serial_redirect.py) is a hack of a script found here, I’ve stripped out the return path as we’re only sending to the printer to make life easier.
The python files are attached for your hacking usage, fun, twitter printing.
There are plenty of instructables out there on how to make a wifi dongle work with a Pi.
Once you’ve got the Pi or whatever cheapo network going you can then cat some ASCI to /dev/ttyUSB0 or whatever and watch the printer spew it out. Put the python/shell scripts into /usr/sbin and link to cron to start on boot. Do “crontab -e” and add:
@reboot sh /usr/sbin/proxyPrinter.sh /dev/ttyUSB0 >/tmp/proxyPrinter.log 2>&1
Now whenever your pi boots the printer proxy will run.
The next part of getting this all together took somewhat longer and I really quite enjoyed messing with and that was writing a twitter4j based Android application. There are some screenshots below and if you want a copy of the app in the short term then email me at kate at …. and I’ll send the APK to you, in the longer term it will probably get uploaded to the App store but maybe not as its a real specialised/narrow/small group of nerds like me that are interested anyways, ask and I’ll send. Its not too hard to use, the styling leaves a lot to be desired but its not a priority at the moment. Screenshots below:
Sorry but comments have had to be disabled due to endless comment spamming, drop me a line at kate @ …. if you like the project. Thx