Monday 16 May 2011

How to: Connecting and receiving data from remote environmental sensors

This weekend I finally managed to complete my interface that will allow an anemometer (wind sensor) to control kinetic sculptures which could (theoretically) be placed on the moon. This post acts mainly as a log/set of instructions for myself and also for my own troubleshooting when I come to set up my installation at the gallery!! - those interested in using arduino and processing however, may find it useful...


1) download the Firmata arduino library for processing from here and put inside the libraries folder in the processing sketchbook.


2) upload OldStandardFirmata to the arduino board. I’m using an Arduino uno and find that this version of firmata works best. Note that arduino uno installs as '/dev/tt/usbmodem621' not 'dev/tt/usbSerial' as the older arduinos do...


3) Test that processing can access the serial data sent from arduino by running a sample processing sketch of a graph controlled by a simple arduino potentiometer circuit. I had a bit of trouble at this point – processing version 1.5 seemed to have trouble communicating with the serial port. I was getting all kinds of strange RXTX library conflict errors. There is a way around this by apparently deleting RXTX.comm.jar and librxtxSerial.jnilib from /library/java/extensions and replacing them with the same files from the arduino directory /Application/Arduino.app/Contents/Resources/Java. I could’t be bothered spending any more time on this problem so I simply reverted back to processing 1.2.1 and everything worked fine.


4) Now comes the tricky bit, I had to configure my Sky (netgear) router to allow for port forwarding for all traffic attempting to connect to my server (mac pro) on port 5210 - since my ip address was a local network address (beginning 192.168.x.x) and not the actual address that external site can see (http://whatismyip.com) . More info on configuring netgear routers to enable port forwarding can be found here you could of course use dynamic dns


5) Once that was set up it was time to test my feed. I setup a simple arduino/potentiometer ciruit and used processing to read the value of the potti. Make sure the EEML library for processing is installed at this point, this is the Extended Environments Markup Language and is a protocol for sharing data between remote responsive environments. Processing then broadcasts this data in a simple xml format. Providing the port forwarding works correctly, you can access this xml file, and subsequent potentiometer reading from your browser http://localhost:5210 - amazingly, this worked first time for me!!


6) If that works its time to setup the internet stream. A processing sketch reads the serial data and uploads this to the remote site. Test the feed works in the browser.


7) Once the feed is tested and working ok, its time to build the system that is to be controlled by the remote sensor. To test this I used a simple servo connected to arduino. I uploaded the ServoFirmata that is included with the Arduino IDE. Another processing sketch runs on the remote machine (again using both the firmata arduino library and EEML library) which pulls down the data from the live feed and moves the servo accordingly. The code for this sketch took aaaages to write and was really really messy. Thats the hard bit done woohooooo, all thats left to do now is make my kinetic sculptures.


If you like anymore info on this please leave a comment or email me.


No comments:

Post a Comment