

The DS18B20, manufactured by DFRobot (Part ID: DFR0024), is a digital temperature sensor that communicates over a 1-Wire bus. It provides accurate temperature readings with a resolution of 9 to 12 bits and operates within a temperature range of -55°C to +125°C. The sensor is widely used in applications such as environmental monitoring, HVAC systems, and industrial temperature control due to its simplicity, reliability, and ability to connect multiple sensors on a single data line.








| 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 | Configurable: 9 to 12 bits |
| Communication Protocol | 1-Wire |
| Max Current Consumption | 1.5mA during conversion |
| Unique 64-bit Address | Yes |
| Response Time | 750ms (12-bit resolution) |
The DS18B20 sensor typically comes in a 3-pin TO-92 package or as a waterproof probe. Below is the pin configuration:
| Pin Number | Name | Description |
|---|---|---|
| 1 | GND | Ground |
| 2 | DQ | Data line (1-Wire communication) |
| 3 | VDD | Power supply (3.0V to 5.5V) |
The waterproof version of the DS18B20 has three wires:
| Wire Color | Name | Description |
|---|---|---|
| Red | VDD | Power supply (3.0V to 5.5V) |
| Black | GND | Ground |
| Yellow | DQ | Data line (1-Wire communication) |
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 Example");
}
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
}
No Temperature Reading:
Incorrect Temperature Values:
Sensor Not Detected:
Q: Can I use the DS18B20 with a 3.3V microcontroller?
A: Yes, the DS18B20 operates with a voltage range of 3.0V to 5.5V, making it compatible with 3.3V systems.
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 this depends on factors like cable length and power supply.
Q: Can the DS18B20 measure liquid temperature?
A: Yes, the waterproof version of the DS18B20 is suitable for measuring liquid temperatures. Ensure proper insulation of connections to avoid short circuits.
Q: What is the default resolution of the DS18B20?
A: The default resolution is 12 bits, which provides a temperature precision of 0.0625°C.
This documentation provides a comprehensive guide to using the DS18B20 temperature sensor. For further assistance, refer to the DFRobot datasheet or contact their support team.