

The DS18B20 is a digital temperature sensor manufactured by DFRobot, designed for precise temperature measurement in a wide range of applications. It communicates using the 1-Wire protocol, allowing multiple sensors to be connected to a single data line. The sensor provides temperature readings in degrees Celsius with a resolution of up to 12 bits, making it ideal for applications requiring accurate and reliable temperature monitoring.








| 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-bit to 12-bit (programmable) |
| Communication Protocol | 1-Wire |
| Maximum Current Draw | 1.5mA during conversion |
| Waterproof Version | Yes (encased in stainless steel) |
| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | GND | Ground pin, connect to the ground of the circuit |
| 2 | VDD | Power supply pin (3.0V to 5.5V) |
| 3 | DQ | Data pin for 1-Wire communication |
Note: A 4.7kΩ pull-up resistor is required between the DQ pin and the VDD pin for proper operation.
Wiring the Sensor:
Programming with Arduino:
OneWire and DallasTemperature.#include <OneWire.h>
#include <DallasTemperature.h>
// Pin connected to the DS18B20 data pin
#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
}
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 connected!");
}
delay(1000); // Wait 1 second before the next reading
}
No Temperature Reading:
Incorrect Temperature Values:
Sensor Not Detected:
Fluctuating Readings:
Q: Can I connect multiple DS18B20 sensors to the same data line?
A: Yes, the DS18B20 supports multiple sensors on a single 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 measure negative temperatures?
A: Yes, the DS18B20 can measure temperatures as low as -55°C.
Q: Is the DS18B20 waterproof?
A: The standard DS18B20 is not waterproof, but DFRobot offers a waterproof version encased in stainless steel.
Q: What happens if the sensor is disconnected during operation?
A: The DallasTemperature library will return a value of DEVICE_DISCONNECTED_C to indicate the sensor is not connected.