Go Down

Topic: Arduino Uno with WiFly shield posting data to pachube (Read 2181 times) previous topic - next topic


Hi all,

I'm using an Arduino Uno with a WiFly shield from Sparkfun (http://www.sparkfun.com/products/9954) to try to post home energy use data to pachube.  It works - the first time when I fire it up, but then it does not work on the following loops.  Here is the posting code...  is there something I need to send at the end to close the link?

I'm using WiFly.h library (http://forum.sparkfun.com/viewtopic.php?f=32&t=25216)

Code: [Select]
SpiSerial.println("open pachube.com 80");
  SpiSerial.print("POST /api/");
  SpiSerial.print(".csv?_method=put HTTP/1.1\r\nHost: www.pachube.com\r\n");
  SpiSerial.print("X-PachubeApiKey: ");
  SpiSerial.print("\r\nContent-Length: ");
  SpiSerial.print("\r\nConnection: close\r\n");

Any ideas?



Bear in mind, I don't use pachube OR the SpiSerial library, but I do use the Wifly Shield and connect with the open command. I think you need to close the connection.

If you do:
SpiSerial.println("open pachube.com 80");

While the connection is open, it will send that to the pachube page.

You need to go into command mode (Which should close the connection if open) and, as a redundency, issue the "close" command.

Then you can redo
SpiSerial.println("open pachube.com 80");

and start the process all over again.

Using SpiSerial and delays, the process looks like this:

delay(500);  // Guard time for entry to Command Mode.
SpiSerial.print("$$$");  // Command Mode.
delay(500);  // Guard time again, The module will have entered Command Mode 250 ms prior to this delay ending.
SpiSerial.println("close"); // Just in case the module was already IN Command Mode.
SpiSerial.println("open pachube.com 80");


Go Up