Uploading data to Xively using Uno and Ethernet shield

I am attempting to display temp readings from my Dallas DS18B20 thermometer on my Xively account. I am using Xively's "Datastream Upload Code" from their site. All I am getting though is 0 degrees temperature. The original code was for analog sensors so I changed it over for the Dallas "One Wire".

//Xively Temperature Sensor 

#include <SPI.h>
#include <Ethernet.h>
#include <HttpClient.h>
#include <Xively.h>
#include <OneWire.h>
#include <DallasTemperature.h>

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0E, 0xCA, 0xCB}; // MAC address for your Ethernet shield

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

#define ONE_WIRE_BUS 8   //data wire is plugged into pin 8 on the Arduino 
#define TEMPERATURE_PRECISION 12

OneWire oneWire(ONE_WIRE_BUS);  //Setup a oneWire instance to communicate with any OneWire devices.

DallasTemperature sensors(&oneWire);  //pass our oneWire reference to the Dallas Temperature.

DeviceAddress OutsideThermometer ={ 0x28, 0xB8, 0x6E, 0xDE, 0x04, 0x00, 0x00, 0x81};

char sensorId[] = "sensor_reading";  // Define the strings for our datastream IDs
XivelyDatastream datastreams[] = {
  XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),
};

XivelyFeed feed(676748944, datastreams, 1 /* number of datastreams */);  // Finally, wrap the datastreams into a feed

EthernetClient client;
XivelyClient xivelyclient(client);

float tempC;

void getTemperatures(DeviceAddress deviceAddress)
{
  sensors.requestTemperatures();
   tempC = sensors.getTempC(deviceAddress);
}

void setup() {
  
  Serial.begin(9600);  // put your setup code here, to run once:
  
  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);
  }
  sensors.begin();
  sensors.setResolution(OutsideThermometer, TEMPERATURE_PRECISION);
}

void loop() {
  int sensorValue = tempC;
  datastreams[0].setFloat(sensorValue);

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

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

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

I know my set up is right, because if I change to a LM35DT and use the original code it works. My changes used code I got from "Project 46- Ethernet Web Server" from Michael McRoberts book, "Beginning Arduino".

  int sensorValue = tempC;
  datastreams[0].setFloat(sensorValue);

Why are you truncating the float to an int, and then passing the int to a function that expects a float?

void getTemperatures(

The name implies that the function returns a temperature. It doesn't. Fix the name, or, better yet, make it actually return a value. There is no reason for this function to be storing a value in a global variable.

In loop(), you probably need to actually call this function.

Paul,
I've been learning Arduino for about six months and I am still in the paste stuff together and see if it works. The DS18
code was how McRoberts s set it up in another project so I copied is direct. Obviously it didn't work. The following code
is working.

 //Xively Temperature Sensor 
//DS18B20 code from, http://milesburton.com/Main_Page?title=Dallas_Temperature_Control_Library

#include <SPI.h>
#include <Ethernet.h>
#include <HttpClient.h>
#include <Xively.h>
#include <OneWire.h>
#include <DallasTemperature.h>

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0E, 0xCA, 0xCB}; // MAC address for your Ethernet shield

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

#define ONE_WIRE_BUS 8   //data wire is plugged into pin 8 on the Arduino 
#define TEMPERATURE_PRECISION 12

OneWire oneWire(ONE_WIRE_BUS);  //Setup a oneWire instance to communicate with any OneWire devices.

DallasTemperature sensors(&oneWire);  //pass our oneWire reference to the Dallas Temperature.

DeviceAddress OutsideThermometer ={ 0x28, 0xB8, 0x6E, 0xDE, 0x04, 0x00, 0x00, 0x81};

char sensorId[] = "sensor_reading";  // Define the strings for our datastream IDs
XivelyDatastream datastreams[] = {
  XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),
};

XivelyFeed feed(676748944, datastreams, 1 /* number of datastreams */);  // Finally, wrap the datastreams into a feed

EthernetClient client;
XivelyClient xivelyclient(client);



void setup() {
  
  Serial.begin(9600);  // put your setup code here, to run once:
  
  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);
  }
  sensors.begin();
  sensors.setResolution(OutsideThermometer, TEMPERATURE_PRECISION);
}

void loop() {
  sensors.requestTemperatures();
  int sensorValue = (sensors.getTempCByIndex(0));  //this is teh code from MBurton 
  datastreams[0].setFloat(sensorValue);

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

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

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

Thanks for pointing out the major screw ups in the code.