Go Down

Topic: Pachube: how to upload 8 datastream at the same time? (Read 940 times) previous topic - next topic

DanielaES

Hello,
I have some problem with pachube.
I dont have space to use the official Pachube lib, so I have to write the code by myself.
How update 8 datastream within the same PUT?
The example in the new IDE are quite old.
Any example code?
Thank you


demosa


The following function doing it for me (but only for 3 datastreams).
You basically have to follow the notation :

0,<value>
1,<value>
2,<value>
3,<value>
...
7,<value>


void WritePachube(void)
{
  // update sensor feed
  char PachubeData[64];
 
  sprintf(PachubeData,
          "0,%d.%d\n1,%d.%d\n2,%d\n",
          (int)FTemp[0], (int)((FTemp[0] - (int)FTemp[0]) * 100),
          (int)FTemp[1], (int)((FTemp[1] - (int)FTemp[1]) * 100),
          GetSuccessRate());
 
  int nContentLength = strlen(PachubeData);
 
  SerialPrint("PUT request to update sensor feed... ");
  LocalClient.print("PUT /v2/feeds/");
  LocalClient.print(SENSOR_FEED_ID);
  LocalClient.print(".csv HTTP/1.1\n");
  LocalClient.print("Host: api.pachube.com\n");
  LocalClient.print("X-PachubeApiKey: ");
  LocalClient.print(PACHUBE_API_KEY);
  LocalClient.print("\n");
  LocalClient.print("Content-Type: text/csv\n");
  LocalClient.print("Content-Length: ");
  LocalClient.print(nContentLength);
  LocalClient.print("\n");
  LocalClient.print("Connection: close\n\n");
  LocalClient.print(PachubeData);
  LocalClient.print("\n");
  LocalClient.print("\n");
  SerialPrint("done\n");
}

Go Up