Last week I created on Xively a channel "Temperature".
With a Arduino Uno, Internet shield and SHT15 sensor I see the values on Xively.
It's works well.
I have one question. The values are visible as 24.00 , 25.00 and so on.
Round whole numbers. What I will see is 24.1 , 25.3 and so on.
One number after the zero.
Below my sketch:
Who can advice / help me that the values are one number after the zero?
#include <SPI.h>
#include <SHT1x.h>
#include <Wire.h>
#include <Ethernet.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[] = "YOUR_XIVELY_API_KEY";
// Specify data and clock connections and instantiate SHT1x object
#define dataPin 6
#define clockPin 7
SHT1x sht1x(dataPin, clockPin);
// Define the strings for our datastream IDs
char sensorId[] = "Temperatuur";
XivelyDatastream datastreams[] = {
XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),
};
// Finally, wrap the datastreams into a feed
XivelyFeed feed(29985, datastreams, 1 /* number of datastreams */);
EthernetClient client;
XivelyClient xivelyclient(client);
void setup() {
Wire.begin();
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()
{
float temperature;
float humidity;
// Read values from the sensor
temperature = sht1x.readTemperatureC();
humidity = sht1x.readHumidity();
int sensorValue = temperature;
datastreams[0].setFloat(sensorValue);
//Serial.print("Read sensor value");
Serial.print("Read sensor value", 1);
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);