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.

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.