3

I cannot upload data from my Arduino Mega with Ethernet Shiled to Cosm. I tried one of the tutorial examples (DatastreamUpload.ino). I used the API key and feed ID that Cosm gave to me at the registration and changed the init() function to use a static IP address as below:

    byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0xD3, 0x45 };
    IPAddress ip(192,168,0, 110);
    IPAddress gateway(192,168,0, 1);
    IPAddress subnet(255, 255, 255, 0);

then:

    Ethernet.begin(mac, ip, gateway, subnet);

Here is the output from serial monitor:

Read sensor value 452.00
Uploading it to Cosm
cosmclient.put returned -1

Read sensor value 451.00
Uploading it to Cosm
cosmclient.put returned -1

Read sensor value 378.00
Uploading it to Cosm
cosmclient.put returned -3

Read sensor value 352.00
Uploading it to Cosm
cosmclient.put returned -3

Does someone have a solution to this?

lebreeze
  • 5,094
  • 26
  • 34

2 Answers2

0

There is a lack of documentation on this at the moment, one needs to look at the source code to find out. These error codes are defined in HttpClient.h as below:

// The end of the headers has been reached.  This consumes the '\n'
static const int HTTP_SUCCESS =0;
// Could not connect to the server
static const int HTTP_ERROR_CONNECTION_FAILED =-1;
// This call was made when the HttpClient class wasn't expecting it
// to be called.  Usually indicates your code is using the class
// incorrectly
static const int HTTP_ERROR_API =-2;
// Spent too long waiting for a reply
static const int HTTP_ERROR_TIMED_OUT =-3;
// The response from the server is invalid, is it definitely an HTTP
// server?
static const int HTTP_ERROR_INVALID_RESPONSE =-4;
errordeveloper
  • 6,716
  • 6
  • 41
  • 54
  • i saw yet the cosm forum and i understand that arduino can't communicate with pachube server. But i don'it understand why. If i try to start ethernet with DHCP like this: Ethernet.begin(mac) sometimes data arrive to pachube... This is still a mistery to me! Anyone can help? Thanks! – user2312976 Apr 24 '13 at 10:12
  • Using DHCP would probably be a good start on debugging this... It's very likely to be an issue with IP configuration. – errordeveloper Apr 24 '13 at 11:36
0

Unsurprisingly, the ino you link to looks 100% kosher and I struggle to see anything different from what I have used.

As a precaution I would put int ret=0; at the start of the loop

I realise you have only one sensor but suggest you meticulously identify it as sensorId0

I have a buffer

const int bufferSize = 100; char bufferValue[bufferSize]; CosmDatastream datastreams[] = { CosmDatastream(sensorId0, strlen(sensorId0), DATASTREAM_FLOAT),

The full bottle was published on the cosm forum last October.

I don't use that ip, gateway and subnet stuff. It is probably muddying the water.