DS18B20 and Firebeetle 2 (ESP32-C6) : no device found

Hello, I'm experiencing a particularly strange problem with DS18B20 sensors using a FireBeetle 2: I've used several probes, but OneWire can't return a device, so it always returns -127°C on requestTemperatures.

Here the pin diagram for FireBeetle 2 (ESP32 C6):


(from the seller: Firebeetle 2 Board ESP32-C6 Microcontroller Wiki - DFRobot)

My wiring is very basic using a bread board:

  • DS18B20 with VDD to 3.3V, ground and data to pin 9 (D9)
  • Pull-up 4.7K resistor between data and 3.3V (I also try a lower resistor 2.1K)
  • powering by USB C (in schematics i kept the LiPo battery as it will used with it)

Sorry for the typo in schematics I do not found ESP32-C which have a different pinout...


I used 5 different DS18B20 because I suspected it might be ko:

  • 1 of 1m from az-delivery,
  • 2 of 3m from az-delivery,
  • and 2 of 3m from a Chinese seller.

Here the code I used:

#include <OneWire.h>
#include <DallasTemperature.h>

// GPIO where the DS18B20 is connected to
const int oneWireBus = D9;
// const int oneWireBus = 9;
const byte temperaturePrecision = 11;

OneWire oneWire(oneWireBus);

DallasTemperature sensors(&oneWire);

void setup() {
  Serial.begin(115200);
  pinMode(oneWireBus, INPUT);

  sensors.setResolution(temperaturePrecision);
  sensors.begin();

  Serial.print("Found devices: ");
  Serial.println(sensors.getDeviceCount(), DEC);

  Serial.print("Parasite power is: "); 
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");

  uint8_t address[8];
  if (sensors.getAddress(address, 0)) {
    Serial.print("Address fetched:");
    for (int i = 0; i < 8; i++) {
      Serial.printf("%02X ", address[i]);
    }
  } else {
    Serial.println("Error fetching the address");
  }
}

void loop() {
  Serial.print("loop, pin ");
  Serial.println(oneWireBus);
  sensors.requestTemperatures();
  float temperatureC = sensors.getTempCByIndex(0);
  Serial.print(temperatureC);
  Serial.println("ºC");
  delay(2000);
}

Here is the output:

00:11:23.532 -> Found devices: 0
00:11:23.532 -> Parasite power is: OFF
00:11:23.532 -> Error fetching the address
00:11:23.532 -> loop, pin 9
00:11:23.532 -> -127.00ºC
00:11:25.304 -> loop, pin 9
00:11:26.073 -> -127.00ºC

Software used:

I have no idea why this do not works... any suggestion?

DS18B20 links from az-delivery:

Sorry, but a reading of -127 typically indicates bad wiring or insufficient voltage to the sensor. Can you try connecting the sensors to a 5V Arduino to see if that resolves the issue? Make sure all connections are secure and double-check your wiring.

Thanks. If I found my old arduino I will try on it.

Wirings may be weak as my breadboard is not very young :sweat_smile:

Also, I just noticed that I've wrote this, is it really required?

pinMode(oneWireBus, INPUT);

I don’t think so, as the library typically handles switching the pin mode between output and input as needed, depending on whether it’s writing data to the sensor or receiving a response. I don’t recall ever needing to manually set the pin mode for this sensor.

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