DS18B20 not found, Arduino ESP32 NANO

Hi

I can't find my DS18B20, tried three different sensors (one with 1m cable). Have tried 4.7k, 10k and no resistor. Tried different pins for data. Tried different example sketches, from OneWire and Dallas. The output is always that no addresses are found.

Any help appreciated!

#include <OneWire.h>

OneWire  ds(10);

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) {
  discoverOneWireDevices();
  delay(1000);
}

Please, edit your Title to "DS18B29 not found, Arduino ESP32 NANO". the Title should match with yoour picture of the post so that readers are not confused. ESP32 refers to the following board (Fig-1).


Figure-1

I just learned that OneWire.h uses the ESP32 pin numbering and therefore it works if I put pin 21 instead of 10 in the example code above.

OneWire  ds(21);

Reference: Nano ESP32 Selecting Pin Configuration | Arduino Documentation

You have just corrected the title and the the setup has statrted working?

Tell us, what have you done. Post the latest working sketch.

It is a Forum; we need to discuss the problem in order to learn more on the architecture ad programming of ESP32 NANO.

I also added a solution (post #3), is that enough?

NANO ESP32 is a "Arduino NANO/Classic NANO" form factor with the classic NANO pinout. So, decision of decalring OneWire ds(10) is logically correct; but, pracatically it does not work unless the DPin# is chnaged to the original ESP32's GPIO number which is 21.

Now, my query is --
What is the benefit of same pinout of classic NANO when we have to remmeber the corresponding GPIO numbers of ESP32 (Fig-1)?


Figure-1:

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.