Multiple DS18B20 Temperature Sensors on one bus

Another solution is to repeatedly click the 'reset' button on your Arduino. You normally have to click it at least once for the program to work.

Hello,

I had the same problem recently, using the Hacktronics 1-Wire Address Finder. It ended up that the resistor was not placed in the right spot, connecting power and signal. I used a 10k ohm resistor in place of the 4.7k, as that was all I had at the time. It seems to work alright now, reading the same temperature as my analog manual thermometers. I located the address perfectly but when I loaded the multiple-sensor code, with the correct addresses, it failed. I used the bildr guide which can only use 1 temperature sensor. However, a member posted a code with capability for multiple sensors in the code, which solved my problems.

Following is the 1-Wire Address Finder

// This sketch looks for 1-wire devices and
// prints their addresses (serial number) to
// the UART, in a format that is useful in Arduino sketches
// Tutorial: 
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html

#include <OneWire.h>

OneWire  ds(3);  // Connect your 1-wire device to pin 3

void setup(void) {
  Serial.begin(9600);
  discoverOneWireDevices();
}

void discoverOneWireDevices(void) {
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];
  
  Serial.print("Looking for 1-Wire devices...\n\r");
  while(ds.search(addr)) {
    Serial.print("\n\rFound \'1-Wire\' device with address:\n\r");
    for( i = 0; i < 8; i++) {
      Serial.print("0x");
      if (addr[i] < 16) {
        Serial.print('0');
      }
      Serial.print(addr[i], HEX);
      if (i < 7) {
        Serial.print(", ");
      }
    }
    if ( OneWire::crc8( addr, 7) != addr[7]) {
        Serial.print("CRC is not valid!\n");
        return;
    }
  }
  Serial.print("\n\r\n\rThat's it.\r\n");
  ds.reset_search();
  return;
}

void loop(void) {
  // nothing to see here
}

And here is the 'comment' code I am using currently

#include <OneWire.h> 

int DS18S20_Pin = 4; //DS18S20 Signal pin on digital 4

//Temperature chip i/o
OneWire ds(DS18S20_Pin); // on digital pin 4

void setup(void) {
 Serial.begin(9600);
}

void loop(void) {
 float temperature = getTemp();
 Serial.print ("The inside temperature in Degrees Celsius is:") ;
 Serial.println(temperature);
 
 delay(1000); //just here to slow down the output so it is easier to read
 
}


float getTemp(){
 //returns the temperature from one DS18S20 in DEG Celsius

 byte data[12];
 byte addr[8];

 if ( !ds.search(addr)) {
   //no more sensors on chain, reset search
   ds.reset_search();
   return -1000;
 }

 if ( OneWire::crc8( addr, 7) != addr[7]) {
   Serial.println("CRC is not valid!");
   return -1000;
 }

 if ( addr[0] != 0x10 && addr[0] != 0x28) {
   Serial.print("Device is not recognized");
   return -1000;
 }

 ds.reset();
 ds.select(addr);
 ds.write(0x44,1); // start conversion, with parasite power on at the end

 byte present = ds.reset();
 ds.select(addr);  
 ds.write(0xBE); // Read Scratchpad

 
 for (int i = 0; i < 9; i++) { // we need 9 bytes
  data[i] = ds.read();
 }
 
 ds.reset_search();
 
 byte MSB = data[1];
 byte LSB = data[0];

 float tempRead = ((MSB << 8) | LSB); //using two's compliment
 float TemperatureSum = tempRead / 16;
 
 return TemperatureSum;
 
}

Cheers,
Mark