2013-04-23 42 views
3

我不能從我的Arduino兆豐與以太網數據上傳到Cosm。我嘗試了一個教程示例(DatastreamUpload.ino)。我使用的COSM給我在註冊API密鑰和飼料ID,改變了init()函數中使用如下靜態IP地址:無法通過教程草圖將數據上傳到Cosm arduino兆豐通過教程草圖

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

這裏是輸出從串口監視器:

 
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 

有人有解決這個問題嗎?

回答

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; 
+0

我還沒看到cosm論壇,我明白arduino無法與pachube服務器通信。但我不明白爲什麼。 如果我嘗試使用DHCP這樣的啓動以太網: Ethernet.begin(MAC) 有時數據到達pachube ... 這仍然是一個謎給我!任何人都可以幫忙謝謝! – user2312976 2013-04-24 10:12:50

+0

使用DHCP可能會很好地開始調試...這很可能是IP配置的問題。 – errordeveloper 2013-04-24 11:36:51

0

毫不奇怪,你鏈接到伊諾看起來100%潔淨,我很難看到任何東西從我用的不同。

作爲預防措施我把 INT RET = 0; 在循環

我知道你只有一個傳感器,但建議你認真的開始將其識別爲sensorId0

我有一個緩衝

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

滿瓶上發佈的宇宙論壇去年十月。

我不使用該ip,網關和子網的東西。它可能混濁水。