DS18B20 Temperature Sensor returns "No more addresses."

After hours of trying, you are my last resort of hope.

I’m using the DS18B20 Temperature Sensor and tried to install it based on this OneWire-tutorial here:
http://www.arduino.cc/playground/Learning/OneWire

As I understand it the breadboard should look like this:

(the flat surface is facing to the front in this picture)
Unfortunately I have no 4.7k resistor, so I took two 2.2K resistors.

The code (taken from the tutorial) is this one:

#include <OneWire.h>

// DS18S20 Temperature chip i/o
OneWire ds(10);  // on pin 10

void setup(void) {
  // initialize inputs/outputs
  // start serial port
  Serial.begin(9600);
}

void loop(void) {
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];

  if ( !ds.search(addr)) {
      Serial.print("No more addresses.\n");
      ds.reset_search();
      return;
  }

  Serial.print("R=");
  for( i = 0; i < 8; i++) {
    Serial.print(addr[i], HEX);
    Serial.print(" ");
  }

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

  if ( addr[0] == 0x10) {
      Serial.print("Device is a DS18S20 family device.\n");
  }
  else if ( addr[0] == 0x28) {
      Serial.print("Device is a DS18B20 family device.\n");
  }
  else {
      Serial.print("Device family is not recognized: 0x");
      Serial.println(addr[0],HEX);
      return;
  }

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

  delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.

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

  Serial.print("P=");
  Serial.print(present,HEX);
  Serial.print(" ");
  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();
    Serial.print(data[i], HEX);
    Serial.print(" ");
  }
  Serial.print(" CRC=");
  Serial.print( OneWire::crc8( data, 8), HEX);
  Serial.println();
}

I am using the OneWire 2.0 library: http://www.pjrc.com/teensy/td_libs_OneWire.html

All I get in the Serial Monitor is “No more addresses.”
What does this error mean? How can I fix it?

Thank you so much for your answers!

DS18B20_Tutorial.png

The resistor should be connected to the 5V line rather than Gnd. (Pull up, not pull down).

Hi Pluggy

Thank you for your fast answer!

I tried that. Now the setup looks like this:

But still I get “No more addresses.”
Any other guesses?

DS18B20_Tutorial2.png

Have you got another DS18B20 you could try ? If you're using 'stock' code it should work. You could try just one 2.2k resistor or a 10k if you have one (its not cast in stone , nor an exact science). No more addresses suggests it isn't seeing anything on the bus.

some additional tests I would do: - test pin 10 - just a simple digitalRead(10) HIGH/LOW test - use other cables. - use another place at the breadboard

Hi Pluggy and robtillaart

Thank you so much for your input!

I tried the following: - use another place at the breadboard and - use other cables. - just one 2.2K resistor instead of the 4.7K-resistor

Not it finds the DS18B20!

Great! :)

PS. @all: if you haven't tried it out yet, use the Dallas Temperature Control Library: http://milesburton.com/index.php/Dallas_Temperature_Control_Library So much more easier to use than the demo-code in the tutorial!

I had the same problem, the 2.2K resistor solved it!! All other tutorials were referring tot the 4.7K one… :expressionless:

evertharmeling:
I had the same problem, the 2.2K resistor solved it!! All other tutorials were referring tot the 4.7K one… :expressionless:

The reason why tutorials refer to 4.7k is that it is the correct value. A 2.2k may be used when the cable is really long - over 10m.

If you don’t have a very long cable and using a 2k2 fixed the problem, it may be because of a bad connection somewhere providing the extra 2.5k, or more…

evertharmeling: I had the same problem, the 2.2K resistor solved it!! All other tutorials were referring tot the 4.7K one... :|

Same here, changed down to 2.2K Resistor, and now it's working again. Before it was working perfectly even with cables around 20m length (1.5mm2 ! XD), but after it startet to rain outside all the sensors just showed 0.0°C…

Thanks for the help here!

Am I the only one on the internet that can’t get these temp sensors to work? I am only using 1 DS18B20 on Uno and 1.6.6 IDE. I am not using parasite mode.

  • I have tried both a 4.7K and a 2.2K resistor (tested ohms on both and good)
  • Tried different locations on bread board
  • Tried different jumper wires
  • Tried several different pins on arduino
  • Tried 3 different DS18B20 sensors

I keep getting “No more addresses” in the serial monitor. What else can I try?

#include <OneWire.h>

// OneWire DS18S20, DS18B20, DS1822 Temperature Example
//
// http://www.pjrc.com/teensy/td_libs_OneWire.html
//
// The DallasTemperature library can do all this work for you!
// http://milesburton.com/Dallas_Temperature_Control_Library

