Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

DS18B20 with Seeed XIAO ESP32C3 — waterproof probe

Read a DS18B20 waterproof temperature probe on D3 (GPIO5) of a Seeed XIAO ESP32C3 with a 4.7 kΩ pull-up to 3V3 — wiring, code and common faults.

Arduino C++Verified — core esp32 3.3.12, OneWire 2.3.8, 3 Nov 2026Compile-only

Community draft — report a mistake

The DS18B20 probe is sealed in steel, so it can sit in a water tank, an aquarium or soil. On the XIAO ESP32C3 it needs one data pin — D3 — and one 4.7 kΩ pull-up to 3V3.

The sketch counts the probes on the bus at start-up and prints the first probe’s temperature every second.

Wiring

XIAO ESP32C3Only the pins used are shown · 3.3 V logicDS18B20 (1-Wire)4.7k → 3V3D3GND3V3GNDDQVDD
Also needed: 4.7 kΩ resistor.
Every connection
XIAO ESP32C3DS18B20 (1-Wire)WireNotes
3V3VDDred
D3DQyellow
3V3DQredVia 4.7 kΩ — Pull-up between DQ and 3V3.
GNDGNDblack

3.0–5.5 V part, 3.3 V board. Power it from your board's logic voltage (3.3 V on ESP32/Pico, 5 V on Uno) so DQ never goes above the GPIO limit. DQ needs a 4.7 kΩ pull-up to that same supply.

Board quirks

  • D3 is GPIO5. It is the C3’s ADC2 pin, which only matters for analog readings — for a digital 1-Wire bus it is a good, boot-safe choice.
  • Avoid D0, D8 and D9 for the bus: they are strapping pins, and D9 is the BOOT button.
  • The XIAO’s 3V3 regulator easily powers several probes (about 1.5 mA each while converting).

Code

ds18b20-xiaoc3.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// DS18B20 probe on a Seeed XIAO ESP32C3.
// VDD → 3V3, DQ → D3 (GPIO5) with a 4.7 kΩ pull-up to 3V3, GND → GND.
#include <OneWire.h>
#include <DallasTemperature.h>

OneWire oneWire(D3);
DallasTemperature sensors(&oneWire);

void setup() {
  Serial.begin(115200);
  delay(1500);
  sensors.begin();
  Serial.printf("DS18B20 on D3 (GPIO5) - %u sensor(s) found\n", sensors.getDeviceCount());
}

void loop() {
  sensors.requestTemperatures();
  float t = sensors.getTempCByIndex(0);
  if (t == DEVICE_DISCONNECTED_C) Serial.println("No sensor answered - check the 4.7 kOhm pull-up");
  else Serial.printf("Temperature: %.2f C\n", t);
  delay(1000);
}

Library: DallasTemperature (Miles Burton (also install OneWire by Jim Studt / Paul Stoffregen)) — compiled with OneWire 2.3.8.

Expected serial output

Serial Monitor · 115200Output
DS18B20 on D3 (GPIO5) - 1 sensor(s) found
Temperature: 24.88 C
Temperature: 24.94 C

Common errors

Reads −127 °C

Pull-up missing or DQ on the wrong pad. Full fix.

Serial Monitor blank after upload

Press RESET once and reopen the port; the C3’s native USB re-enumerates after flashing.

↑↓ to move · Enter to open