ESP32 DS18B20 Dallas Temperature Sensor

DS18B20 Dallas Temperature Sensor image

DS18B20

Protocol: 1-Wire

Overview

The DS18B20 is a digital temperature sensor widely used in microcontroller-based applications. It communicates via the 1-Wire protocol, requiring only one data line (and ground) for communication. This sensor is known for its high accuracy, durability, and versatility, making it ideal for temperature measurement projects.

About DS18B20 Dallas Temperature Sensor

The DS18B20 is a high-accuracy digital temperature sensor that communicates using a 1-Wire protocol, requiring only a single data line for operation. It is widely used in industrial, weather monitoring, and IoT applications due to its broad temperature range and configurable resolution.

Key Features

  • High Accuracy – ±0.5°C in the -10°C to +85°C range.
  • Wide Operating Range – Measures from -55°C to +125°C.
  • 1-Wire Communication – Requires only one data line + ground, simplifying wiring.
  • Configurable Resolution9-bit to 12-bit selectable resolution.
  • Flexible Power Options – Supports normal & parasite power modes.
  • Compact & Easy to Integrate – Available in a TO-92 package for easy mounting.

🔗 Learn more about the DS18B20 sensor.

Where to Buy

DS18B20 Dallas Temperature Sensor

Starting from

$2 per unit

Amazon com
Amazon.com Ships worldwide
View Price
Amazon de
Amazon.de Ships to EU
View Price
Aliexpress
AliExpress Best value
View Price

Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.

Technical Specifications

Interface 1-Wire
Accuracy ±0.5°C (from -10°C to +85°C)
Operating Range -55°C to +125°C
Voltage 3.0V to 5.5V (typical 3.3V)
Resolution 9-bit to 12-bit (user-configurable)
Conversion Time 93.75ms (12-bit resolution)
Communication Speed Up to 16.3 kbps
Power Modes Normal and Parasite Power Modes
Power Consumption 1mA active, <1µA idle
Package Type TO-92 (commonly used), also available in other packages
Unique Identifier 64-bit unique ROM code for multi-device systems

Pinout Configuration

The VCC pin is used to supply power to the sensor, and it typically requires 3.3V or 5V (refer to the datasheet for specific voltage requirements). The GND pin is the ground connection and must be connected to the ground of your ESP32.

  • Pin 1 (GND): Connects to the ground of the circuit.
  • Pin 2 (DQ): Serves as the data line for 1-Wire communication and can also supply power in parasite power mode.
  • Pin 3 (VDD): Provides power to the sensor, typically connected to 3.3V or 5V.

Note: In parasite power mode, Pin 3 (VDD) is connected to ground, and the sensor derives power from the data line (DQ).

Wiring with ESP32

  • DS18B20 Pin 1 (GND): Connect to the ESP32 GND pin.
  • DS18B20 Pin 2 (DQ): Connect to an available GPIO pin on the ESP32 (e.g., GPIO4). Add a pull-up resistor (typically 4.7kΩ) between DQ and VDD.
  • DS18B20 Pin 3 (VDD): Connect to the ESP32 3.3V pin (or 5V if using a 5V power source).

Note: If using parasite power mode, connect Pin 3 (VDD) to GND, and ensure the pull-up resistor is in place between DQ and 3.3V or 5V.

Troubleshooting Guide

Common Issues

🌡️ One wire DS18B20 reading +85°C

❄️ DS18B20 Reading of -127°C

Debugging Tips

🔍 Serial Monitor

⚡ Voltage Checks

Code Examples

Arduino Example

C++
🔧

ESP-IDF Example

C++
🏠

ESPHome Example

YAML
🛠️

PlatformIO Example

C++
🐍

MicroPython Example

Python

Conclusion

The ESP32 DS18B20 Dallas Temperature Sensor is a powerful environment sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.

For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.

Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.