Pages: [1]   Go Down
Author Topic: Arduino Uno with WiFly shield posting data to pachube  (Read 1773 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
SpiSerial.println("open pachube.com 80");
  delay(1000);
  SpiSerial.print("POST /api/");
  SpiSerial.print(SHARE_FEED_ID);
  SpiSerial.print(".csv?_method=put HTTP/1.1\r\nHost: www.pachube.com\r\n");
  SpiSerial.print("X-PachubeApiKey: ");
  SpiSerial.print(PACHUBE_API_KEY);
  SpiSerial.print("\r\nContent-Length: ");
  SpiSerial.print(content_length);
  SpiSerial.print("\r\nConnection: close\r\n");
  SpiSerial.print("\r\n");
  SpiSerial.print(pachube_data);
  SpiSerial.print("\r\n");

Any ideas?

Cheers,
Brad
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 108
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
delay(1000);
SpiSerial.println("open pachube.com 80");




   
Logged

Linux and Arduino, two great things that go great together!
http://www.roboticcore.com

Pages: [1]   Go Up
Jump to: