ds18s20 and pachube


i wanting display data 3 ds18s20 on pachube feeds, haven't found nay sample code on how this.  do replace analog lines in code digital data?  i want graph status of digital pins state track how turned on.

i'm using example code http://community.pachube.com/files/ethernet_pachube_input_output_1_1.zip

i adapted 1-wire sample code address each sensor directly , generate string pass pachube_in_out function - grab sensor readings before calling pachube_in_out() , avoid pin 10 bus

code: [select]
void readtemphex(byte *addr, byte *data) {
 
 byte i;
 byte present = 0;
 // dallastemperature library can work you!

 ds.reset();
 ds.select(addr);
 ds.write(0x44,1);         // start conversion, parasite power on @ end
 
 delay(1000);     // maybe 750ms enough, maybe not
 // might ds.depower() here, reset take care of it.
 
 present = ds.reset();
 ds.select(addr);    
 ds.write(0xbe);         // read scratchpad

 for ( = 0; < 9; i++) {           // need 9 bytes
   data[i] = ds.read();
   //serial.print(data[i], hex);
   //serial.print(" ");
 }
 //serial.println();
}

// convert hex temperature reading celsius
char *convertreading(byte *hexreading) {
 int highbyte, lowbyte, treading, signbit, tc_100, whole, fract;
 char reading[20]; // array holding converted temp
 
 lowbyte = hexreading[0];
 highbyte = hexreading[1];
 treading = (highbyte << 8) + lowbyte;
 signbit = treading & 0x8000;  // test sig bit
 if (signbit) // negative
 {
   treading = (treading ^ 0xffff) + 1; // 2's comp
 }
 tc_100 = (treading*100/2);    

 whole = tc_100 / 100;  // separate off whole , fractional portions
 fract = tc_100 % 100;
 if ( !signbit ) { // positive temp
   sprintf(reading, "%d.%d",whole, fract < 10 ? 0 : fract);
 }
 else { // negative temp
   sprintf(reading, "%c%d.%d",'-', whole, fract < 10 ? 0 : fract);  
 }
 return reading;
}


here's feed http://www.pachube.com/feeds/14134


Arduino Forum > Forum 2005-2010 (read only) > Software > Interfacing > ds18s20 and pachube


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums