

The DS18B20 is a digital temperature sensor manufactured by DFRobot, designed for precise temperature measurement in a wide range of applications. This sensor communicates using the 1-Wire protocol, allowing multiple sensors to be connected to a single data line. It is widely used in weather monitoring systems, industrial temperature control, and home automation projects due to its accuracy and ease of use.








The DS18B20 sensor offers reliable performance with the following key specifications:
| 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 |
| Maximum Current Draw | 1.5mA during conversion |
| Waterproof Version | Available (encased in stainless steel) |
The DS18B20 sensor typically has three pins. Below is the pinout description:
| Pin | Name | Description |
|---|---|---|
| 1 | GND | Ground connection |
| 2 | DQ | Data line for 1-Wire communication |
| 3 | VDD | Power supply (3.0V to 5.5V) |
Note: A 4.7kΩ pull-up resistor is required between the DQ pin and VDD for proper 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 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
Serial.println("DS18B20 Temperature Sensor Initialized");
}
void loop() {
sensors.requestTemperatures(); // Send command to get temperature readings
float temperatureC = sensors.getTempCByIndex(0); // Get temperature in Celsius
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:
Intermittent Communication:
Q: Can I use the DS18B20 with a 3.3V microcontroller?
A: Yes, the DS18B20 operates within 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 practical limitations like power supply and signal integrity may reduce this number.
Q: What is the purpose of the pull-up resistor?
A: The pull-up resistor ensures proper communication on the 1-Wire bus by keeping the data line at a high logic level when idle.
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 sensor into your projects for accurate and reliable temperature measurements.