OneWire  ds(2);  // on pin 2 (a 4.7K resistor is necessary)

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

void loop(void) {
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float celsius, fahrenheit;

  if ( !ds.search(addr)) {
    Serial.println("No more addresses.");
    Serial.println();
    ds.reset_search();
    delay(250);
    return;
  }

  Serial.print("ROM =");
  for( i = 0; i < 8; i++) {
    Serial.write(' ');
    Serial.print(addr[i], HEX);
  }

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

  // the first ROM byte indicates which chip
  switch (addr[0]) {
    case 0x10:
      Serial.println("  Chip = DS18S20");  // or old DS1820
      type_s = 1;
      break;
    case 0x28:
      Serial.println("  Chip = DS18B20");
      type_s = 0;
      break;
    case 0x22:
      Serial.println("  Chip = DS1822");
      type_s = 0;
      break;
    default:
      Serial.println("Device is not a DS18x20 family device.");
      return;
  } 

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

  delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.

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

  Serial.print("  Data = ");
  Serial.print(present, HEX);
  Serial.print(" ");
  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();
    Serial.print(data[i], HEX);
    Serial.print(" ");
  }
  Serial.print(" CRC=");
  Serial.print(OneWire::crc8(data, 8), HEX);
  Serial.println();

  // Convert the data to actual temperature
  // because the result is a 16 bit signed integer, it should
  // be stored to an "int16_t" type, which is always 16 bits
  // even when compiled on a 32 bit processor.
  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);
    // at lower res, the low bits are undefined, so let's zero them
    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
    //// default is 12 bit resolution, 750 ms conversion time
  }
  celsius = (float)raw / 16.0;
  fahrenheit = celsius * 1.8 + 32.0;
  Serial.print("  Temperature = ");
  Serial.print(celsius);
  Serial.print(" Celsius, ");
  Serial.print(fahrenheit);
  Serial.println(" Fahrenheit");
}

alphacheese: What else can I try?

// The DallasTemperature library can do all this work for you!

You can try getting rid of that junk software and using something useful

http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html

The one line of code above says it all........and quite a lot about the idiot who wrote that code as well.

Make sure the 4.7k is between 5v and signal, not like in the picture above.

There's nothing wrong with that code. I just tried it on a NANO with a DS18B20 on pin2 with 3k3 pullup and it works. I also put 3 DS18B20 together and it finds all 3. Nothing wrong with the software.

Either your DS18B20s aren't really DS18B20s (apparently has happened) or you aren't wiring it properly.

Pete

If you wired it up as shown in the Fritzing diagrams, then you'll never get it to work. [edit] The diagram in the first post is wrong. Ignore it. The second diagram wires up the DS18B20 for non-parasite mode (which is fine) on pin 10 but the code uses pin 2.[/edit] If that's what you're doing, move the data to pin 2, or change the code to pin 10.

Pete

Yes I am wiring correctly. I have already tried several different pins on arduino. Do you have an idea of what the sensors could be if not DS18B20? Maybe different model, any way to test this idea?

Nick_Pyner: You can try getting rid of that junk software and using something useful

http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html

The one line of code above says it all........and quite a lot about the idiot who wrote that code as well.

Make sure the 4.7k is between 5v and signal, not like in the picture above.

I tried that sketch with still no success. My resistor goes from 5v to signal wire. I have tried 2.2k and 10k resistors. I have tried the address finder sketch as well and it reports back with nothing, blank. Again, all my sensors read like this, both when trying separately and when on parasite or not parasite mode.

Yes I am wiring correctly

That doesn't tell me much. Exactly which pin have you wired the data pin to?

I've also used the code in msg #1(OP) which uses pin 10, and the diagram in msg #2 (which uses pin 10). It works. Both sample sketches work, provided that the 18B20 is wired to the correct pin.

Either your wiring and/or your code are incorrect or you aren't using DS18B20 sensors. Look at the flat surface of the sensors. Do the first two lines have this written on it? DALLAS 18B20

Can you take a clear, focused photo of the way that you have the DS18B20 wired and attach it here?

Pete

el_supremo:

Yes I am wiring correctly

That doesn’t tell me much. Exactly which pin have you wired the data pin to?

I’ve also used the code in msg #1(OP) which uses pin 10, and the diagram in msg #2 (which uses pin 10). It works. Both sample sketches work, provided that the 18B20 is wired to the correct pin.

