

The DS18B20 is a digital temperature sensor manufactured by DS18B20. It communicates over a 1-Wire bus, requiring only one data line (and ground) for communication. This sensor provides temperature readings in Celsius with a resolution ranging from 9 to 12 bits, making it highly versatile for applications requiring precise temperature monitoring. Its compact design and ease of integration make it a popular choice for hobbyists and professionals alike.








The DS18B20 is designed to operate efficiently in a wide range of environments. 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 | Programmable (9 to 12 bits) |
| Communication Protocol | 1-Wire |
| Max Current Consumption | 1.5mA during conversion |
| Standby Current | 750nA (typical) |
| Conversion Time | 93.75ms (12-bit resolution) |
| Package Types | TO-92, SOIC-8, or waterproof probe |
The DS18B20 typically comes in a 3-pin TO-92 package. Below is the pinout:
| Pin | Name | Description |
|---|---|---|
| 1 | GND | Ground connection |
| 2 | DQ | Data line for 1-Wire communication |
| 3 | VDD | Power supply (optional, can operate in parasite mode) |
Note: In parasite power mode, the sensor can operate without a dedicated VDD pin by drawing power from the data line.
The DS18B20 is straightforward to use in a circuit, thanks to its 1-Wire communication protocol. Below are the steps and considerations for using the sensor:
Basic Wiring:
Parasite Power Mode:
Below is an example of how to use the DS18B20 with an Arduino UNO. This code reads the temperature and displays it on the Serial Monitor.
#include <OneWire.h>
#include <DallasTemperature.h>
// Pin where the DS18B20 data line is connected
#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); // Initialize serial communication at 9600 baud
sensors.begin(); // Start the DS18B20 sensor
}
void loop() {
sensors.requestTemperatures(); // Request temperature from the sensor
float temperatureC = sensors.getTempCByIndex(0); // Get temperature in Celsius
// Check if the reading is valid
if (temperatureC != DEVICE_DISCONNECTED_C) {
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.println(" °C");
} else {
Serial.println("Error: Sensor not detected!");
}
delay(1000); // Wait 1 second before the next reading
}
Sensor Not Detected:
Incorrect Temperature Readings:
Multiple Sensors on the Same Bus:
getAddress() function in the DallasTemperature library to identify each sensor's unique address.Q: Can I use multiple DS18B20 sensors on the same data line?
A: Yes, the DS18B20 supports multiple devices on the same 1-Wire bus. Each sensor has a unique 64-bit address for identification.
Q: What is parasite power mode?
A: In parasite power mode, the sensor draws power directly from the data line, eliminating the need for a dedicated VDD connection.
Q: How do I increase the accuracy of temperature readings?
A: Use the highest resolution (12-bit) setting and ensure the sensor is properly calibrated and powered.
Q: Can the DS18B20 measure negative temperatures?
A: Yes, the DS18B20 can measure temperatures as low as -55°C.
By following this documentation, you can effectively integrate the DS18B20 into your projects for reliable and accurate temperature sensing.