i have multiple temperature and humidity sensors conected to arduino board mega(DHT22, DS18b20,...) In my program i get the temperature from the sensors and i put them into datastream and send it to Xiviely, and here comes the problem. When i put the fake float number into the stream (e.g. float number 100.12) i got client reply "xivelyclient.put returned 200" witch is ok, but when i put real data (temperature or humidity) from the sensors in the datastream i dont get answer from Xively. (the program stops there and sometimes after few minutes Xively returns -3 or something like that).
Code which works fine:
/*OUTSIDE ANY METHOD*/
XivelyDatastream datastreamsRekuperator[] = {
XivelyDatastream("01-T-zunanji", strlen("01-T-zunanji"), DATASTREAM_FLOAT),
XivelyDatastream("02-T-notranji", strlen("02-T-notranji"), DATASTREAM_FLOAT),
XivelyDatastream("03-T-odvod", strlen("03-T-odvod"), DATASTREAM_FLOAT),
XivelyDatastream("04-T-vpih", strlen("04-T-vpih"), DATASTREAM_FLOAT),
XivelyDatastream("05-T-kanal", strlen("05-T-kanal"), DATASTREAM_FLOAT),
XivelyDatastream("06-V-zunanji", strlen("06-V-zunanji"), DATASTREAM_FLOAT),
XivelyDatastream("07-V-notranji", strlen("07-V-notranji"), DATASTREAM_FLOAT),
XivelyDatastream("08-V-odvod", strlen("08-V-odvod"), DATASTREAM_FLOAT),
XivelyDatastream("09-V-vpih", strlen("09-V-vpih"), DATASTREAM_FLOAT),
XivelyDatastream("10-V-kanal", strlen("10-V-kanal"), DATASTREAM_FLOAT),
};
XivelyFeed rekuperatorFeed(XXXXXXXXX, datastreamsRekuperator, 10/* number of datastreams */);
/*IN LOOP METHOD*/
datastreamsRekuperator[0].setFloat(100.12);
datastreamsRekuperator[1].setFloat(100.12);
datastreamsRekuperator[2].setFloat(100.12);
datastreamsRekuperator[3].setFloat(100.12);
datastreamsRekuperator[4].setFloat(100.12);
datastreamsRekuperator[5].setFloat(100.12);
datastreamsRekuperator[6].setFloat(100.12);
datastreamsRekuperator[7].setFloat(100.12);
datastreamsRekuperator[8].setFloat(100.12);
datastreamsRekuperator[9].setFloat(100.12);
Serial.println("Uploading it to Xively");
int retRekuperator = xivelyclient.put(rekuperatorFeed, xivelyKey);
Serial.print("xivelyclient.put returned ");
Serial.println(retRekuperator);
Code which don't work:
/*OUTSIDE ANY METHOD*/
XivelyDatastream datastreamsRekuperator[] = {
XivelyDatastream("01-T-zunanji", strlen("01-T-zunanji"), DATASTREAM_FLOAT),
XivelyDatastream("02-T-notranji", strlen("02-T-notranji"), DATASTREAM_FLOAT),
XivelyDatastream("03-T-odvod", strlen("03-T-odvod"), DATASTREAM_FLOAT),
XivelyDatastream("04-T-vpih", strlen("04-T-vpih"), DATASTREAM_FLOAT),
XivelyDatastream("05-T-kanal", strlen("05-T-kanal"), DATASTREAM_FLOAT),
XivelyDatastream("06-V-zunanji", strlen("06-V-zunanji"), DATASTREAM_FLOAT),
XivelyDatastream("07-V-notranji", strlen("07-V-notranji"), DATASTREAM_FLOAT),
XivelyDatastream("08-V-odvod", strlen("08-V-odvod"), DATASTREAM_FLOAT),
XivelyDatastream("09-V-vpih", strlen("09-V-vpih"), DATASTREAM_FLOAT),
XivelyDatastream("10-V-kanal", strlen("10-V-kanal"), DATASTREAM_FLOAT),
};
XivelyFeed rekuperatorFeed(XXXXXXXXX, datastreamsRekuperator, 10/* number of datastreams */);
/*IN LOOP METHOD*/
datastreamsRekuperator[0].setFloat(getTemperatureDHT22(6));
datastreamsRekuperator[1].setFloat(getTemperatureDHT22(7));
datastreamsRekuperator[2].setFloat(getTemperatureDHT22(8));
datastreamsRekuperator[3].setFloat(getTemperatureDHT22(9));
datastreamsRekuperator[4].setFloat(getTemperatureDHT22(10));
datastreamsRekuperator[5].setFloat(getHumidityDHT22(6));
datastreamsRekuperator[6].setFloat(getHumidityDHT22(7));
datastreamsRekuperator[7].setFloat(getHumidityDHT22(8));
datastreamsRekuperator[8].setFloat(getHumidityDHT22(9));
datastreamsRekuperator[9].setFloat(getHumidityDHT22(10));
Serial.println("Uploading it to Xively");
int retRekuperator = xivelyclient.put(rekuperatorFeed, xivelyKey);
Serial.print("xivelyclient.put returned ");
Serial.println(retRekuperator);
The getTemperature method (getHumidity is created on the same way):
float getTemperatureDHT22(int DHT22_PIN){
DHT22 myDHT22(DHT22_PIN);
delay(2000); //DHT22 can be read every 2s
DHT22_ERROR_t errorCode = myDHT22.readData();
if(errorCode==DHT_ERROR_NONE){
Serial.print("Pin ");
Serial.print(DHT22_PIN);
Serial.print(" ");
Serial.println(myDHT22.getTemperatureC());
return myDHT22.getTemperatureC();
}
else{
Serial.print("Pin ");
Serial.print(DHT22_PIN);
Serial.println(" No data");
return 0.0;
}
}
The only difference in code is that "100.12" is replaced with "getTemperatureDHT22(PIN)" or "getHumidityDHT22(PIN)".
Reply from the working code:
Uploading it to Xively
xivelyclient.put returned 200
Reply from the non working code:
Pin 6 17.40
Pin 7 20.70
Pin 8 19.90
Pin 9 16.40
Pin 10 19.10
Pin 6 50.10
Pin 7 52.50
Pin 8 51.20
Pin 9 44.00
Pin 10 45.20
Uploading it to Xively
/*HERE THE PROGRAM STOPS*/
Does anybody know what it could go wrong? I would realy be thankfull for any reply and any suggestion. Thank you.