Either your wiring and/or your code are incorrect or you aren’t using DS18B20 sensors.
Look at the flat surface of the sensors. Do the first two lines have this written on it?
DALLAS
18B20

Can you take a clear, focused photo of the way that you have the DS18B20 wired and attach it here?

Pete

I cannot confirm print on IC as it is a waterproof model and is located in a steel tube with heatshrink tubing, no writing on the outside.

I have tried everything I can think of and read of. Let me regale you. Here is the code I started with. It’s included in the examples of the OneWire Library.

#include <OneWire.h>

OneWire  ds(10);  // on pin 10 (a 4.7K resistor is necessary)

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

void loop(void) {
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float celsius, fahrenheit;
  
  if ( !ds.search(addr)) {
    Serial.println("No more addresses.");
    Serial.println();
    ds.reset_search();
    delay(250);
    return;
  }
  
  Serial.print("ROM =");
  for( i = 0; i < 8; i++) {
    Serial.write(' ');
    Serial.print(addr[i], HEX);
  }

  if (OneWire::crc8(addr, 7) != addr[7]) {
      Serial.println("CRC is not valid!");
      return;
  }
  Serial.println();
 
  // the first ROM byte indicates which chip
  switch (addr[0]) {
    case 0x10:
      Serial.println("  Chip = DS18S20");  // or old DS1820
      type_s = 1;
      break;
    case 0x28:
      Serial.println("  Chip = DS18B20");
      type_s = 0;
      break;
    case 0x22:
      Serial.println("  Chip = DS1822");
      type_s = 0;
      break;
    default:
      Serial.println("Device is not a DS18x20 family device.");
      return;
  } 

  ds.reset();
  ds.select(addr);
  ds.write(0x44);        // start conversion, with parasite power on at the end
  
  delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.
  
  present = ds.reset();
  ds.select(addr);    
  ds.write(0xBE);         // Read Scratchpad

  Serial.print("  Data = ");
  Serial.print(present, HEX);
  Serial.print(" ");
  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();
    Serial.print(data[i], HEX);
    Serial.print(" ");
  }
  Serial.print(" CRC=");
  Serial.print(OneWire::crc8(data, 8), HEX);
  Serial.println();

  // Convert the data to actual temperature
  // because the result is a 16 bit signed integer, it should
  // be stored to an "int16_t" type, which is always 16 bits
  // even when compiled on a 32 bit processor.
  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);
    // at lower res, the low bits are undefined, so let's zero them
    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
    //// default is 12 bit resolution, 750 ms conversion time
  }
  celsius = (float)raw / 16.0;
  fahrenheit = celsius * 1.8 + 32.0;
  Serial.print("  Temperature = ");
  Serial.print(celsius);
  Serial.print(" Celsius, ");
  Serial.print(fahrenheit);
  Serial.println(" Fahrenheit");
}

I have the VCC wire of sensor wired to breadboard rail wired to 5v on arduino (tried different ports on breadboard, confirmed 5.00v coming from arduino). I have ground wire of sensor wired to breadboard rail wired to ground of arduino (tested different ports on breadboard). I have a 4.7K ohm resistor wired from 5v rail wired to data wire of sensor. I have tested a 2.2K ohm and 10K ohm resistor with 5 different sensors. The data wire from breadboard is in digital pin 10 of my uno. I have attempted wiring to pin 2, 3, 4, 7, and 8 and changed accordingly in sketch:

OneWire  ds(10); or OneWire ds(2); or OneWire ds(7); ... etc

I am not using parasite mode, changed code to:

ds.write(0x44);

I have tried running as parasite with VCC wire of sensor disconnected and code:

ds.write(0x44, 1);

I have tried every combination of trying different sensor, in parasite mode or not, different arduino pins, different resistors, different breadboard ports, and different codes. I have tried these codes as well to detect sensor and get ID:

#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
}

Get this reported back:

Looking for 1-Wire devices...



That's it.

I can’t thin of what to try next.

SOLVED

Got it! I found your post here and my data wire and VCC wire were labeled wrong from the manufacturer too! |500x500 This image is wrong for my sensors. For anyone else: the red is VCC and yellow is data on my sensors.

Arrrrggghhhhh. :)

Pete

alphacheese: SOLVED

Got it! I found your post here and my data wire and VCC wire were labeled wrong from the manufacturer too!

This image is wrong for my sensors. For anyone else: the red is VCC and yellow is data on my sensors.

Wow! I haven't heard of that before - just somebody who wrote the instructions being incompetent to instruct. The image is probably wrong for everybody else's sensors too. One would expect red to be 5v, even though the others may vary. (I still think that code is junk)