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.


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: (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) (a diagram for the wiring setup recommended on the Arduino site) (a quick example of using the 4-bit LCD library, I haven’t tried it) (interesting project connecting twitter and Arduino) (lots of interesting projects, hooking up Arduino + Twitter and Gmail + Arduino using Python) (some helpful troubleshooting stuff) (analog write, I used this to correct the contrast problem I had) (LCD library for Arduino) (great idea for introducing a distributed urban surface sound project);num=1181079252 (solar-powered Arduino help) finder) (the LCD screens I got) (controlling LCD over web) (Interfacing Processing and Arduino) (Process + Serial + LCD to display Tweets) (some tutorials on physical computing) (simple serial communications) (arduino / processing / python) (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) (control arduino through html) (arduino serial reading) (potential sms forwarding to email option) (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) (notes on how to bring sms messages into an application using HTTP POST) (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) (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) (helpful to get PHP running properly on 10.6) or maybe not useful in some capacity, using arduino to check email) (serial commands);num=1192470251 (word wrapping in Arduino) (word wrapping more) (ideas from Mike Beauchamp) (ideas from Mike Beauchamp) (serial communication with PHP) (string position tutorial) (potential to use Arduino rather than PHP for string manipulation) (open a text file and read data from it) (export mail messages to text file) (check gmail as rss feed) (more info on gmail rss feeds, needs feed authentication) (php + imap + gmail output) (gmail + python) (disemvoewling PHP) (tutorial on writing files in PHP) (tutorial on writing files in PHP) (tutorial) (some ideas on alternative ways to read files line by line) (tutorial) (parsing RSS with PHP magpie library) (basic Magpie RSS tutorial) (another example of LCD + Twitter + Python) (some other PHP projects, with some questions about the Serial Monitor problem) (PHP + Serial pin reset problem) (Disabling auto reset on a serial connection on the Arduino) (wireless LCD Arduino project) (Arduino + LCD + XBee) (disemvoweling PHP function) (distinguishes between cu and tty)
(set up XBee in terminal, OS X) (XBee read-me) (setting up two Xbees) (wireless LCD, sends via an XBee to an XBee connected to Arduino / LCD) (instructions that explain the XBee shield) (basic point-to-point networking, sending messages using softserial) (tool for configuring XBees) (more XBee configuration) (XBee shield info, not what I’m using, but still helpful) (battery tests with Arduino + XBee ***important***) (XBee Serial Communication) (basic XBee tutorial) (tutorial, shows timed “waking up” and some unfolding of data packets) (wireless temperature sensor, XBee, Arduino + solar) (PHP, XPort, Arduino) (basic how-to photo for soldering 9v Arduino battery adapter) (reminder on how to hook up LCD to Arduino)

I would like to thank the Canada Council for the Arts for their generous support.

CCFA bar XBees, Arduinos, Serial Data

7 Replies to “Arduino, PHP, LCDs, XBees: Tactical Texting in Public Spaces”

  1. 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.

Comments are closed.