2014-07-21 4 views
1

Xively에서 2 개의 채널을 업데이트하고 싶습니다. 데이터 스트림을 업데이트 할 수 없습니다. 하나의 채널이 업데이트되고 ("온도"), 다른 "센서 1"이 업데이트되지 않습니다.Xively Datastreams Setup Arduino

이것은 데이터 스트림에서의 첫 번째 균열입니다. 그래서 어떤 advice/pointers/tutorials도 보게 될 것입니다. 나는 온통 쳐다 보았고 이것을 작동시키지 못한다. 처음에는 Feed API를 사용하여 하나의 센서에 대해 하나의 피드를 설정했지만 지금은 더 많은 센서를 추가하려고합니다. 다시 한번, 어떤 도움이라도 극도로 감사하게 될 것입니다!

#include <SPI.h> 
#include <EthernetV2_0.h> 
#include <HttpClient.h> 
#include <Xively.h> 

// MAC address for your Ethernet shield 
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; 

// Your Xively key to let you upload data 
char xivelyKey[] = "osUccdJJbn9lkhjSOZMoTznEUOYJH7j1mgU5Jz8DRXOtGzHf"; 

// Analog pin which we're monitoring (0 and 1 are used by the Ethernet shield) 
int tempPin = 3; 
int motionPin = 5; 

// Define the strings for our datastream IDs 
    char sensorId[] = "sensor_reading"; 


XivelyDatastream datastreams[] = { 
    XivelyDatastream("Temperature", strlen("Temperature"), DATASTREAM_FLOAT), 
    XivelyDatastream("sensor1", strlen("sensor1"), DATASTREAM_FLOAT), 
}; 
// Finally, wrap the datastreams into a feed 
XivelyFeed feed(418519995, datastreams, 1 /* number of datastreams */); 

EthernetClient client; 
XivelyClient xivelyclient(client); 

void setup() { 
    // put your setup code here, to run once: 
    Serial.begin(9600); 

    Serial.println("Starting single datastream upload to Xively..."); 
    Serial.println(); 

    while (Ethernet.begin(mac) != 1) 
    { 
    Serial.println("Error getting IP address via DHCP, trying again..."); 
    delay(15000); 
    } 
} 

void loop() { 
    int tempValue = analogRead(tempPin); 
    int motionValue = analogRead(motionPin); 

    //temperature conversion - not working currently. 
    int tempValueTmp = log(((10240000/tempValue) - 10000)); 
    tempValueTmp = 1/(0.001129148 + (0.000234125 * tempValueTmp) + (0.0000000876741 * tempValueTmp * tempValueTmp * tempValueTmp)); 
    tempValueTmp = tempValueTmp - 273.15; 
    int ftemp = (tempValueTmp * 1.8) + 32; 


    datastreams[0].setFloat(ftemp); 
    datastreams[1].setFloat(motionValue); 

    Serial.print("Read temp sensor value "); 
    Serial.println(datastreams[0].getFloat()); 

    Serial.print("Read motion sensor value "); 
    Serial.println(datastreams[1].getFloat()); 

    Serial.println("Uploading it to Xively"); 
    int ret = xivelyclient.put(feed, xivelyKey); 
    Serial.print("xivelyclient.put returned "); 
    Serial.println(ret); 

    Serial.println(); 
    delay(3000); 
} 

답변

1

마지막 피드 XivelyFeed 피드로 데이터 스트림을 래핑 // 2

에 데이터 스트림의 개수를 변경하는 시도 (418,519,995, 데이터 스트림, 2/* 데이터 스트림의 개수 * /);