for ( i = 0; i < 9; i++) { // we need 9 bytes
data01[i] = ds.read();
}
if (OneWire::crc8(data01,8) != data01[8]) {
Serial.println("CRC is not valid!");
return;
}
// convert the data to actual temperature
int raw01 = (data01[1] <<8) | data01[0];
celsius = (float)raw01 / 16.0 ;
Serial.print(" Temp1 : ");
Serial.print(celsius);
Serial.println(" Celsius ");
//--2nd ds18b20--//
ds.reset();
ds.select(dev02);
ds.write(0x44,1); // start conversion, with parasite power on at the end
delay(1000);
for ( i = 0; i < 9; i++) { // we need 9 bytes
data02[i] = ds.read();
}
if (OneWire::crc8(data02,8) != data02[8]) {
Serial.println("CRC is not valid!");
return;
}
// convert the data to actual temperature
int raw02 = (data02[1] <<8) | data02[0];
celsius = (float)raw02 / 16.0 ;
Serial.print(" Temp2 : ");
Serial.print(celsius);
Serial.println(" Celsius ");
}
void loop(void) {
byte i ,data[12];
int raw, devno;
float celsius;
for(devno = 0;devno < 2;devno++) {
ds.reset();
ds.select(dev[devno]);
ds.write(0x44,1); // start conversion, with parasite power on at the end
delay(1000);
for ( i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();
}
if (OneWire::crc8(data,8) != data[8]) {
Serial.println("CRC is not valid!");
return;
}
// convert the data to actual temperature
raw = (data[1] <<8) | data[0];
celsius = (float)raw / 16.0 ;
switch(devno) {
case 0:Serial.print(" Temp1 : ");break;
case 1:Serial.print(" Temp2 : ");break;
}
Serial.print(celsius);
Serial.println(" Celsius ");
}
}