

The DS18B20 is a digital temperature sensor manufactured by Maxim Integrated. It communicates using the 1-Wire protocol, which allows multiple sensors to share a single data line, simplifying wiring and reducing hardware requirements. The sensor provides accurate temperature readings in both Celsius and Fahrenheit, with a resolution of up to 12 bits. Its compact design and ease of use make it a popular choice for applications such as weather monitoring, industrial temperature control, and home automation systems.








The DS18B20 is designed for precision and versatility. Below are its 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 |
| Communication Protocol | 1-Wire |
| Conversion Time | 93.75ms (12-bit resolution) |
| Unique 64-bit ROM Code | Yes (for device identification) |
| Power Modes | Parasitic power or external power |
| Package Options | TO-92, SOIC, and others |
The DS18B20 typically comes in a TO-92 package with three pins. Below is the pinout:
| Pin | Name | Description |
|---|---|---|
| 1 | GND | Ground pin. Connect to the ground of the circuit. |
| 2 | DQ | Data pin. Used for communication and data transfer via the 1-Wire protocol. |
| 3 | VDD | Power supply pin. Can be connected to 3.0V to 5.5V or left unconnected for parasitic power. |
Below is an example of how to interface the DS18B20 with an Arduino UNO using the DallasTemperature and OneWire libraries.
#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 at 9600 baud
sensors.begin(); // Initialize the DS18B20 sensor
}
void loop() {
sensors.requestTemperatures(); // Send command to get temperature readings
// Fetch and print the temperature in Celsius
float temperatureC = sensors.getTempCByIndex(0);
Serial.print("Temperature (C): ");
Serial.println(temperatureC);
// Fetch and print the temperature in Fahrenheit
float temperatureF = sensors.getTempFByIndex(0);
Serial.print("Temperature (F): ");
Serial.println(temperatureF);
delay(1000); // Wait 1 second before the next reading
}
No Temperature Reading:
Incorrect Temperature Values:
Multiple Sensors Not Detected:
Q1: Can I use the DS18B20 with a 3.3V power supply?
Yes, the DS18B20 operates within a voltage range of 3.0V to 5.5V.
Q2: How many DS18B20 sensors can I connect to a single data line?
Theoretically, you can connect up to 100 sensors on a single 1-Wire bus, but this depends on factors like wire length and power supply.
Q3: What is the purpose of the pull-up resistor?
The pull-up resistor ensures the data line remains in a defined state (high) when no device is actively driving it.
Q4: Can I use the DS18B20 in outdoor applications?
Yes, but ensure the sensor is properly sealed or housed to protect it from moisture and extreme environmental conditions.
Q5: What is parasitic power mode?
In parasitic power mode, the sensor draws power from the data line (DQ) instead of the VDD pin. This reduces wiring but may limit performance in some cases.