Getting Started with Pachube & Arduino
Thursday, June 25th, 2009Another post on Pachube and how easy it is to get setup and going. This post will cover the basic steps on how to get some sensors online! I will be using my project of two light sensors as an example. The status of my light sensors are viewable at http://www.pachube.com/feeds/2145
Pachube + Arduino from Morgellon on Vimeo.
STEP ONE: GET A PACHUBE ACCOUNT!
Head over to the Pachube website and see various sensors from all over the world and view their status. Be sure to view the ABOUT page, this describes INPUTs and OUTPUTs, along with ways to interface with Pachube and your sensors. The QUICKSTART page has the details to get started and how to use your API. Pachube is still in beta, so you’ll need to get an invite code… but no worries, Pachube has an email address on the QUICKSTART page. Just send them and email asking for an invite and what you would like to do. If they let me in… they will let anyone in!
STEP TWO: PREPARE ARDUINO!
The Arduino can be interfaced with Pachube two ways: 1. With an Ethernet shield OR 2. Via USB connected to a PC running Processing… which is the way used in this tutorial… as I feel it is an easy and inexpensive way. You can learn more about each way at the Pachube Arduino page.
To prep the Arduino, you need to connect the sensors you will be using and verify that they are working correctly! Once the sensors are good, then upload the “Standard Firmata” to the Arduino. Now the Arduino is prepped for Pachube! Leave the Arduino connected to the PC.
STEP THREE: PREPARE PROCESSING!
To have Processing communicate easily with Pachube, you will need to add a few libraries. They are the Pachuino, Arduino and EEML libraries, they are available and there is more info at the PACHUINO page. Download, unzip and move them to the libraries folder, in your sketchbook folder. Now Processing is ready!
STEP FOUR: PREPARE INPUT FEED!
Once you have a Pachube account and your API key, go ahead and set up a new feed for your sensors. Since I have light sensors, I started a new INPUT FEED. I chose to make my feed “manual” (as this is easier for me) which means Pachube gets updates only when I send them. Instead of Pachube connecting directly to my PC to pull the info.
STEP FIVE: PREPARE CODE FOR PROCESSING!
Once you have the libraries in the folder, you are ready to start Processing and start coding. Below is the code I used for my light sensor. This was taken from the sample code and stripped to make it more simple. I added a LED on pin 11 to light up (to let me know when my Arduino was running) and a delay(1500).
Be sure to add you API Key, and the URL of your INPUT FEED!
import processing.serial.*;
import cc.arduino.*;
import eeml.*;
import pachuino.*;
Pachuino p;
Arduino arduino;
int ledPin = 11;
void setup(){
p = new Pachuino(this, Arduino.list()[0], 115200);
p.manualUpdate(”http://www.pachube.com/api/2145.xml”); // change URL — this is the feed you want to update
p.setKey(”—YOUR API KEY HERE—”);
// local sensors
p.addLocalSensor(”analog”, 0,”Light Sensor Inside”);
p.addLocalSensor(”analog”, 1,”Light Sensor Outside”);
}
void draw(){
//p.debug();
p.digitalWrite(ledPin, Arduino.HIGH);
delay(1500);
}
// you don’t need to change any of these
void onReceiveEEML(DataIn d){
p.updateRemoteSensors(d);
}
STEP SIX: LAUNCH CODE AND COLLECT DATA!
Make sure that:
- Sensors are *working* and connected to Arduino
- Arduino is running “Standard Firmata” and connected to computer
- Processing is collecting sensor data from Arduino
- Computer has Internet connection
Now run your program and begin collecting data and sharing it on the web!! Check your feed to make sure you data is being transmitted. Have fun and happy tinkering!
–Morgellon OUT!














