/* Pachube Data Out Demonstrates use of the ERxPachube library. Push local sensor data to Pachube server. If you don't have a Pachube account, register one first (http://www.pachube.com/). To run this sketch, you need: 1. Create a same feed as http://www.pachube.com/feeds/26318 (A manual feed with three data streams with ids 0, 1, 2.) 2. Use your API key to replace the space holer PACHUBE_API_KEY below. 3. Use your feed id to replace the space holer PACHUBE_FEED_ID below. Circuit: * Ethernet shield attached to pins 10, 11, 12, 13 * Created 22 April 2011 * By Jeffrey Sun * http://code.google.com/p/pachubelibrary/ */ #include #include #include "ERxPachube.h" #define PACHUBE_API_KEY "XXXXXXXXXXXXXXXXXXXXXXX" #define PACHUBE_FEED_ID "26318" // assign a MAC address for the ethernet controller. // Enter a MAC address and IP address for your controller below. // The IP address will be dependent on your local network. byte mac[] = { X, X, X, X, X, X }; // MAC address byte ip[] = { X, X, X, X }; // no DHCP so we set our own IP address byte server[] = { 209, 85, 146, 147 }; // www.pachube.com byte gateway[] = { 192, 168, X, X }; // the router's gateway address byte subnet[] = { 255, 255, 255, 0 }; // the subnet Client client(server, 80); // initialize the library instance ERxPachubeDataOut dataout(PACHUBE_API_KEY, PACHUBE_FEED_ID); void PrintDataStream(const ERxPachube & pachube); void PrintString(const String & message) ; void setup(){ Serial.begin(9600); Ethernet.begin(mac, ip, gateway, subnet); dataout.addData("0"); } void loop(){ Serial.println("+++++++++++++++++++++"); dataout.updateData("0", analogRead(0)); int status = dataout.updatePachube(); Serial.print("sync status code == "), Serial.println(status); PrintDataStream(dataout); delay(10000); } void PrintDataStream(const ERxPachube & pachube){ unsigned int count = pachube.countDatastreams(); Serial.print("data count=> "); Serial.println(count); Serial.println(","); for(unsigned int i=0; i