can't get anything on DS18b20 temp sensor.

Hello I got my first arduino a week ago and I've been messing around with it....
Now that I'm trying to get into the real things I found myself facing a real problem.

I wired the sensor as in the picture:

vdd going to the 5v pin on the arduino, gnd going to a gnd pin on the arduino and the data goes to pin 2 (tried other pins with no success)

when I run the 1wire address finder sketch I founf on the internet I get no devices found.

anyone knows what am I doing wrong?

I went over the code and anything that I should change I did. I already spent 2 hours trying to solve something that I think should be very simple. :frowning:

Please help me,
Thanks in advance

Your wiring seems ok. It should work as is and the problem could be in a program. Show your code.

tried with this:

// 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(2);  // 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 this as well:

// Include the libraries we need
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// arrays to hold device address
DeviceAddress insideThermometer;

/*
 * Setup function. Here we do the basics
 */
void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // locate devices on the bus
  Serial.print("Locating devices...");
  sensors.begin();
  Serial.print("Found ");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" devices.");

  // report parasite power requirements
  Serial.print("Parasite power is: "); 
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");
  
  // Assign address manually. The addresses below will beed to be changed
  // to valid device addresses on your bus. Device address can be retrieved
  // by using either oneWire.search(deviceAddress) or individually via
  // sensors.getAddress(deviceAddress, index)
  // Note that you will need to use your specific address here
  //insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };

  // Method 1:
  // Search for devices on the bus and assign based on an index. Ideally,
  // you would do this to initially discover addresses on the bus and then 
  // use those addresses and manually assign them (see above) once you know 
  // the devices on your bus (and assuming they don't change).
  if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); 
  
  // method 2: search()
  // search() looks for the next device. Returns 1 if a new address has been
  // returned. A zero might mean that the bus is shorted, there are no devices, 
  // or you have already retrieved all of them. It might be a good idea to 
  // check the CRC to make sure you didn't get garbage. The order is 
  // deterministic. You will always get the same devices in the same order
  //
  // Must be called before search()
  //oneWire.reset_search();
  // assigns the first address found to insideThermometer
  //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");

  // show the addresses we found on the bus
  Serial.print("Device 0 Address: ");
  printAddress(insideThermometer);
  Serial.println();

  // set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions)
  sensors.setResolution(insideThermometer, 9);
 
  Serial.print("Device 0 Resolution: ");
  Serial.print(sensors.getResolution(insideThermometer), DEC); 
  Serial.println();
}

// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
  // method 1 - slower
  //Serial.print("Temp C: ");
  //Serial.print(sensors.getTempC(deviceAddress));
  //Serial.print(" Temp F: ");
  //Serial.print(sensors.getTempF(deviceAddress)); // Makes a second call to getTempC and then converts to Fahrenheit

  // method 2 - faster
  float tempC = sensors.getTempC(deviceAddress);
  Serial.print("Temp C: ");
  Serial.print(tempC);
  Serial.print(" Temp F: ");
  Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit
}
/*
 * Main function. It will request the tempC from the sensors and display on Serial.
 */
void loop(void)
{ 
  // call sensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");
  
  // It responds almost immediately. Let's print out the data
  printTemperature(insideThermometer); // Use a simple function to print out the data
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}

the second one is the dallas library and it gives me one line of gibberish… :frowning:

Wire up one sensor in non-parasite mode (the sensor's pin 3 to Vdd) and try the first sketch that you posted.

Pete

nothing. :frowning:

also replaced a sensor and replaced a resistor (another 4.7K and tried 2.2K)

ok now that's new....
I can't get to the serial monitor.... it says that the board is not available....

connected pin 3 to vdd, connected the resistor between the rail of pin 1 and pin 2, connected the data to pin 2 on the arduino and the sensor, and the gnd to pin 1.....

did I do everything right?

I don't understand some of what you wrote. In particular, "connected the resistor between the rail of pin 1 and pin 2," doesn't sound right.

pin 3 of the sensor goes to Vdd.
pin 2 of the sensor goes to pin 2 of the Arduino
pin 1 of the sensor goes to ground.
One end of the resistor goes to Vdd and the other goes to pin 2 of the sensor.

Pete

It was the first thing I've tried...

nothing.
already tried few other resistors, few values and few of the same value.
tried 4 different sensors.

tried connecting the GND on the digital pins on the arduino as I read somewhere that this might help...
tried 3.3V and 5V.... I'm not sure what else I can try...

Hmm..., did you buy sensors on ebay or ali? Maybe bad batch. Sometimes people complain.
The value of resistor is not a problem if the wires are not extremely long, 4k7 is pretty good value.

yeah I bought from Ebay.... so now what? should I check them all? should I buy from somewhere else?
I needed those for my project and now I'm stuck.

Please let me know what I can do.
Thanks.

Try to buy from some local shop or from internet shops like TME, Mouser, Farnell..., which are authorised distributors.
BTW there is a lot of fakes on the ebay.

Wire up one of the sensors again with non-parasite power. Try it.
If it fails take a photo of it, which clearly shows all the wiring, and attach the photo here with a copy of the code which you used.

Pete

https://postimg.org/image/mh8e6ixu3/
This is the wiring and the code is the same but I’ll post it again:

// 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(2);  // 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
}

Your code is kosher, and the same as I use. Check that you have not installed the DS18B20 the wrong way round. If it gets very hot, you have.

Apart from one out of the 10 that I bought they all stayed cold. One of them did get very hot and I plugged it in the same way. So I am not sure what happened there.
I can try inserting only that one the opposite way but I don't think that was the problem. Any other ideas before I go and buy more and throw these out? :frowning:

Have you tested that power is getting to the sensor, i.e. the breadboard is kosher? I have heard of dud sensors but never experienced it. There have even been stories of DS18B20s not actually being DS18B20s. perhaps a better way of ensuring they are is to get them properly packaged, like this http://www.ebay.com.au/itm/10pcs-3m-10ft-Durable-Waterproof-Digital-Temperature-Temp-Sensor-Probe-DS18b20-/331287537189?hash=item4d2246a625:g:J5UAAOxyOypSWq-v
You can get them with female terminals too, but I prefer bare wire with soldered tip and a screw terminal block.

I don't need it waterproof or at this length... do you have any other listing that are with the tiny head? I also have a space limitation.
I'll buy 1 from a local store and I'll see if it's the sensor fault or the wiring. But until I do get one if you think something I did was wrong then please let me know what to check.

Your wiring looks kosher, and your code is kosher, hence my comment. Just stay away from parasite power.

Show the real photo of your wiring, just one sensor without parasite power.

Ok wait isn't that what I posted?
The non parasite option?
Because as I understand it I posted the regular option of the wiring in a link above.