DS18B20 waterproof temperature probe with ESP32
Supply 3.3-5 V
Bus ONEWIRE
Measures temperature
Pins and ESP32 wiring
| Pin | Role | ESP32 pin | Notes |
|---|---|---|---|
| VDD | Power | 3V3 | Red wire |
| DQ | One-wire data | D25 | Yellow (sometimes white) wire. Needs a 4.7 kΩ pull-up to 3.3 V |
| GND | Ground | GND | Black wire |
Suggested wiring for the 30-pin ESP32 DevKit, avoiding flash, input-only and strapping pins. BoardPilot checks it for you as you wire.
Good to know
- It needs a 4.7 kΩ pull-up resistor between DATA and VCC. Without it the sensor is not found. (Maxim DS18B20 datasheet, Powering the DS18B20; 1-Wire bus pull-up)
- A 12-bit reading takes up to 750 ms. Code that waits less gets the last value, or 85 °C (the power-on value). (Maxim DS18B20 datasheet, Temperature conversion time 750 ms max; power-on reset value +85 °C)
Sources
- Maxim DS18B20 datasheet, Pin description: GND, DQ, VDD; DQ needs a pull-up of about 4.7 kΩ
- Maxim DS18B20 datasheet, Supply 3.0 to 5.5 V
Try it in 3D in BoardPilot
DS18B20 waterproof temperature probe on other boards: wiring and code
Arduino Mega 2560 R3 Arduino Nano Arduino Uno R3 WeAct Black Pill STM32F411CE ESP32-C3-DevKitM-1 ESP32-S3-DevKitC-1 Nordic nRF52840 DK NUCLEO-F401RE Raspberry Pi Pico 2 Raspberry Pi Pico W Raspberry Pi Pico Teensy 4.1
Learn the basics
Lesson: GPIO: pins in and out GPIO Pull-up resistor
Related parts
AM2301 (DHT21) wired temperature + humidityDHT11 temperature + humidityDHT22 (AM2302) temperature + humidityDS18B20 module (KY-001 style)DS18B20 temperature sensor (TO-92)
Part data: CC BY 4.0, free to reuse with credit to BoardPilot.