- All products
- Sensors & Modules
- Temperature Sensor DS18B20
- Sensors & Modules
Features
- Digital temperature sensor with high accuracy
- Communicates over Dallas Semiconductor 1 Wire bus
- Power supply range 3.0V to 5.5V
- Operating temperature range minus 55 C to plus 125 C
- Accuracy plus minus 0.5 C from minus 10 C to 85 C
- Programmable resolution up to 12 bit
- Unique 64 bit serial code for multi device operation on a single bus
Principle of Work
The DS18B20 operates using the 1 Wire communication protocol. Two pins are used for power and one pin is used for data. A pull up resistor is required on the data line to maintain a high state when the bus is idle. Internally the sensor stores the measured temperature in a 2 byte register that can be read by issuing ROM and function commands over the 1 Wire bus. When used with Arduino available libraries abstract this complexity and simplify communication.
Pinout of the Board

| Pin | Description |
|---|---|
| GND | Ground |
| DQ | Data pin connect to any digital pin with a 4.7k ohm pull up resistor |
| VDD | 5V normal mode or GND parasite power mode |
Applications
- Temperature measurement in harsh environments
- Liquid temperature measurement
- Multi point temperature monitoring systems
Circuit
Connect Arduino digital pin 2 to the DQ pin of the sensor. A 4.7k ohm pull up resistor must be connected between DQ and 5V to keep the 1 Wire bus in a high idle state. When the flat side of the sensor text side faces you the leftmost pin is GND.

Library
Download the DallasTemperature and OneWire libraries then install them in the Arduino IDE via Arduino IDE greater than Sketch greater than Include Library greater than Add ZIP Library.
Example Code
#include "OneWire.h"
#include "DallasTemperature.h"
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup() {
Serial.begin(9600);
sensors.begin();
}
void loop() {
sensors.requestTemperatures();
float tempC = sensors.getTempCByIndex(0);
float tempF = sensors.getTempFByIndex(0);
Serial.print("Temperature: ");
Serial.print(tempC);
Serial.print(" C | ");
Serial.print(tempF);
Serial.println(" F");
delay(1000);
}
Technical Details
- Programmable digital temperature sensor
- Communicates using 1 Wire method
- Operating voltage 3V to 5V
- Temperature range minus 55 C to plus 125 C
- Accuracy plus minus 0.5 C
- Output resolution 9 bit to 12 bit programmable
- Unique 64 bit address enables multiplexing
- Conversion time 750 ms at 12 bit resolution
Comparison
| Parameter | DHT11 | DS18B20 |
|---|---|---|
| Measurement | Temperature and Humidity | Temperature |
| Temperature Range | 0 to 50 C plus minus 2 C | minus 55 to 125 C plus minus 0.5 C |
| Humidity Range | 20 to 80 percent plus minus 5 percent | Not supported |
| Communication | Single wire proprietary | 1 Wire |
| Operating Voltage | 3 to 5 V | 3 to 5 V |
Features
- Digital temperature sensor with high accuracy
- Communicates over Dallas Semiconductor 1 Wire bus
- Power supply range 3.0V to 5.5V
- Operating temperature range minus 55 C to plus 125 C
- Accuracy plus minus 0.5 C from minus 10 C to 85 C
- Programmable resolution up to 12 bit
- Unique 64 bit serial code for multi device operation on a single bus
Principle of Work
The DS18B20 operates using the 1 Wire communication protocol. Two pins are used for power and one pin is used for data. A pull up resistor is required on the data line to maintain a high state when the bus is idle. Internally the sensor stores the measured temperature in a 2 byte register that can be read by issuing ROM and function commands over the 1 Wire bus. When used with Arduino available libraries abstract this complexity and simplify communication.
Pinout of the Board

| Pin | Description |
|---|---|
| GND | Ground |
| DQ | Data pin connect to any digital pin with a 4.7k ohm pull up resistor |
| VDD | 5V normal mode or GND parasite power mode |
Applications
- Temperature measurement in harsh environments
- Liquid temperature measurement
- Multi point temperature monitoring systems
Circuit
Connect Arduino digital pin 2 to the DQ pin of the sensor. A 4.7k ohm pull up resistor must be connected between DQ and 5V to keep the 1 Wire bus in a high idle state. When the flat side of the sensor text side faces you the leftmost pin is GND.

Library
Download the DallasTemperature and OneWire libraries then install them in the Arduino IDE via Arduino IDE greater than Sketch greater than Include Library greater than Add ZIP Library.
Example Code
#include "OneWire.h"
#include "DallasTemperature.h"
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup() {
Serial.begin(9600);
sensors.begin();
}
void loop() {
sensors.requestTemperatures();
float tempC = sensors.getTempCByIndex(0);
float tempF = sensors.getTempFByIndex(0);
Serial.print("Temperature: ");
Serial.print(tempC);
Serial.print(" C | ");
Serial.print(tempF);
Serial.println(" F");
delay(1000);
}
Technical Details
- Programmable digital temperature sensor
- Communicates using 1 Wire method
- Operating voltage 3V to 5V
- Temperature range minus 55 C to plus 125 C
- Accuracy plus minus 0.5 C
- Output resolution 9 bit to 12 bit programmable
- Unique 64 bit address enables multiplexing
- Conversion time 750 ms at 12 bit resolution
Comparison
| Parameter | DHT11 | DS18B20 |
|---|---|---|
| Measurement | Temperature and Humidity | Temperature |
| Temperature Range | 0 to 50 C plus minus 2 C | minus 55 to 125 C plus minus 0.5 C |
| Humidity Range | 20 to 80 percent plus minus 5 percent | Not supported |
| Communication | Single wire proprietary | 1 Wire |
| Operating Voltage | 3 to 5 V | 3 to 5 V |