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.










![Defiance: Disobedient Design Panel Discussion Next week, I’ll be heading over to Detroit to join a panel discussion hosted by rogueHAA entitled, Defiance: Obedient Design. They’ve been doing a lot of great programming over the last year or so, and here’s some more information: As part of the Detroit Design Festival presented by the Detroit Creative Corridor Center, rogueHAA is pleased to announce the third [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/09/disobedient-design_A-150x150.jpg)
![Scavenge the City Recap A week ago, on an incredibly cold, rainy, snowy evening, we headed out on an exploration of Windsor’s downtown guided by a randomly assembled algorithm for Scavenge The City. We only made it through the first 20 steps (we stopped checking them off though), plus a couple others we skipped to by the end, but for [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/04/algorithm-original-used2-150x150.jpg)
![1-Day Project: “Find Something Worthwhile” We had ordered these screen printing supplies in anticipation of using them for our upcoming Civic Maintenance project, but before we could embark on that large-scale production, we needed to test. We got process colours cmyk and the basics for screen printing – photo emulsion and photo emulsion remover and two screens. We haven’t screen [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2012/08/wpid19672-IMG_1253-150x150.jpg)
![100 Ways to Save the City Projection As part of FAM Fest 09, we did a projection performance on the roof of Metro Cleaners accessed from Empire Lounge in downtown Windsor. For about an hour and a half, we presented our 100 Ways to Save the City and then asked for ideas from the folks on the ground, at Phog, and on the Twitterverse. After the [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/10/IMG_1761-150x150.jpg)
![SRSI, Day 5: Clothes, Trucks, Lightbulbs and Flowers. Yesterday morning on Pelissier was very loud and hectic. When I arrived there was about 3 feet of sidewalk space in front of 406. It was another eventful day as we were joined by The Swap Shop . I did some catching up with Jefferson, Julie and Andrea as well. Big machines looked like dinosaurs [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/06/DSC_08461-150x150.jpg)
![Anxious to Explore the Border Bookmobile’s Winter Reading Room I stopped by the Ecohouse today (where our collective studio is housed) to check out one of our new neighbours — The Border Bookmobile Winter Reading Room. Collected and curated by Border Bookmobile founder, Lee Rodney, the books assembled as part of the winter reading room are going to be incredible helpful for our upcoming [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/01/IMG_5136-150x150.jpg)

![Tonight, the first iteration of Cross-Border Communication Tonight, we are going to perform the first iteration of Cross-Border Communication. Thanks to the generosity from the University of Windsor’s Faculty of Arts and Social Sciences Research Leadership Chair and Spectrodata, we have the equipment we need to realize this project. Cross-Border Communication was initially imagined through a collaborative effort between Broken City Lab [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/11/IMG_4416-150x150.jpg)

![City Counseling (Session #1) Last night, in front of city hall, we had a conversation about the ways we want to shape our city. In the midst of rising tensions around existing city services and new infrastructures, there seems to be a renewed wish for not just more public dialogue with the city, but a dialogue based on transparency [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/06/IMG_0088-150x150.jpg)
![Research Trip: Residency at White Water Gallery for A Northern Locality We’re heading up to White Water Gallery next week for a weeklong residency exploring a northern locality — this work will inform an exhibition coming up in the fall! Over the course of a weeklong residency, we will engage in a series of exploratory public interventions, micro-gestures, and tactical DIY responses to North Bay. Join [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2012/07/gateway-640-150x150.jpg)
![Expect More Activity + How Do You Collaborate Online? Be it resolved that we’ll be a lot more active on here starting now. We’ve been overly involved in communicating on Google Wave while trying to keep our brains together for Save the City. With that project winding down, we’ll be shifting more of our research and communications back on here. We’ve missed it. And [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/05/howToPostOnBCL-sm-150x150.jpg)
![Learning to Transplant Josh and I spent some of the day in the heat collecting some interesting flowers and plants to transplant for our magnetic planters project. Overall, it was fairly successful, as we did learn quite a lot about transplanting, but we’re still going to be looking for some more plants to finish up this stage of [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/08/IMG_46142-150x150.jpg)
![The International Hyper-local Exchange Monday night we met with some new friends from Detroit and had an amazingly good conversation about some of the very specific differences between our two cities. Maybe unsurprisingly, much of what we perceive about each other’s cities isn’t entirely correct, and it is exactly those strange assumptions about these two border cities that continue [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/11/IMG_5195-150x150.jpg)
![Last Meeting for 2009! Monday night marked the last Broken City Lab meeting of the year!!! We’ll be taking a brief break over the holidays and then gearing up for a series of events starting at the end of January. For anyone who has been wondering how to get involved or if we’d ever hold open office hours again, [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/12/IMG_72891-150x150.jpg)
![Community Garden Site I went out to the site for our proposed community garden to take some photos yesterday. It’s looking fairly likely that this will be the site for our community garden starting this summer. This park is located at Russell and Mill near the Sandwich windmill. We’re still working out all the details, but everything has [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/04/img_4065-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)
![Making Banners at the Labour Lounge We spent Friday night in Hamilton at the Workers Arts and Heritage Centre as part of their Labour Lounge series (organized by once-Windsorite, Andrew Lochhead). In a little less than two hours, we led a workshop and explosion of creativity with some amazingly great 13-year-olds. We made banners, two really great banners that will be [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/11/IMG_5675-150x150.jpg)
![SRSI, Day 2 : The People’s Museum, The Breakroom and More Painting Day 2 of SRSI went awesome! We are almost all settled into 406, 410 and 424 Pelissier. I started off the day by cleaning and organizing my desk in the entrance of 410. I’ll be stationed here throughout the residency so come and say hi! Over at The Breakroom in 406, Jolie had some fresh [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/06/DSC_0714-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?