title: Arduino sending data to Xively
body: <p>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).</p>
  
  <p>Code which works fine:</p>
  
  <pre><code>/*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></pre>
  
  <p>Code which don't work:</p>
  
  <pre><code>/*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);
  </code></pre>
  
  <p>The getTemperature method (getHumidity is created on the same way):</p>
  
  <pre><code>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;
    }
  }
  </code></pre>
  
  <p>The only difference in code is that "100.12" is replaced with "getTemperatureDHT22(PIN)" or "getHumidityDHT22(PIN)".</p>
  
  <p>Reply from the working code:</p>
  
  <pre><code>Uploading it to Xively
  xivelyclient.put returned 200
  </code></pre>
  
  <p>Reply from the non working code:</p>
  
  <pre><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*/
  </code></pre>
  
  <p>Does anybody know what it could go wrong? I would realy be thankfull for any reply and any suggestion. Thank you.</p>