Help with DS18B20, not found

Hi,

I have a single DS1820B and the OneWire library from OneWire Arduino Library, connecting 1-wire devices (DS18S20, etc) to Teensy

I have pin 1 to gnd, pin 2 to digital pin 10 on my uno and pin 3 to +5v. I also have a 4k7 resistor on my breadboard across pins 2 & 3 which I believe is correct.

I loaded the example shipped with the OneWire lib, checked the bus pin was correct and pushed it to my uno but it does not find my sensor, serial output is simply "No more addresses"

I have tried two different DS18B20 sensors and two different resistors (of the same value). I've stripped my breadboard of everything else and I have 4.96v to the sensor according to my multimeter. I'm 99.99% sure everything is wired correctly as per the pinouts on http://datasheets.maxim-ic.com/en/ds/DS18B20.pdf

Any ideas what else I could be missing?

Thanks in advance.

Any ideas what else I could be missing?

Posting your code?

have you tried - MilesBurton.com - works like a charm on the UNO

robtillaart:

Any ideas what else I could be missing?

Posting your code?

The code is simply the sample included with the OneWire library...

#include <OneWire.h>

/* DS18S20 Temperature chip i/o */

OneWire  ds(10);  // on pin 10

void setup(void) {
  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();
    delay(250);
    return;
  }
  ....

robtillaart:
have you tried - MilesBurton.com - works like a charm on the UNO

I tried this also and loaded the example sketch that ships with that library, also the same result.

Sounds more and more like hardware.

  • how long is the cable used?

  • have you tried without the resistor?

  • did you (double) check the pin 1 and 3

  • did you (double) checked the cables?

I assume you have but I can't think of anythink better yet ...

robtillaart:
Sounds more and more like hardware.

  • how long is the cable used?

  • have you tried without the resistor?

  • did you (double) check the pin 1 and 3

  • did you (double) checked the cables?

I assume you have but I can't think of anythink better yet ...

Yeah I agreee it sounds like hardware but im honestly sure everything is hooked up correctly.

I had soldered wire onto the first sensor, but we're talking 20cm max wich I hope is ok as I plan eventually to run these at ~ 100 meters. I deicided I might have fried the sensor with heat from the soldering iron so took a new one and plugged it directly into the breadboard.

I've got voltage at the sensor so obviously those cables are ok, I've got continuity from pin 2 back to pin 10 on the uno so that rules out any broken wire I guess. I've tried pin 2 back to a different digital pin on the uno too but to no avail.

Im sure I have the pins in the correct order, if I look at the sensor with the flat face towards me and legs pointing downward, leg 1 is on the left and is going to gnd, the right hand leg to +5v. That said they are going to gnd & +5v rails on the breadboard but the voltage is there so shouldnt make any difference right?

I have not tried without the resistor, Im really new to this so I wasnt sure if I would do any damage running without a resistor but I can try that and see what happens.

Not sure if this makes any odds but originally when I ran the "Single" sketch from the Dallas temp lib, I was getting no sensors found and a temp of -127c for address 0000000000000000

Without the resistor, still 0 devices found but the temp is now 0c

Dallas Temperature IC Control Library Demo
Locating devices...Found 0 devices.
Parasite power is: OFF
Unable to find address for Device 0
Device 0 Address: 0000000000000000
Device 0 Resolution: 0
Requesting temperatures...DONE
Temp C: 0.00 Temp F: 32.00

outofsight:
I was getting no sensors found and a temp of -127c for address 0000000000000000

I looked at these sensors a few weeks back. I seem to recall that you had to run some initial software to get the Device Address which is unique for each sensor, and then put that device address into your code that is receiving the temp value from that specific sensor. Each sensor has a unique device address, and this allows you to have multiple sensors on the same line connected to the same pin, and you're able to query the value from a specific sensor on that line by using its unique address.

Hope that helps.

  • can you measure 5V at the sensor side?

DaveO:
I looked at these sensors a few weeks back. I seem to recall that you had to run some initial software to get the Device Address which is unique for each sensor, and then put that device address into your code that is receiving the temp value from that specific sensor. Each sensor has a unique device address, and this allows you to have multiple sensors on the same line connected to the same pin, and you're able to query the value from a specific sensor on that line by using its unique address.

Hope that helps.

Thanks but I already know this. Calling the search method from the OneWire library should find all of the addresses on the bus, I am calling this, my problem is that it is not finding anything on the bus though :frowning:

robtillaart:

  • can you measure 5V at the sensor side?

yes, well 4.97v between pins 1 & 3

Unfortunately I don't know what's wrong, but I bought several DS18B20's a few weeks ago.

The onewire sample example apparently is written for the DS18S20, not the B version.
When I run it, all sensors/addresses are found but I get no sensor-readings, error-msgs keep telling me "device is not a DS18S20 family device".

I did get values of -127 C after accidentally having plugged in one LM335 (and a few DS18B20's) on the bus. For some reason 85C and 0C are values I've seen several times on all sensors, but I haven't paid too much attention to know what I did wrong to get that on display.

Using the dallastemperature-Lib I do get the correct readings though.

@Simpson_Jr
Somewhere in your code is the model ID, you should check your code for this magic number and replace it

#define DS18S20MODEL 0x10
#define DS18B20MODEL 0x28
#define DS1822MODEL 0x22

-127 C is a value returned when it is disconnected
#define DEVICE_DISCONNECTED -127

0C is a value when there is nothing written in the variable to hold the temperature.

85C is the power-on reset value of the temperature register (datasheet DS18B20).

FYI, #defines from Dallas Temp Lib.

Thanks Rob for the info,
As told I already got the stuff working. I just run the onewire-sample to see what would happen and gave my info hoping I could make a contribution. Reading back my message I can see you may have interpreted as a question, sorry for not writing it better.

@simpson_jr
It might answer the particular values you got :wink:

This might help to ensure I am not just being dim

I think the 4,7k resistor is supposed to be between sensor pin 2 and 5v+

Please check my thinking.

ps .. conflict of info here. Your original post and the wiring diagram you just posted have the resistor in different positions ?

DaveO:
I think the 4,7k resistor is supposed to be between sensor pin 2 and 5v+

Please check my thinking.

Arrgghhh yes, sorry that diagram was done in a rush and is, as you pointed out incorrect. My resistor is actually between pin 2 and +5v however....

As I was in the process of putting a new diagram together I happen to notice that I am indeed being dim, I appear to have ordered 4R7 not 4K7 resistors which one would assume is the reason things are not working.

I do not have any 4K7 resistors (anything common I could rob one of these from?) so cannot confirm until I have one.

Thanks for all of your help guys, sorry to have been a fool

I also didn't have 4k7 available for my last test (too lazy to get one from the attic), but 4x1K in series worked perfectly. 4r7 will indeed cause problems, but as pull up I guess 4k7 isn't really a critical value.
It wouldn't surprise me if anything between 3k3 and 10k works.
You should be able to find resistors in the right range in most electronic equipment.

The schematics given (with resistor connected to data and +5v) is exactly what tells me it's 21.87C/71.37F in my room right now.

Talking about fools, I love meeting equals :wink:

Simpson_Jr:
It wouldn't surprise me if anything between 3k3 and 10k works.

You're spot on. I managed to savlage a 3k3 from an old board and now I am getting a reading, finally.

Simpson_Jr:
Talking about fools, I love meeting equals :wink:

Pleased to meet you then :smiley:

Thanks again to everyone for their input on this.