science tinker

Digital temperature sensor (DS18B20)

A digital thermometer in a three-leg package: −55 to 125 °C in steps of 0.0625 °C, sent as a number on one data wire.

Sensors · Elements inside: SiCHOCuSn

Function: what the DS18B20 does in a circuit

A digital thermometer in a three-leg package: −55 to 125 °C in steps of 0.0625 °C, sent as a number on one data wire.

  • Measures temperature as a digital number
  • Shares one data wire with other sensors
  • Works at the end of a long cable

DS18B20 key facts

Supply3.0 V to 5.5 V
Range−55 °C to 125 °C
Accuracy±0.5 °C from −10 °C to 85 °C
Resolution0.0625 °C (12 bits)
Pull-up4.7 kΩ from DQ to VDD
Pins (flat side facing you)GND, DQ, VDD
LibrariesOneWire and DallasTemperature

DS18B20 pinout

The legs from left to right, as the part is drawn in the simulator:

No.Name
1GND
2DQ (data)
3VDD

How it works

The chip measures temperature itself and stores it as a 12-bit number. It talks on the "1-Wire" bus: the data pin DQ is held HIGH by a 4.7 kΩ pull-up resistor, and the board and the sensor take turns pulling it LOW. Every sensor has its own 64-bit serial number, so many can share one pin. Sketches use the OneWire and DallasTemperature libraries: requestTemperatures(), then getTempCByIndex(0).

What it is made of

  • Chip: Silicon integrated circuit Si
  • Package: Black epoxy (TO-92) CHO
  • Legs: Tinned copper alloy CuSn

Where the materials come from: Silicon from quartz sand, purified to better than 99.9999%; copper from ores such as chalcopyrite; tin from cassiterite.

The chemistry

The chip compares two voltages inside the silicon, one that rises with temperature and one that falls. The difference depends only on temperature, not on the supply.

Biology connection

Your body holds its core near 37 °C by comparing a measured temperature with a set point, just as a thermostat built with this sensor does. Nerve impulses →

Safety and the environment

Flat side facing you: GND on the left, DQ in the middle, VDD on the right. Backwards, it gets very hot in seconds. Without the 4.7 kΩ pull-up it reads −127 °C; a reading of exactly 85 °C means no conversion has been requested yet.

Did you know? A waterproof version sealed in a steel tube is used in aquariums, soil and food because the signal is digital and does not fade along a long cable.

Try it in the simulator

Build and code a circuit with a Digital temperature sensor in these practice projects:

Questions students ask

What does the DS18B20 do?

A digital thermometer in a three-leg package: −55 to 125 °C in steps of 0.0625 °C, sent as a number on one data wire. Main functions: measures temperature as a digital number; shares one data wire with other sensors; works at the end of a long cable.

Why does my DS18B20 read −127 °C?

−127 °C means the sensor did not answer. The usual cause is a missing 4.7 kΩ pull-up resistor between DQ and 5V. Also check that DQ goes to the pin named in OneWire oneWire(pin) and that the sensor is not backwards.

What are the connections of the DS18B20?

In order: GND, DQ (data), VDD.

How does the DS18B20 work?

The chip measures temperature itself and stores it as a 12-bit number. It talks on the "1-Wire" bus: the data pin DQ is held HIGH by a 4.7 kΩ pull-up resistor, and the board and the sensor take turns pulling it LOW. Every sensor has its own 64-bit serial number, so many can share one pin. Sketches use the OneWire and DallasTemperature libraries: requestTemperatures(), then getTempCByIndex(0).

What is the DS18B20 made of?

Chip: Silicon integrated circuit. Package: Black epoxy (TO-92). Legs: Tinned copper alloy.

Is the DS18B20 safe? How should it be recycled?

Flat side facing you: GND on the left, DQ in the middle, VDD on the right. Backwards, it gets very hot in seconds. Without the 4.7 kΩ pull-up it reads −127 °C; a reading of exactly 85 °C means no conversion has been requested yet.

More sensors

Know someone who would use this?

It’s free for every learner. Send it to your class, team or club.

Updated · Free, no sign-up ·

Connected tools

The same idea from another angle, across the site.