

The DS18B20, manufactured by DFRobot (Part ID: DFR0024), is a digital temperature sensor that communicates using a 1-Wire interface. It is capable of providing temperature readings with a resolution of 9 to 12 bits, offering a measurement range from -55°C to +125°C. This sensor is widely used in applications requiring precise temperature monitoring, such as HVAC systems, weather stations, industrial automation, and home automation projects.








| 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 |
| Interface | 1-Wire |
| Maximum Current Draw | 1.5mA during conversion |
| Conversion Time | 93.75ms (9-bit) to 750ms (12-bit) |
| Unique 64-bit Address | Yes |
The DS18B20 is available in a 3-pin TO-92 package. Below is the pinout:
| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | GND | Ground (0V reference) |
| 2 | DQ | Data line for 1-Wire communication |
| 3 | VDD | Power supply (3.0V to 5.5V) |
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 1-Wire 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
}
void loop() {
sensors.requestTemperatures(); // Send command to get 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
}
No Temperature Reading:
Incorrect Temperature Values:
Sensor Not Detected:
Slow Response Time:
Q: Can I connect multiple DS18B20 sensors to the same data line?
A: Yes, the DS18B20 supports multiple sensors on the same 1-Wire bus. Each sensor has a unique 64-bit address for identification.
Q: What is the maximum cable length for the DS18B20?
A: The maximum cable length depends on the power supply and pull-up resistor value. Typically, lengths up to 30 meters are achievable with proper wiring.
Q: Can the DS18B20 operate without a dedicated power supply?
A: Yes, it can operate in parasitic power mode, but this requires careful timing and is less reliable.
Q: How do I change the resolution of the DS18B20?
A: The resolution can be configured by writing to the sensor's configuration register. Refer to the datasheet for detailed instructions.
This concludes the documentation for the DS18B20 digital temperature sensor. For further details, refer to the DFRobot datasheet or contact technical support.