ESP32 DS18B20 Waterproof Temperature Logger
Log water or soil temperature with a waterproof DS18B20 probe and an ESP32, viewable over Wi-Fi.
- Build time
- 35 min
- Status
- Rule-checked
- Last revised
Passed the automatic wiring rules. Not yet physically built and tested.
Quick answer
To build the ESP32 DS18B20 Waterproof Temperature Logger you need a ESP32 DevKit V1 (30-pin) and DS18B20 Waterproof Temperature Probe, Resistor, 5× Jumper wires + breadboard. It is a beginner project with 5 connections, takes about 35 min and costs roughly ₹500–₹750 in parts.
The DS18B20 talks over a single 1-Wire data line which needs a 4.7 kΩ pull-up resistor to 3.3 V. Forgetting that resistor is the most common reason the sensor reads −127 °C.
Circuit diagram
Open & edit in Circuit BuilderDownload
Parts list
| Qty | Part | Notes | Buy |
|---|---|---|---|
| 1 | ESP32 DevKit V1 (30-pin) | ESP32-WROOM-32 development board with Wi-Fi and Bluetooth, 3.3 V logic and USB power. Common 30-pin DOIT layout. | Amazon.inRobu.in |
| 1 | DS18B20 Waterproof Temperature Probe | 1-Wire digital temperature probe in a stainless-steel tube. | Amazon.inRobu.in |
| 1 | Resistor, 4.7kΩ | Fixed through-hole resistor. Set its value in the properties panel. | |
| 5 | Jumper wires + breadboard | Male/female jumpers as required by the modules' headers. | Amazon.inRobu.in |
Estimated cost: ₹500–₹750 including a breadboard and jumper wires (typical Indian online prices, 2026-11). Some links may be affiliate links, they cost you nothing extra and help keep this site free.
Pin-to-pin wiring
| From | Pin | To | Pin | Type |
|---|---|---|---|---|
| DS18B20 probe | VDD (red) | ESP32 DevKit V1 (30-pin) | 3V3 | power |
| DS18B20 probe | DQ (yellow) | ESP32 DevKit V1 (30-pin) | D4 | signal |
| DS18B20 probe | GND (black) | ESP32 DevKit V1 (30-pin) | GND | ground |
| R pull-up | 1 | DS18B20 probe | DQ (yellow) | signal |
| R pull-up | 2 | ESP32 DevKit V1 (30-pin) | 3V3 | power |
Step-by-step build
- 1
Wire the probe
Red → 3V3, black → GND, yellow → GPIO4.
- 2
Add the pull-up
Put a 4.7 kΩ resistor between the yellow data wire and 3V3.
- 3
Install libraries
Install OneWire and DallasTemperature from the Arduino Library Manager.
AI code-generation prompt
Paste this into Gemini, ChatGPT, Claude or another coding assistant. It includes the exact pin map. Treat the generated code as untested until you have run it.
You are an experienced embedded firmware engineer. Write complete, compilable firmware for the project below. ## Project Title: ESP32 DS18B20 Temperature Logger Description: Waterproof temperature probe logged over Wi-Fi. Board: ESP32 DevKit V1 (30-pin), 3.3 V logic Development environment: Arduino IDE Connectivity: wifi ## Required behaviour Read the DS18B20 every 10 seconds at 12-bit resolution. Keep the last 360 readings (1 hour) in RAM and serve a local web page with the current temperature, min/max and a simple line chart. Treat −127 °C or 85 °C power-on values as read errors. ## Components - 1 × ESP32 DevKit V1 (30-pin) - 1 × DS18B20 Waterproof Temperature Probe - 1 × Resistor (4.7kΩ) ## Exact pin map (do not change these pins) - DS18B20 probe VDD (red) → 3V3 - DS18B20 probe DQ (yellow) → GPIO4 (D4) - DS18B20 probe GND (black) → GND - R pull-up 1 → GPIO4 (D4) - R pull-up 2 → 3V3 ## Libraries I expect you to use - OneWire + DallasTemperature ## Assumptions - Probe wire colours are red = VDD, yellow = DQ, black = GND (check your probe's documentation). ## Requirements for the code - Use only the pins listed above, defined once as named constants at the top. - Non-blocking structure using millis() (no long delay() calls in loop()). - Put all outputs (relays, motors, buzzers) in a safe OFF state in setup() before anything else. - Print readable debug output to Serial at 115200 baud. - Handle sensor read failures (e.g. NaN, timeouts, missing I2C device) without crashing, and report them. - Put thresholds and calibration values in clearly named constants with comments. - Wi-Fi: use placeholder constants WIFI_SSID / WIFI_PASSWORD, reconnect automatically, and keep working locally when Wi-Fi is down. Never hard-code real credentials. ## What to return 1. The complete source file(s), ready to compile in Arduino IDE. 2. The exact libraries (with the library manager names) and board package to install. 3. A short explanation of how the code works and how to calibrate it. 4. A testing checklist I can follow step by step. Do not invent pins, libraries or functions that do not exist. If something in this spec is ambiguous or unsafe, say so before writing code.
Troubleshooting & common mistakes
- Reads −127 °C
- The sensor isn't responding: check the 4.7 kΩ pull-up and the data wire on GPIO4.
- Reads 85 °C
- That's the power-on default; request a conversion and wait for it to complete before reading.
Safety, assumptions & checks
Safety notes
- Keep the ESP32 dry; only the stainless probe end is waterproof.
- GPIO pins are 3.3 V only and are not 5 V tolerant.
- Do not draw more than about 12–20 mA from a single GPIO.
Assumptions
- Probe wire colours are red = VDD, yellow = DQ, black = GND (check your probe's documentation).
Automatic wiring check (rules-2026.11.1)
✔ No problems found by the wiring rules.
The checker finds known wiring mistakes. It is not a simulator and cannot guarantee the circuit is safe or will work.
Viva and interview questions
Questions examiners commonly ask about the parts in this circuit, with short answers.
Q1. What logic voltage does the ESP32 use, and is it 5 V tolerant?
3.3 V. Its GPIO pins are not 5 V tolerant, so 5 V signals need a level shifter or a resistor divider.
Q2. Why use ADC1 pins (GPIO32–39) for analog sensors on the ESP32?
ADC2 is shared with the Wi-Fi radio, so ADC2 readings fail while Wi-Fi is active. ADC1 keeps working.
Q3. Which ESP32 pins are input-only?
GPIO34, 35, 36 (VP) and 39 (VN). They have no output driver and no internal pull-up/pull-down.
Q4. Why does the DS18B20 need a 4.7 kΩ resistor?
The 1-Wire bus is open-drain, so the data line needs a pull-up resistor to VCC.
Q5. How can several DS18B20 sensors share one pin?
Each has a unique 64-bit ROM address, so many sensors can sit on the same 1-Wire bus.
Frequently asked questions
What components do I need for the ESP32 DS18B20 Waterproof Temperature Logger?
You need a ESP32 DevKit V1 (30-pin) and DS18B20 Waterproof Temperature Probe, Resistor, 5× Jumper wires + breadboard, plus a breadboard, jumper wires and a USB cable.
How much does the ESP32 DS18B20 Waterproof Temperature Logger cost to build in India?
About ₹500–₹750 for new parts from Indian online stores (estimate, 2026-11). Reusing a board you already own makes it much cheaper.
How long does it take to build?
About 35 min for a beginner maker, including wiring and uploading code.
Is this project suitable as a college or school project?
Yes. It is a beginner project that suits school science exhibitions, diploma practicals and first-year engineering mini projects. Extend it with a web dashboard or data logging for a bigger project.
What should I do if: Reads −127 °C?
The sensor isn't responding: check the 4.7 kΩ pull-up and the data wire on GPIO4.
What should I do if: Reads 85 °C?
That's the power-on default; request a conversion and wait for it to complete before reading.
Related
ESP32 Smart Irrigation System
Read a capacitive soil moisture sensor with an ESP32 and switch a small 5 V water pump through a relay when the soil gets dry.
ESP32 DevKit V1 (30-pin) · 1 h