Arduino, PHP, LCDs, XBees: Tactical Texting in Public Spaces
While the adventure in working on this project began months ago, I’ve finally sorted through the mess of files I made and put it all together in a nice handy zip folder. Using Arduinos, XBees, LCDs, and PHP, this project was challenging from a technical stand-point, but I think the project is now at a place where it can act as a foundation for a number of other projects I’m hoping to take on.
While the most-recent installation of this project was on view as part of SRSI, I’m already looking at the Arduino-TVOut library dreaming of what to do next.
Certainly, it’s no surprise that I really, really like working with text. I think there’s something about text that allows an accessibility to the work that isn’t always possible with an exclusively image-based presentation. So, while I had some loftier ambitious at the start of this project, it was actually the process of running into those walls that helped me to move this project into something that is more flexible and expansive (in the long-run).
I think there’s a lot of strong potential for this project — it’s possible for these to be battery-operated (though in my tests, you won’t get a hugely long run out of them), and even if you are tethered to a wall-based power source, you can still install these in a variety of situations. Being able to dynamically insert messages into public space is very fun and as this project continues to develop, it could provide the groundwork for a lot of new tactical activities.
Should you like to take on a similar project, I’ll detail the hardware/software requirements, code, and some general details below…
As for the installation in the storefronts on Pelissier, I hung the LCDs from their power cable.
Behind a desk was the MacBook and XBee sending out the text-data wirelessly to these LCDs. It’s a bit crude, but elastic bands and a small bread board was all that I needed to keep this together.
You can see the power cable doubled as a hanging mechanism. Given the size of the screens, I think it helps a bit to have all of the cables and hardware visible to help it stand out a bit more. Perhaps having hundreds of screens together could help (something similar to Listening Post by Mark Hansen and Ben Rubin?), but the resources required for that are beyond me at this time.
For the installation at SRSI, the screens displayed a series of “…and then the city” texts, pulled from a simple text file.
The screens were more visible behind some glass than others, but the physical distance between them actually made it so that you would see a different text by the time you reached each one as you walked between them.
The software can also grab an RSS feed and display that, although it gets a bit iffy if the character length is greater than something around Twitter’s 140 characters. Mostly this is due to my likely poor logic skills when writing the PHP code that would wrap the words appropriately.
Behind the glass, somewhat annotated by (or perhaps annotating) some of Thea’s project. Perhaps most important technical thing to note in terms of the PHP is that the LCDs will not wrap lines in the middle of words. However, when getting RSS feeds, it won’t display URIs at all, as they may be fairly useless on a screen like this.
This particular installation ran without any problem for 3 or 4 days straight, so it’s very stable. It seems that the LCDs that were stationed around the 100′ mark were a bit finicky, not always receiving the text. It would have been nice to setup a type of mesh network between the XBees, but trying to configure them on OS X proved essentially impossible.
Download TacticalTexting.zip
Here are some important notes when considering a project like this (that is, using PHP for a serial interface, working with XBees on OS X, and trying to wrap lengthy texts on an HD44780-based LCD.
The 4-line LCD wants to wrap text as follows: Line 1 to Line 3, Line 2 to Line 4. There are a number of LCD libraries for Arduino out there, and one may have very well already figured this out, but if not and if you happen to use the basic LiquidCrystal.h library with a 4-line LCD, then you’ll have to do something similar to what I did in my Arduino script. Using case breaks in the Arduino code, I basically manually guided the LCD to write in the correct order: Line 1 to Line 2 to Line 3 to Line 4. It used a character that the PHP script would insert to make those line breaks. PHP would measure a line and attempt to wrap text appropriately, without breaking up the words.
Configuring XBees on OS X is an exercise in frustration. It’s been done, but I didn’t have any luck using any of the tools, tips, or tricks. It may be my aging MacBook Pro, or the fact that I’ve done a System Migration from an even older MacBook, but for whatever reason, I could not configure the XBees. Thankfully, by default, the XBees would work and talk to one another, but only in the basic send/receive setting.
On the Arduino, you have to disable the auto-reset by basically routing from the 5V power to the RESET pin on the Arduino with the 120 OHM resistor in between. That is, you have to do this on each Arduino+XBee+LCD setup you have, so that they can continually be open to receiving Serial data.
And, if you’re really having difficulty in making something like this work, you may want to check how you’re addressing the Serial port in the PHP file — you may have seen examples as /dev/tty.usbserial-xxxxxxxx, but you might actually want /dev/cu.usbserial-xxxxxxxx.
So, overall, I think that all of this research has actually become a useable foundation for other upcoming project ideas. I’m glad that it’s flexible in that it can read from RSS feeds and text-files, and with that, it could easily be updated to read emails, web-pages, etc. The one element that has continued to elude me is the integration with SMS, although using something like FrontlineSMS may be the answer, though inevitably, the incoming part of any of these SMS systems is the expensive and confusing part.
And, for the sake of making this refernece as usable as possible, here is the entire annotated bibliography I put together for this project:
http://www.arduinoprojects.com/node/13 (for whatever reason, this was the most successful wiring setup, though I have my suspicions that I messed up the contrast at some point due to my shoddy and impermanent wiring)
http://arduino.cc/en/uploads/Tutorial/lcd_schem.png (a diagram for the wiring setup recommended on the Arduino site)
http://www.jamie.net/tag/arduino/ (a quick example of using the 4-bit LCD library, I haven’t tried it)
http://dawes.wordpress.com/2009/12/23/twitter-to-lcd/ (interesting project connecting twitter and Arduino)
http://blog.tinyenormous.com/2008/12/02/arduino-based-rss-reader-with-lcd/ (lots of interesting projects, hooking up Arduino + Twitter and Gmail + Arduino using Python)
http://www.alfonsomartone.itb.it/kwztcq.html (some helpful troubleshooting stuff)
http://www.arduino.cc/en/Reference/AnalogWrite (analog write, I used this to correct the contrast problem I had)
http://arduino.cc/en/Reference/LiquidCrystal (LCD library for Arduino)
http://www.ladyada.net/make/pumpkin/pumpkin.html (great idea for introducing a distributed urban surface sound project)
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?action=print;num=1181079252 (solar-powered Arduino help)
http://www.adafruit.com/index.php?main_page=product_info&cPath=35&products_id=172(range finder)
http://www.adafruit.com/index.php?main_page=product_info&cPath=37&products_id=198 (the LCD screens I got)
http://clete2.com/2009/11/control-lcd-text-over-web-interface-arduino/ (controlling LCD over web)
http://www.arduino.cc/playground/Interfacing/Processing (Interfacing Processing and Arduino)
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1255733236 (Process + Serial + LCD to display Tweets)
http://itp.nyu.edu/physcomp/Labs/SerialOut (some tutorials on physical computing)
http://drewish.com/content/2009/06/simple_arduino_serial_communications (simple serial communications)
http://www.akeric.com/blog/?p=1015 (arduino / processing / python)
http://dorkbotpdx.org/blog/kmat/serial_lcd (serial –> LCD … this is making more sense now, using case breaks to look for specific characters to insert a function, such as starting a new line)
http://blog.datasingularity.com/?p=50 (control arduino through html)
http://stackoverflow.com/questions/899098/arduino-serial-reading (arduino serial reading)
http://www.ipipi.com/ContactUs.do (potential sms forwarding to email option)
http://www.ipipi.com/help/ipipi_in_out.htm (this is what I would need to receive messages, not as simple as a number, but maybe the best way to avoid having to get another phone number, I should also ask about a potential shortcode)
http://docs.upsidewireless.com/index.php?title=MO_HTTP (notes on how to bring sms messages into an application using HTTP POST)
http://www.upsidewireless.com/how_virtual_sms_works.htm (this is the kind of service I’ll need for this project … SMS messages forwarded to email or accessible through HTTP requests … with the possibility of getting a Windsor-based number AKA longcode)
http://www.mydarkmaterials.co.uk/2008/11/interfacing-php-with-the-arduino/ (this is an example of interfacing PHP Serial with Arduino, and I suspect old enough that many of the problems the author ran into aren’t there any longer … maybe it’s been silly of me to ignore PHP … I actually have a decent idea of what I’m doing there)
http://www.procata.com/blog/archives/2007/10/28/working-with-php-5-in-mac-os-x-105/ (helpful to get PHP running properly on 10.6)
http://opensourceprojects-torchris.blogspot.com/2009/09/arduino-pop3-email-checker.html(maybe or maybe not useful in some capacity, using arduino to check email)
http://www.arduino.cc/playground/Learning/SparkFunSerLCD (serial commands)
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?action=print;num=1192470251 (word wrapping in Arduino)
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1252901403/4 (word wrapping more)
http://www.sparkfun.com/commerce/categories.php?c=66 (ideas from Mike Beauchamp)
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1227581530/0 (ideas from Mike Beauchamp)
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1264895784/9 (serial communication with PHP)
http://www.tizag.com/phpT/php-string-strpos.php (string position tutorial)
http://www.arduino.cc/en/Tutorial/TextString (potential to use Arduino rather than PHP for string manipulation)
http://www.tizag.com/phpT/fileread.php (open a text file and read data from it)
http://veritrope.com/tips/export-apple-mail-messages-and-notes-to-text-files/2 (export mail messages to text file)
http://www.tech-recipes.com/rx/878/check-google-e-mail-gmail-from-an-rss-feed/ (check gmail as rss feed)
http://googlesystem.blogspot.com/2008/03/feed-for-unread-gmail-messages.html (more info on gmail rss feeds, needs feed authentication)
http://davidwalsh.name/gmail-php-imap (php + imap + gmail output)
http://g33k.wordpress.com/2009/02/04/check-gmail-the-python-way/ (gmail + python)
http://www.hashbangcode.com/blog/disemvoweling-php-function-1077.html (disemvoewling PHP)
http://www.tizag.com/phpT/filewrite.php (tutorial on writing files in PHP)
http://www.tizag.com/phpT/filewrite.php (tutorial on writing files in PHP)
http://www.w3schools.com/PHP/php_file.asp (tutorial)
http://www.linuxquestions.org/questions/programming-9/php-read-file-line-by-line-and-change-a-specific-line.-523519/ (some ideas on alternative ways to read files line by line)
http://www.php-learn-it.com/php_files/php_file_read.html (tutorial)
http://www.ibm.com/developerworks/library/os-php-readfiles/http://magpierss.sourceforge.net/ (parsing RSS with PHP magpie library)
http://www.olate.co.uk/articles/view.php?id=214 (basic Magpie RSS tutorial)
http://www.iknowthe.net/blog/arduino-twitter-lcd-doorsign.html (another example of LCD + Twitter + Python)
http://missionduke.com/arduino-projects/ (some other PHP projects, with some questions about the Serial Monitor problem)
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1262928238 (PHP + Serial pin reset problem)
http://www.arduino.cc/playground/Main/DisablingAutoResetOnSerialConnection (Disabling auto reset on a serial connection on the Arduino)
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1236198283 (wireless LCD Arduino project)
http://rapplogic.blogspot.com/2009/05/arduino-xbee-portal.html (Arduino + LCD + XBee)
http://www.hashbangcode.com/blog/disemvoweling-php-function-1077.html (disemvoweling PHP function)
http://blog.soundsorange.net/2006/08/29/arduino-getting-the-usb-version-up-and-running-on-osx-using-pd/ (distinguishes between cu and tty)
http://hyperradiant.net/blog/2009/02/sending-serial-commands-to-xbe.html (set up XBee in terminal, OS X)
http://www.digi.com/support/productdetl.jsp?pid=3434&osvid=0&s=367&tp=3 (XBee read-me)
http://antipastohw.blogspot.com/2009/01/xbee-shield-to-xbee-shield.html (setting up two Xbees)
http://www.youtube.com/watch?v=-U8fxOf8JA8 (wireless LCD, sends via an XBee to an XBee connected to Arduino / LCD)
http://www.ladyada.net/make/xbee/wiring.html (instructions that explain the XBee shield)
http://www.ladyada.net/make/xbee/point2point.html (basic point-to-point networking, sending messages using softserial)
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1229180251/10 (tool for configuring XBees)
http://teenybreeny.wordpress.com/2009/04/12/xbee-going-wireless/ (more XBee configuration)
http://www.arduino.cc/en/Guide/ArduinoXbeeShield (XBee shield info, not what I’m using, but still helpful)
http://www.faludi.com/projects/arduino-and-xbee-battery-test-results/ (battery tests with Arduino + XBee ***important***)
http://www.kobakant.at/DIY/?p=772 (XBee Serial Communication)
http://forums.trossenrobotics.com/tutorials/how-to-diy-128/xbee-basics-3259/ (basic XBee tutorial)
http://hcgilje.wordpress.com/resources/xbee_arduino_code/ (tutorial, shows timed “waking up” and some unfolding of data packets)
http://www.youtube.com/watch?v=7A7coLAUyfQ (wireless temperature sensor, XBee, Arduino + solar)
http://www.glacialwanderer.com/hobbyrobotics/?p=15 (PHP, XPort, Arduino)
http://www.flickr.com/photos/35434449@N08/4324916783/in/pool-adafruit (basic how-to photo for soldering 9v Arduino battery adapter)
http://www.ladyada.net/learn/lcd/charlcd.html (reminder on how to hook up LCD to Arduino)
I would like to thank the Canada Council for the Arts for their generous support.
Related posts:
Friday afternoon turned ou...
Not that we don't already ...
I'm starting a new project...
Around the maps, we're beg...









![New Friends Across the Border: Visiting 555 Yesterday, Lee Rodney (Research Director of the Border Bookmobile) and I headed on a short 4km journey. We visited the fine folks at 555, a volunteer artist-run arts organization providing affordable studios and workspace, gallery space, exhibition programs, arts education programs, and an artist in residency program. We met at their temporary location, while they [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/01/WindsorDetorit-BCL-555-150x150.jpg)

![Quick Update: LEDs Survived, Postcards are Being Distributed! Just a quick update…the LEDs in the freezer are still going strong, more than two days later, which is good news for any potential LED-embedded ice or snow project. The glow was way more exciting than this photo makes it appear, as I had assumed the battery wouldn’t have lasted this long at all. Finally had [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/01/IMG_6546-150x150.jpg)
![9:30pm tonight, an open conversation on the walls of city hall, you’re invited It would be great if you could come. We’ll be at 350 City Hall Sq West, across the street from Charles Clark Square at 9:30pm. We’ll have a projector and a bunch of bristol board. We want to look at what public consultation could look like and how we might imagine the changes we want [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/06/bcl-citycounsel-150x150.jpg)
![Snow, LEDs, Flights, Fill-in-the-blanks, Proofs, and Postcards Meeting twice in a week is awesome. I can’t say that enough. So much time makes us way more productive and makes it a lot easier to be OK with not having everyone there all the time. First on the list, doing some really, really quick tests of the potential of embedding LEDs in ice [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/01/IMG_6483-150x150.jpg)

![BCL Report: February 4, 2011 (Repairs and Reviews) A Friday with everyone around the table usually translates into a lot of excellent new ideas, and yesterday was no exception! We spent the evening reviewing the progress we’ve made on some initial research and may have sparked an entirely new direction for the project. All of the excitement is after the jump! Michelle has [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/02/IMG_8611-150x150.jpg)
![Quality Time with Books & Imaginary Spaces Friday night was especially fun. With next week being our first research report for How to Forget the Border Completely, we basically spent the evening casually going over some preliminary research, planning out some new directions, and getting more acquainted with the collection of border books next door. Michelle brought a tourism Detroit magazine she [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/01/IMG_8505-150x150.jpg)
![Homework Prep! Resampled Notebooks We’re gearing up for Homework. It’s going to be fun and you should really consider attending! There’s a few spots left. If you do decide to attend, you can look forward to receiving one of these fine sketchbooks. Designed by Liisa Salonen, the sketchbooks are recovered paper sample books, rewrapped. They still need to be stamped, maybe [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/10/IMG_4871-150x150.jpg)
![New Exhibition: Unrest Everywhere (Tools for Playing with Halifax) Just back from an incredible week installing at Eye Level Gallery for our show, Unrest Everywhere (tools for playing with Halifax), which runs until May 12, 2012. The show features a number of multiples and interactive works, all of which are yours for the taking and borrowing. The premise for the show was to create [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2012/04/IMG_7792-150x150.jpg)
![SRSI, Day 12 &13: Tactics, Presents and Garden Party Plans Lea Bucknell arrived from British Columbia to take over the window display of 424 Pelissier, Andrea Carvalho sent pictures of her last tactics in Windsor from Montreal, and SRSI participants get a surprise gift from a local fan. During the last few days of Andrea’s residency, she performed public interventions at bus stops and inside [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/06/DSC_0660-150x150.jpg)
![Border Interviews: Kero To get a jump start on laying the groundwork for our upcoming How to Forget the Border Completely project, we have decided to interview a small group of individuals who may be considered “experts” of the Windsor-Detroit border in some way. Kero, a musician/graphic designer/video artist, was our first candidate for a video interview. He [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/02/04-copy-150x150.jpg)
![New Project Soon (Keep Your July Open) Not that we don’t already have our hands full, but seeing as it’s nearly March, we’re starting to look ahead to summer time activities. These activities might be somewhat related to this ongoing conversation we’ve been having on the blog. We’ll be posting more information soon, but for now, just know that if you’ve been [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/02/srsi-screenshot-poster-150x150.jpg)
![“Alive & Well” viewable on Google Maps Our project for the 2011 Windsor Biennial, Alive & Well, was created with the hope that it would be captured on Google Maps to make a monument or announcement of sorts to the rest of the world about Windsor as we near the end of the year and ahead of being torn up for the new Aquatic [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/12/aliveandWellscreenshot-2-150x150.jpg)
![Things Worth Saving The details: Sunday, April 11th via email & Tuesday, April 27th at 7pm, at Artspeak Gallery. As part of the Broken City Lab: Save the City project, Broken City Lab is inviting Windsorites to venture out into the city and take five photographs that showcase what makes our city “worth saving.” These photographs will be turned into [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/03/BCL-STC-APR-5x7-outlines-sm-150x150.jpg)
![Phone Calls and Budgets – Tuesday Morning Productivity Extravaganza Tuesday felt like the first day back from the holidays should. We were tired, well Josh and I were tired, we were motivated and anxious to get to work, and we got a lot done. It was a very great way to start the new year! We spent the better part of the morning and [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/01/IMG_62542-150x150.jpg)
![Brainstorming Community Gardens Darren, Josh, and I met with some folks from the Sandwich Community Health Centre and Maya from FedUp to start discussing community gardens. The meeting went well, serving as a good starting point to start figuring out what we might be able to do in Sandwich. The SCHC is working on a site on Prince Road, [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/02/communitygarden-aerial-150x150.jpg)
![Math, Markers, and Measurements + Eric’s micro-documentary We spent last night watching a rough cut of some of Eric’s ongoing micro-residency project, did a lot of measuring, used Google Earth, did some math, drew some diagrams, and brainstormed a new project (because Cristina wants to sew, a lot). With the semester basically over now, we’re hoping to wrap up a couple things [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/12/IMG_6230-150x150.jpg)

![SRSI, Day 25: Bookmobile & Friendly Services Monday saw the last new residents move in to the SRSI spaces; Lee Rodney’s Bookmobile Reading Room and Emily Colombo’s friendly services. To get footage for the SRSI documentary, Daragh followed Norman around, who was on his A game all day. Norman’s logs present a personal perspective on his security guard experiences. Lee Rodney arrived [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/07/IMG_1470-150x150.jpg)
Great post Justin. This is a heap of resources that would all be useful. That tvOut extension appears to be an area of great potential.
Im going to be delving a lot into arduino technology in the upcoming semester so you wont be alone.
Im also going to explore the textile side with the lilypad arduino and the potential for interactive clothes or materials.
Thanks, Stephen!
Glad to hear you’ll be continuing your adventures with Arduino, and that Lilypad stuff has a ton of potential.
Keep me posted, we should play.
I will. I have been researching some of it’s potential. You can see a rescent article in Bitch Magazine that talks a bit about certain social implications of “smart” technology and what is happening: http://bitchmagazine.org/article/making-geek-chic
Thanks Stephen, I shall have a try, But I am still puzzled on how it is accomplished?