Components / Sensors / DS18B20 Temperature Sensor

DS18B20 Temperature Sensor

Digital temperature sensing device using 1-Wire communication.

MeasuresTemperature
Range−55 to 125 °C
Accuracy±0.5 °C from −10 to 85 °C
Interface1-Wire (many sensors on one pin; each has a 64-bit ID)
SensorsReviewedMPN DS18B20Used in 20 projects
DS18B20
In short

What is the DS18B20 Temperature Sensor and what is it used for?

Digital temperature sensing device using 1-Wire communication. Makers use it to read temperature with suitable pull-up.

Cheap clones exist that read slightly differently. Calibrate against ice water (0 °C) if accuracy matters.
In the real world

Temperature monitoring

How it works

Sensors convert a physical quantity into an electrical signal. Calibrate, verify module supply, interfaces and environmental limits.

Key specifications

Sensor specValue
MeasuresTemperature
Range−55 to 125 °C
Accuracy±0.5 °C from −10 to 85 °C
Interface1-Wire (many sensors on one pin; each has a 64-bit ID)
Supply voltage3.0 to 5.5 V
Operating temperature−55 to 125 °C

Pinout

GNDGround (black)
DQData (yellow), 4.7 kΩ pull-up to VCC
VDD3.0 to 5.5 V (red)

How to use it

Needs a 4.7 kΩ pull-up on the data line. The waterproof probe version is ideal for liquids and soil. Use the OneWire and DallasTemperature libraries.

#include <OneWire.h>
#include <DallasTemperature.h>
OneWire bus(4);
DallasTemperature t(&bus);
void setup() { Serial.begin(115200); t.begin(); }
void loop() { t.requestTemperatures(); Serial.println(t.getTempCByIndex(0)); delay(1000); }

Applications

Alternatives

Buy at

Common questions

What is the DS18B20 Temperature Sensor used for?

In products: temperature monitoring. In maker projects: read temperature with suitable pull-up.

How does the DS18B20 Temperature Sensor work?

Sensors convert a physical quantity into an electrical signal. Calibrate, verify module supply, interfaces and environmental limits.

What voltage does the DS18B20 Temperature Sensor need?

3.0 to 5.5 V.

How do I connect the DS18B20 Temperature Sensor to an Arduino or ESP32?

1-Wire (many sensors on one pin; each has a 64-bit ID). Pins: GND (Ground (black)), DQ (Data (yellow), 4.7 kΩ pull-up to VCC), VDD (3.0 to 5.5 V (red)).

What can I use instead of the DS18B20 Temperature Sensor?

DHT22 Sensor.