Problem with DS18B20 - not working

Hello,

I have Arduino Nano clone and two DS18B20 thermometers. I connect the thermometers in the standard power mode. When I connect the first sensor, it works. The second sensor does not work - my program can not even find its address on 1Wire. When I connect two sensors, the first measurement is 0.5 C.

Help :slight_smile:

Can you find one at a time?

Read how to use this forum
Top post in every foruforum
Post your code using code tags
And a link to where you got the codd

Ok, It’s my code for searching connected 1-Wire devices. If I connect only first termometer it print one address, if i connect two termometers or i connect only second termometer this code doesn’t write anything.

#include <OneWire.h>

const byte ONEWIRE_PIN = 2;

OneWire onewire(ONEWIRE_PIN);

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

void loop()
{
  byte address[8];

  onewire.reset_search();
  while(onewire.search(address))
  {
    if (address[0] != 0x28)
      continue;

    if (OneWire::crc8(address, 7) != address[7])
    {
      Serial.println(F("Bad address"));
      break;
    }

    for (byte i=0; i<8; i++)
    {
      Serial.print(F("0x"));
      Serial.print(address[i], HEX);

      if (i < 7)
        Serial.print(F(", "));
    }
    Serial.println();
  }

  while(1);
}

(deleted)

@OP

Take the opportunity of learning something on the programming and operation of DS18B20 sensor and then write the codes yourself for finding/printing the address of the sensor.

1. Include OneWire.h library in the sketch.
2. Create an object like ds from the class – OneWire.
3. Attach the sensor’s signal’s DPin number with the object of Step-2.
4. Issue Reset command to the sensor.
5. Collect the address (8-byte) of the sensor and save it in an array named byte addr[8];.
6. Print the content of array of Step-5 along with leading 0s to see the 8-byte (64-bit) value.

Can you write the codes for the above steps and post here? Just try like this:
1. #include<OneWire.h>
2.

Also check the wiring.
You should have only one 4.7 or 10k resistor on tthe Signal line.

Are you using ththe TO92 package or the ones in cans with long leads