Pages: [1]   Go Down
Author Topic: DS18B20 problem with finding pin address  (Read 1315 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am using DS18B20 with arduino, I tried compiling the code 'one_wire_address_finder' which is the following:

Code:
// 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 the result that it is giving me in the serial monitor is:
Found '1-Wire' device with address:

0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF CRC is not valid!

what could the reason be?
Thanks
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How have you wired the DS18B20 to the Arduino? The result you get sound like a wrong wiring.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I wired it according to this picture:


I am using a 4.7kohm resistor.
Logged

0
Offline Offline
Shannon Member
****
Karma: 200
Posts: 11672
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It looks right - double check the device is the right way round, check with a multimeter that the device is getting the supply
voltage (some breadboards split the supply rails in the middle for instance).  The result shown suggests the
pull up resistor is correctly wired but the DS18B20 isn't connected properly.

Personally I'd add a 0.1uF decoupling capacitor near the device too, but make sure the device is getting its supply in
the first place.
Logged

[ I won't respond to messages, use the forum please ]

Dallas, TX
Offline Offline
Sr. Member
****
Karma: 10
Posts: 318
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

From the drawing, it looks like it's wired to pin 2 (pins number from 0) instead of pin 3.
Logged

Dee Why NSW
Offline Offline
Full Member
***
Karma: 5
Posts: 206
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I assume the signal wire on pin 2 is just a slack arsed drawing error, but are you sure you have wired up power rails as drawn? It would not work like that on my breadboard as the power lines are discontinuous.

Check the sensor with your fingers. If it is seriously hot, you have it the wrong way round. I did that but the DS18B20 survived, and so did I.
Logged

Pages: [1]   Go Up
Jump to: