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 ESP32S3 — wiring and code

Read a DS18B20 waterproof probe on D1 (GPIO2) of a Seeed XIAO ESP32S3 with a 4.7 kΩ pull-up to 3V3, using the board’s D-pin names.

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

Community draft — report a mistake

A DS18B20 probe and a XIAO ESP32S3 make a compact water or soil thermometer. Wire the probe to 3V3, GND and D1, with a 4.7 kΩ pull-up from D1 to 3V3.

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

Wiring

XIAO ESP32S3Only the pins used are shown · 3.3 V logicDS18B20 (1-Wire)4.7k → 3V3D1GND3V3GNDDQVDD
Also needed: 4.7 kΩ resistor.
Every connection
XIAO ESP32S3DS18B20 (1-Wire)WireNotes
3V3VDDred
D1DQyellow
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

  • D1 is GPIO2 on the XIAO S3. OneWire oneWire(D1) uses the right pin; OneWire oneWire(1) would be GPIO1, the pad printed D0.
  • Keep the pull-up off D2 (GPIO3), the only strapping pin on the XIAO S3’s edge.
  • OneWire 2.3.8 supports the S3, so DallasTemperature works as on any ESP32.

Code

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

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

void setup() {
  Serial.begin(115200);
  uint32_t t0 = millis();
  while (!Serial && millis() - t0 < 3000) {}
  sensors.begin();
  Serial.printf("DS18B20 on D1 (GPIO2) - %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 D1 (GPIO2) - 1 sensor(s) found
Temperature: 25.94 C
Temperature: 26.00 C

Common errors

Reads −127 °C

Pull-up missing or DQ on another pad. Full fix.

Readings stop after a while on battery

Long cable and low battery. Keep the cable short or use 2.2 kΩ.

↑↓ to move · Enter to open