

The DS18B20 is a digital temperature sensor that provides accurate temperature readings in the range of -55°C to +125°C. It communicates using a 1-Wire interface, which allows multiple sensors to be connected to a single data line. This feature makes it highly versatile and suitable for a wide range of applications, including:
The DS18B20 is known for its simplicity, reliability, and ability to operate over long distances with minimal wiring.








The DS18B20 has the following 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 | Programmable: 9-bit to 12-bit | 
| Interface | 1-Wire | 
| Maximum Current (Active) | 1.5 mA | 
| Standby Current | 750 nA | 
| Conversion Time | 93.75 ms (12-bit resolution) | 
| Package Types | TO-92, SOIC, or waterproof probe | 
The DS18B20 typically comes in a 3-pin TO-92 package. The pinout is as follows:
| 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 connection, drawing power from the data line.
To use the DS18B20, follow these steps:
Below is an example of how to connect the DS18B20 to an Arduino UNO:
The following code demonstrates how to read temperature data from the DS18B20 using the Arduino IDE. This example uses the OneWire and DallasTemperature libraries, which can be installed via the Arduino Library Manager.
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is connected to Arduino digital pin 2
#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); // Start serial communication
  sensors.begin();    // Initialize the DS18B20 sensor
  Serial.println("DS18B20 Temperature Sensor Example");
}
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:
Device Not Detected:
Intermittent Readings:
Q: Can I connect multiple DS18B20 sensors to the same data line?
A: Yes, the DS18B20 supports multiple devices on the same 1-Wire bus. Each sensor has a unique 64-bit address for identification.
Q: What is parasite power mode?
A: In parasite power mode, the DS18B20 draws power from the data line instead of requiring a dedicated VDD connection. This reduces wiring but may limit performance in some cases.
Q: How do I increase the accuracy of temperature readings?
A: Use the 12-bit resolution setting for maximum accuracy. Ensure the sensor is properly calibrated and not exposed to rapid temperature fluctuations.
Q: Can the DS18B20 be used in waterproof applications?
A: Yes, the DS18B20 is available in a waterproof probe version, making it suitable for liquid temperature measurements.
By following this documentation, you can effectively integrate the DS18B20 into your projects for reliable temperature monitoring.