DS18B20 probes are ideal for water tanks, solar water heaters and freezers. Because every probe has a unique 64-bit address, any number of them can share one pin.
On the S3-DevKitC-1 use GPIO5 for the bus with one 4.7 kΩ pull-up to 3V3. The sketch lists every probe it finds and its temperature every 2 s.
Wiring
| ESP32-S3-DevKitC-1 | DS18B20 (1-Wire) | Wire | Notes |
|---|---|---|---|
| 3V3 | VDD | red | |
| 5 | DQ | yellow | |
| 3V3 | DQ | red | Via 4.7 kΩ — One pull-up for the whole bus, however many probes. |
| GND | GND | black |
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
- GPIO5 has no boot role. Keep 1-Wire pull-ups off the S3’s strapping pins (0, 3, 45, 46) — a pull-up on GPIO45 can select 1.8 V flash and stop the board booting.
- Wire all probes in parallel (red to 3V3, black to GND, yellow to GPIO5). The sketch prints the last two bytes of each probe’s address so you can label them — tank top, tank bottom, and so on.
- Over 5 m of cable, drop the pull-up to 2.2 kΩ and use twisted pair.
Code
// DS18B20 probes on an ESP32-S3-DevKitC-1 — reads every probe on the bus.
// VDD → 3V3, DQ → GPIO5 with a 4.7 kΩ pull-up to 3V3, GND → GND.
#include <OneWire.h>
#include <DallasTemperature.h>
constexpr uint8_t ONE_WIRE_PIN = 5;
OneWire oneWire(ONE_WIRE_PIN);
DallasTemperature sensors(&oneWire);
void setup() {
Serial.begin(115200);
sensors.begin();
Serial.printf("DS18B20 on GPIO5 — %u sensor(s) found\n", sensors.getDeviceCount());
}
void loop() {
sensors.requestTemperatures();
uint8_t n = sensors.getDeviceCount();
for (uint8_t i = 0; i < n; i++) {
DeviceAddress addr;
if (!sensors.getAddress(addr, i)) continue;
float t = sensors.getTempC(addr);
Serial.printf("Probe %u (…%02X%02X): %.2f °C\n", i, addr[6], addr[7], t);
}
if (n == 0) Serial.println("No sensor answered — check the 4.7 kΩ pull-up and DQ wire");
delay(2000);
}// DS18B20 probes on an ESP32-S3-DevKitC-1 — reads every probe on the bus.
// VDD → 3V3, DQ → GPIO5 with a 4.7 kΩ pull-up to 3V3, GND → GND.
#include <OneWire.h>
#include <DallasTemperature.h>
constexpr uint8_t ONE_WIRE_PIN = 5;
OneWire oneWire(ONE_WIRE_PIN);
DallasTemperature sensors(&oneWire);
void setup() {
Serial.begin(115200);
sensors.begin();
Serial.printf("DS18B20 on GPIO5 — %u sensor(s) found\n", sensors.getDeviceCount());
}
void loop() {
sensors.requestTemperatures();
uint8_t n = sensors.getDeviceCount();
for (uint8_t i = 0; i < n; i++) {
DeviceAddress addr;
if (!sensors.getAddress(addr, i)) continue;
float t = sensors.getTempC(addr);
Serial.printf("Probe %u (…%02X%02X): %.2f °C\n", i, addr[6], addr[7], t);
}
if (n == 0) Serial.println("No sensor answered — check the 4.7 kΩ pull-up and DQ wire");
delay(2000);
}Library: DallasTemperature (Miles Burton (also install OneWire by Jim Studt / Paul Stoffregen)) — compiled with OneWire 2.3.8.
Expected serial output
DS18B20 on GPIO5 — 2 sensor(s) found
Probe 0 (…A1C3): 26.44 °C
Probe 1 (…07F2): 31.06 °CDS18B20 on GPIO5 — 2 sensor(s) found Probe 0 (…A1C3): 26.44 °C Probe 1 (…07F2): 31.06 °C
Common errors
Reads −127 °C
Missing pull-up or broken DQ wire. Full fix.
Found fewer probes than connected
One probe has a bad joint, or the cable run is too long for 4.7 kΩ — try 2.2 kΩ.