MaLi:
I had it working in this format last year using a wired arduino ethernet interface.........
code is not working anymore ?? have the Pachube guys changed the requirements for csv format ??
If your code worked before but not now, that is very likely the cause of your problem. Your code looks very alien, and that might confirm it. There are two new libraries, Cosm.h and HttpClient.h and I couldn't get any joy until I used them. You can connect multiple sensors to one pin and, since that worked before, I guess that isn't the problem now.
The code below is for two thermometers on pin 3. It exports to cosm over Ethernet and to PLX at home. The important bit is that it shows how to talk to cosm (Pachube).
/*
From cosm library example and lifts from a lot of others
particularly from Stanley in Kuala Lumpur.
Use your own DS18B20 addresses, keys etc.
Note that the feed id is in line 42.
*/
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <Ethernet.h>
#include <HttpClient.h>
#include <Cosm.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,14,5,6,7); // patchwire is to A0 (pin14) on this proto
byte InThermo[8] = {
0x28, 0x69, 0xC2, 0xB0, 0x03, 0x00, 0x00, 0X9F};
byte OutThermo[8] = {
0x28, 0x7A, 0x8B, 0xC0, 0x03, 0x00, 0x00, 0x2F};
#define ONE_WIRE_BUS 3
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char cosmKey[] = "l6a.......................................0Zz0g";
int sensorPin = 3;
int k=0;
// Define the strings for our datastream IDs
char sensorId0[] = "InThermo";
char sensorId1[] = "OutThermo";
char calcId1[] = "diff";
const int bufferSize = 140;
char bufferValue[bufferSize]; // enough space to store the string we're going to send
CosmDatastream datastreams[] = {
CosmDatastream(sensorId0, strlen(sensorId0), DATASTREAM_FLOAT),
CosmDatastream(sensorId1, strlen(sensorId1), DATASTREAM_FLOAT),
CosmDatastream(calcId1, strlen(calcId1), DATASTREAM_FLOAT),
};
// Finally, wrap the datastreams into a feed
CosmFeed feed(83153, datastreams, 3 /*put your number here */);
EthernetClient client;
CosmClient cosmclient(client);
void setup() {
Serial.begin(9600);
Serial.println("LABEL,Time,TempIn,TempOut,diff");
lcd.begin(16, 2);
lcd.clear();
// lcd.print(" in out diff");
sensors.setResolution(InThermo, 12);
sensors.setResolution(OutThermo, 12);
while (Ethernet.begin(mac) != 1)
{
Serial.println("Error getting IP address via DHCP, trying again...");
delay(10000);
}
}
void loop() {
int ret=0;
//get the values from the DS8B20's
sensors.requestTemperatures();
Serial.print("DATA,TIME, ");
float InTemp = (sensorValue(InThermo));
float OutTemp = (sensorValue(OutThermo));
// float Drain = (sensorValue(DrainThermo));
float diff = OutTemp - InTemp;
datastreams[0].setFloat(InTemp);
datastreams[1].setFloat(OutTemp);
datastreams[2].setFloat(diff);
Serial.print(InTemp);
Serial.print(" , ");
Serial.print(OutTemp);
Serial.print(" , ");
Serial.print (diff);
Serial.println(" , ");
/*
datastreams[2].setFloat(DrainTemp);
Serial.println(datastreams[2].getFloat(DrainTemp));
*/
lcd.setCursor (1,0);
lcd.print(InTemp);
lcd.setCursor (11,0);
lcd.print (OutTemp);
lcd.setCursor(1,1);
lcd.print(" ");
lcd.setCursor(1,1);
lcd.print(diff);
k=k+1;
if (k>8 )
{
ret = cosmclient.put(feed, cosmKey); // SEND FEED TO COSM
lcd.setCursor(12,1);
lcd.print(ret);
k=0;
}
delay(1000);
}
//sensorValue function
float sensorValue (byte deviceAddress[])
{
float tempC = sensors.getTempC (deviceAddress);
return tempC;
}