

The DS18B20 Digital Temperature Sensor, manufactured by DF Robot (Part ID: Temperature Sensor), is a versatile and highly accurate temperature sensor. It provides temperature readings in the range of -55°C to +125°C with a resolution of up to 12 bits. The sensor communicates using a 1-Wire interface, enabling multiple sensors to share a single data line. This makes it an excellent choice for applications requiring distributed temperature monitoring.








The DS18B20 sensor is designed for ease of use and reliable performance. Below are its key technical details:
| Parameter | Value |
|---|---|
| Operating Voltage | 3.0V to 5.5V |
| Temperature Range | -55°C to +125°C |
| Accuracy | ±0.5°C (from -10°C to +85°C) |
| Resolution | 9 to 12 bits (programmable) |
| Interface | 1-Wire |
| Maximum Current Draw | 1.5mA during conversion |
| Communication Protocol | 1-Wire digital protocol |
| Response Time | < 750ms (12-bit resolution) |
The DS18B20 sensor typically comes in a 3-pin TO-92 package. Below is the pin configuration:
| Pin | Name | Description |
|---|---|---|
| 1 | GND | Ground pin, connect to the ground of the circuit |
| 2 | DQ | Data pin, used for 1-Wire communication. Requires a pull-up resistor (4.7kΩ) |
| 3 | VDD | Power supply pin, connect to 3.0V to 5.5V |
Wiring the Sensor:
1-Wire Communication:
Power Modes:
Below is an example of how to use the DS18B20 with an Arduino UNO. This code uses the popular DallasTemperature and OneWire libraries.
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is connected to pin 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass the oneWire reference to DallasTemperature library
DallasTemperature sensors(&oneWire);
void setup() {
Serial.begin(9600); // Start serial communication at 9600 baud
sensors.begin(); // Initialize the DS18B20 sensor
}
void loop() {
Serial.println("Requesting temperature...");
sensors.requestTemperatures(); // Send command to get temperature readings
// Fetch and print the temperature in Celsius
float temperatureC = sensors.getTempCByIndex(0);
if (temperatureC != DEVICE_DISCONNECTED_C) {
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.println(" °C");
} else {
Serial.println("Error: Sensor not found or disconnected!");
}
delay(1000); // Wait 1 second before the next reading
}
No Temperature Reading:
Inconsistent Readings:
Sensor Not Detected:
Temperature Stuck at -127°C or 85°C:
Q1: Can I connect multiple DS18B20 sensors to the same data line?
Yes, the DS18B20 supports multiple sensors on a single data line. Each sensor has a unique 64-bit address for identification.
Q2: What is the maximum cable length for the DS18B20?
The maximum cable length depends on the environment and power mode. In ideal conditions, it can reach up to 100 meters with proper pull-up resistance.
Q3: Can the DS18B20 operate in water?
Yes, but only if it is housed in a waterproof casing. Many DS18B20 sensors are available in waterproof versions for such applications.
Q4: What happens if I don't use a pull-up resistor?
The sensor will not communicate properly without a pull-up resistor on the data line.
Q5: Can I use the DS18B20 with a 3.3V microcontroller?
Yes, the DS18B20 operates within a voltage range of 3.0V to 5.5V, making it compatible with 3.3V systems.