User Tools

Site Tools


info:wiznet_to_pachube_communications

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
info:wiznet_to_pachube_communications [2011/01/29 13:43] – created tomgeeinfo:wiznet_to_pachube_communications [2011/01/29 14:35] (current) tomgee
Line 8: Line 8:
      Content-Length: 19      Content-Length: 19
      Connection: close      Connection: close
 +      
 +     
      12,14,66,23.03,text      12,14,66,23.03,text
 +
 +The content-length field is a count of every character in the content, which is the line at the very end.  Content always comes after two newlines, at the end of an HTTP PUT request, as shown above. If sending only one sensor, the PUT statement would look like this:
 +
 +     PUT /api/76.csv HTTP/1.1
 +     Host: www.pachube.com
 +     X-PachubeApiKey: ENTER_YOUR_PACHUBE_API_KEY_HERE
 +     Content-Length: 3
 +     Connection: close
 +     
 +     
 +     126
 +==== The Code ====
 +
 +
 +Using the Arduino Ethernet shield, this kind of a call is trivial. It’s just a series of print statements:
 +
 +     // include the Ethernet library
 +     #include <Ethernet.h>
 +      
 +     // assign a MAC address for the ethernet controller.
 +     // fill in your address here:
 +     byte mac[] = {
 +     0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x01 };
 +     // assign an IP address for the controller:
 +     byte ip[] = {
 +       192,168,0,20 };
 +     // Assign the address of the server you want to connect to:
 +     byte server[] = {
 +       173,203,98,29 }; // pachube.com
 +     
 +     // initialize the library instance:
 +     Client client(server, 80);
 +     
 +     long lastConnectionTime = 0;      // last time you connected to the server, in milliseconds
 +     boolean lastConnected = false;    // state of the connection last time through the main loop
info/wiznet_to_pachube_communications.1296326635.txt.gz · Last modified: 2011/01/29 13:43 by tomgee