Pachuino is an Arduino with both local and remote sensors. It makes use of Pachube to provide real time remote sensor data (and to share your own local sensor data); and an Arduino loaded with Firmata, tethered to a computer connected to the internet. Pachube access is accomplished using the EEML library.
- Download and install the Processing Pachuino library (v. 005) and example here.
- Download and install the Processing Arduino library here.
- Download and install the Processing EEML library here.
- Upload Arduino's Firmata to your Arduino (NG or Diecimila definitely work OK, possibly earlier Arduinos too). Arduino 12 comes with Firmata already so you just need to upload the sketch found at File > Sketchbook > Examples >Library-Firmata > StandardFirmata.
The Processing application runs on your computer, accesses Arduino sensor input values and controls Arduino outputs. It also accesses remote real time sensor data from feeds that you choose.

You should also have some sensors attached, either things like light sensors connected to the analog inputs or buttons connected to digital inputs.
Complete Processing program
Note: scroll down to the bottom of this page for how to do this if you are working behind a firewall.
import processing.serial.*;
import cc.arduino.*;
import eeml.*;
import pachuino.*;
Pachuino p;
void setup(){
p = new Pachuino(this, Arduino.list()[0], 115200);
p.setPort(5230);
p.setKey("ENTER_PACHUBE_API_KEY_HERE");
// local sensors
p.addLocalSensor("analog", 0,"lightSensor");
p.addLocalSensor("analog", 1,"temperature");
p.addLocalSensor("digital", 2, "button");
p.addLocalSensor("digital", 5, "button2");
// remote sensors
p.addRemoteSensor(504, "accesses");
p.addRemoteSensor(1182, 0);
p.addRemoteSensor("http://www.pachube.com/api/1228.xml", 2);
p.addRemoteSensor("http://www.pachube.com/api/1136.xml", "blockameter");
}
void draw(){
float tempVal1 = p.localSensor[3].value;
float tempVal2 = p.remoteSensor[0].value;
String tempTags1 = p.localSensor[0].tags;
String tempTags2 = p.remoteSensor[1].tags;
p.digitalWrite(10, 1);
p.analogWrite(9, p.remoteSensor[0].value * 10);
p.debug();
}
void onReceiveEEML(DataIn d){
p.updateRemoteSensors(d);
}
void onReceiveRequest(DataOut d){
p.updateLocalSensors(d);
}Explanation
There are basically 6 steps, after making sure you have imported all the relevant libraries (Processing serial (which comes standard), Arduino, EEML and Pachuino 005):
-
Setup Pachuino, selecting an Arduino to connect to (change [0] and 115200 if your Arduino/Firmata is different -- see Firmata for details). Then select a port to serve on (for more on ports see the Processing reference for Server()). You can probably leave the port as 5230.
p = new Pachuino(this, Arduino.list()[0], 115200);
p.setPort(5230); -
If you want remote sensors, you will need to register with Pachube to receive a "key". (Keep this private, particularly if you publish code, it's your unique password to access Pachube feeds). Replace the text below with the key that gets emailed to you.
p.setKey("ENTER_YOUR_PACHUBE_KEY_HERE"); -
Add local sensors, identifying whether they are "digital" or "analog" and which particular pin they are connected to. Also include a comma-delimited list of tags to describe the sensor (these will be used by Pachube so that other people know what your sensors are).
p.addLocalSensor("analog", 1, "temperature,heat");
p.addLocalSensor("digital", 2, "button"); -
At Pachube, select some remote feed sensors that you are interested in and note down the feed ID (or feed URL) and the data stream ID for the particular sensor you are interested in (or you can note down just the tag that describes it). You can set up your remote sensors by referencing first the feed ID/URL then the data stream ID/tag:
p.addRemoteSensor(504, "accesses");
p.addRemoteSensor(1182, 0);
p.addRemoteSensor("http://www.pachube.com/api/1228.xml", 2);
p.addRemoteSensor("http://www.pachube.com/api/1136.xml", "blockameter"); -
In your draw loop you then have access to both local and remote sensor data. Local and remote sensors are separately identified in the order they were setup ('0' is the first, '1' is the second, etc.);
float tempVal1 = p.localSensor[3].value;
float tempVal2 = p.remoteSensor[0].value;... and you can control your Arduino outputs (actuators, LEDs, whatever) however you wish; for example you might connect a remote sensor to a local actuator.
p.digitalWrite(10, 1);
p.analogWrite(9, p.remoteSensor[0].value * 10); -
Finally, be sure to include the following two methods so that the EEML library knows to update the sensor readings when requested:
void onReceiveEEML(DataIn d){
p.updateRemoteSensors(d);
}
void onReceiveRequest(DataOut d){
p.updateLocalSensors(d);
}Note: You can use p.debug() to view complete sensor readings in your console.
You will also have to add your feed to Pachube in order to make your sensor available to others. For further details see A (Adding the Arduino's realtime sensor reading to a Pachube feed): Part 2 / Step 3 in this tutorial.
Manual update
If you need to use Pachuino behind a firewall, most of the above holds true. The only difference in the process is this:
- First create a feed in Pachube, and select "manual" instead of "automatic". Make a note of the URL to update to (this is the URL that ends in .xml).
- Now intead of using "setPort()" as in the above, manualUpdate() and include the URL you are updating:
p.manualUpdate("http://www.pachube.com/api/1153.xml"); - You also don't now need onReceiveRequest() method.
A complete Processing example (that updates from behind a firewall), would look like this:
import processing.serial.*;
import cc.arduino.*;
import eeml.*;
import pachuino.*;
Pachuino p;
void setup(){
p = new Pachuino(this, Arduino.list()[0], 115200);
p.manualUpdate("http://www.pachube.com/api/1153.xml"); // change URL -- this is the feed you want to update
p.setKey("ENTER_PACHUBE_API_KEY_HERE");
// local sensors
p.addLocalSensor("analog", 0,"lightSensor");
p.addLocalSensor("analog", 1,"temperature");
p.addLocalSensor("digital", 2, "button");
p.addLocalSensor("digital", 5, "button2");
// remote sensors
p.addRemoteSensor(504, "accesses");
p.addRemoteSensor(1182, 0);
p.addRemoteSensor("http://www.pachube.com/api/1228.xml", 2);
p.addRemoteSensor("http://www.pachube.com/api/1136.xml", "blockameter");
}
void draw(){
float tempVal1 = p.localSensor[3].value;
float tempVal2 = p.remoteSensor[0].value;
String tempTags1 = p.localSensor[0].tags;
String tempTags2 = p.remoteSensor[1].tags;
p.digitalWrite(10, 1);
p.analogWrite(9, p.remoteSensor[0].value * 10);
//p.debug();
}
// you don't need to change any of these
void onReceiveEEML(DataIn d){
p.updateRemoteSensors(d);
}Pachuino Library
- Version 005 - October 23, 2008: added new "manualUpdate()" method so that Pachuino works with Pachube's new manual update feature to use Pachuino behind a firewall. (Ignore v. 003 below). There is also a previously undocumented feature: setLocation() which works just like the EEML library's setLocation() method.
- Version 004 - June 25, 2008: changed localSensor -> addLocalSensor, and remoteSensor -> addRemoteSensor
- Version 003 - June 20, 2008: added setPOST() method for future Pachube feature
- Version 002 - April 16, 2008: updated main Pachube URL
- Version 001 - March, 2008: first release.
| Attachment | Size |
|---|---|
| pachuino-005.zip | 76.16 KB |
Recent comments
1 hour 1 min ago
8 hours 17 min ago
8 hours 45 min ago
10 hours 22 min ago
3 days 5 hours ago
3 days 6 hours ago
3 days 20 hours ago
3 days 20 hours ago
4 days 1 hour ago
4 days 6 hours ago