3

Ethernet Shiled を使用している Arduino Mega から Cosm にデータをアップロードできません。チュートリアルの例 ( DatastreamUpload.ino) の 1 つを試しました。登録時にCosmから提供されたAPIキーとフィードIDをinit()使用し、以下のように静的IPアドレスを使用するように関数を変更しました。

    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);

それから:

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

シリアルモニターからの出力は次のとおりです。

センサー値を読み取る 452.00
Cosmにアップロードする
cosmclient.put は -1 を返しました

センサー値を読み取る 451.00
Cosmにアップロードする
cosmclient.put は -1 を返しました

センサー値を読み取る 378.00
Cosmにアップロードする
cosmclient.put は -3 を返しました

センサー値を読み取る 352.00
Cosmにアップロードする
cosmclient.put は -3 を返しました

誰かがこれに対する解決策を持っていますか?

4

2 に答える 2

0

当然のことながら、リンク先の ino は 100% コーシャに見えます。

念のため、int ret=0; とします。ループの開始時

センサーが 1 つしかないことは承知していますが、細心の注意を払ってそれを sensorId0 として識別することをお勧めします

バッファがあります

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

フルボトルは、昨年 10 月に cosm フォーラムに掲載されました。

そのIP、ゲートウェイ、サブネットなどは使用しません。水を濁らせているのでしょう。

于 2013-04-25T08:02:26.253 に答える
0

現時点では、これに関するドキュメントが不足しているため、ソース コードを調べて確認する必要があります。これらのエラー コードは、次のように定義されHttpClient.hています。

// 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;
于 2013-04-23T21:51:14.717 に答える