HEllo there ,
i have 6 DS18B20 thermometers and i call a procedure that gets the values of one by one DS18B20…
the problem is that to get the celcius from the thermometers the arduino spends 0,8 seconds foe each one, could it be much more faster…
i gues that it can be, this is the code…
void GETTEMPS()
{
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte addr[8];
float celsius;
String key;
key="";
if ( !ds.search(addr)) {
ds.reset_search();
return;
}
for( i = 0; i < 8; i++)
{
key=key + String(addr[i], HEX);
}
key.replace(" ","");
// Serial.println(key);
type_s = 0;
ds.reset();
ds.select(addr);
ds.write(0x44, 1); // start conversion, with parasite power on at the end
present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
for ( i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();
}
int16_t raw = (data[1] << 8) | data[0];
if (type_s) {
raw = raw << 3; // 9 bit resolution default
if (data[7] == 0x10) {
// "count remain" gives full 12 bit resolution
raw = (raw & 0xFFF0) + 12 - data[6];
}
}
else {
byte cfg = (data[4] & 0x60);
if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms
else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
}
celsius = (float)raw / 16.0;
// Serial.print(" Temperature = ");
//Serial.println(key);
if (key == "28144ddc40011")
{ KITCHEN= celsius;}
if (key == "281684dc400ae")
{ PIPE= celsius;}
if (key == "2811d9db400d4")
{ LIVINGROOM= celsius;}
if (key == "281550dc400b6")
{ OUTSIDE= celsius;}
if (key =="28fc6db4008f")
{ ROOM= celsius;}
if (key =="284fcedb400c4")
{ STOVE= celsius;}
}