

The DS18B20 Digital Temperature Sensor, manufactured by DFRobot (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 sensing, such as HVAC systems, weather monitoring, industrial automation, and home automation projects.








The DS18B20 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 typically comes in a 3-pin TO-92 package. Below is the pinout description:
| 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.
Wiring the Sensor:
Using Multiple Sensors:
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 connected to the DS18B20 data line
#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
sensors.begin(); // Start the DS18B20 sensor
Serial.println("DS18B20 Temperature Sensor Initialized");
}
void loop() {
sensors.requestTemperatures(); // Request temperature readings
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 Not Working:
sensors.getAddress() function in the DallasTemperature library to retrieve and verify sensor addresses.Interference on Long Cables:
Q: Can the DS18B20 operate without a dedicated power supply?
A: Yes, the DS18B20 can operate in parasite power mode, drawing power from the data line. However, this mode may not work reliably in all setups, especially with long cables or multiple sensors.
Q: How many DS18B20 sensors can I connect to a single data line?
A: Theoretically, you can connect up to 100 sensors on a single data line, but practical limits depend on factors like cable length, power supply, and noise.
Q: What is the default resolution of the DS18B20?
A: The default resolution is 12 bits, but it can be configured to 9, 10, or 11 bits for faster response times.
Q: Can the DS18B20 measure negative temperatures?
A: Yes, the DS18B20 can measure temperatures as low as -55°C. Negative temperatures are represented in two's complement format.
By following this documentation, you can effectively integrate the DS18B20 Digital Temperature Sensor into your projects for accurate and reliable temperature monitoring.