Go Down

Topic: DS18B20 Temperature Sensor returns "No more addresses." (Read 11876 times) previous topic - next topic

arduinotestbox

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:
Code: [Select]
#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!

pluggy

The resistor should be connected to the 5V line rather than Gnd.  (Pull up, not pull down).
http://pluggy.is-a-geek.com/index.html

arduinotestbox

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?

pluggy

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.
http://pluggy.is-a-geek.com/index.html

robtillaart


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
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

arduinotestbox

#5
Feb 22, 2011, 07:36 am Last Edit: Feb 22, 2011, 08:15 am by arduinotestbox Reason: 1
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!

evertharmeling

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

Nick_Pyner


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


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.....

martin_schilliger


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!

alphacheese

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?
Code: [Select]
#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");
}
If you don't have anything helpful to contribute, then DON'T post anything at all.

Nick_Pyner

#10
Dec 11, 2016, 04:41 pm Last Edit: Dec 11, 2016, 04:47 pm by Nick_Pyner
What else can I try?
Code: [Select]
// 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.

el_supremo

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
Don't send me technical questions via Private Message.

el_supremo

#12
Dec 11, 2016, 05:34 pm Last Edit: Dec 11, 2016, 05:55 pm by el_supremo
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
Don't send me technical questions via Private Message.

alphacheese

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?
If you don't have anything helpful to contribute, then DON'T post anything at all.

alphacheese

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.
If you don't have anything helpful to contribute, then DON'T post anything at all.

Go Up