DS18B20 Gives wrong readings

Hi,

Im using DS18B20 waterproof temperature sensor, and the measuring always show me -127 degrees. I checked the sensor with scope and I saw that the sensor make pulses on his output, so the sensor is proper. somebody know why it happens and how can I solve this problem?
By the way, I tried more than one code and the result is the same.

Thank you and have a nice day,
Roi

Either you have wired the sensor incorrectly, or the sensor is not functional.

Use this onewire scanner to find the rom address for the sensor. If it doesn't find an address, your sensor isn't wired correctly. First edit this line:

#define ONEWIRE_PIN 3

and change it to whichever pin number you are using for the sensor bus. Then run it.

Pete

// This sketch looks for 1-wire devices and
// prints their addresses (serial number) to
// the serial monitor, in hexadecimal format
// so that the ROM code can be copied and pasted
// into a sketch.
// Pete El_Supremo
#include <OneWire.h>

#define ONEWIRE_PIN 3

OneWire ds(ONEWIRE_PIN);

int wire_count = 0;

void setup(void)
{
  Serial.begin(9600);
  while(!Serial);
  delay(2000);
  discoverOneWireDevices();
}

void discoverOneWireDevices(void)
{
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];
  
  Serial.print("Looking for 1-Wire devices on pin ");
  Serial.println(ONEWIRE_PIN);
  
  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.println("");
    wire_count++;
  }
  if(wire_count)Serial.print("\nThat's all.\n");
  else {
    Serial.print("No Onewire devices found on Pin ");
    Serial.println(ONEWIRE_PIN);
  }
  ds.reset_search();
}

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

el_supremo:
Use this onewire scanner to find the rom address for the sensor. If it doesn't find an address, your sensor isn't wired correctly. First edit this line:

#define ONEWIRE_PIN 3

and change it to whichever pin number you are using for the sensor bus. Then run it.

Pete

// This sketch looks for 1-wire devices and

// prints their addresses (serial number) to
// the serial monitor, in hexadecimal format
// so that the ROM code can be copied and pasted
// into a sketch.
// Pete El_Supremo
#include <OneWire.h>

#define ONEWIRE_PIN 3

OneWire ds(ONEWIRE_PIN);

int wire_count = 0;

void setup(void)
{
  Serial.begin(9600);
  while(!Serial);
  delay(2000);
  discoverOneWireDevices();
}

void discoverOneWireDevices(void)
{
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];
 
  Serial.print("Looking for 1-Wire devices on pin ");
  Serial.println(ONEWIRE_PIN);
 
  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.println("");
    wire_count++;
  }
  if(wire_count)Serial.print("\nThat's all.\n");
  else {
    Serial.print("No Onewire devices found on Pin ");
    Serial.println(ONEWIRE_PIN);
  }
  ds.reset_search();
}

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

Thank you very much!