Sensor DS18B20 problem

a friend told me that inside it`s lm35

Based on what? How can your "friend" see inside that thing and determine that it is an LM35? Especially when you paid for a DS18B20.

Try this OneWire ROM address scanner. It should print out the address of your DS18B20.

#include <OneWire.h>

#define ONEWIRE_PIN 2
OneWire  ds(ONEWIRE_PIN);

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("");
  }
  Serial.print("\n\r\n\rThat's it.\r\n");
  ds.reset_search();
  return;
}

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

This is the output I get for one DS18B20:

Looking for 1-Wire devices on pin 2
0x28, 0x84, 0x77, 0xA5, 0x05, 0x00, 0x00, 0x09



That's it.

If it doesn't find anything, you haven't wired the sensor properly (or its dead). If it does work, your sketch should also work but add the code I posted in message #4 to see what the Dallas library is seeing.

Pete