Source: https://mokxi.com/parts/ds18b20
Updated: 2026-11-10

Part

# Temperature sensor, DS18B20

A thermometer with a 64-bit serial number, so any number share one wire. Needs a 4k7 pull-up.

See every part

- 3 pins
- 3 settings
- In 5 projects
- In 1 lesson

Drawn live by the editor's own code, at the size you see it.

At a glance

## The Temperature sensor, DS18B20 in brief

What it is, and every setting the properties panel gives it.

The DS18B20 is the three-legged digital thermometer in every kit or the same chip in a steel probe, and it reports -55 to 125 degrees Celsius to a sixteenth of a degree as a number rather than a voltage. With the flat face toward you the legs are GND, DQ and VDD; VDD takes 3.0 to 5.5 volts, so it runs from an Uno’s 5 V or an ESP32’s 3.3 V, and DQ goes to any digital pin. DQ is open drain and needs one 4.7 kilohm pull-up to VDD for the whole bus; forgetting it is the classic reason a sensor is never found, and the pullup property stands in for the three-pin modules that carry one. Mokxi runs the real 1-Wire protocol bit by bit with the datasheet’s timings: the 480 microsecond reset and presence pulse, a ROM search that finds several sensors on one wire, CRC-8 checks, and conversions of 93.75 to 750 milliseconds by resolution. The OneWire and DallasTemperature libraries work as tutorials use them. Read before converting and you get 85,. Parasite power and the half-degree error a real sensor is allowed are not modeled.

Family

Sensors

Pins

3

temperature

22

serial

pullup

false

A circuit built around it, running and explained: the DS18B20 simulator.

Pins

## 3 pins

Named as the editor names them, so a wire lands where you expect it.

Pin

What it does

GND

Ground. The left leg with the flat face towards you.

DQ

The data line: open drain, and needs a pull-up.

VDD

Supply, 3.0 to 5.5 V.

How to use it

## How to use the DS18B20 with an Arduino

Wire VDD to 5 V, GND to GND and DQ to pin 2, then put one 4.7 k resistor from DQ to 5 V. That single pull-up serves every sensor on the wire, so a second DS18B20 needs only its DQ joined to the same row. Without it the line floats and the library reports no devices at all.

Call sensors.begin() once, then sensors.requestTemperatures() before every read: it starts every sensor converting and waits the 750 ms twelve bits take. Read without it and you get 85, the power-up value. With several sensors, fetch each address once with getAddress() and read it by address after that, which is quicker than searching by index every time.

Part pin

Board pin

DQ

Pin 2, with 4.7 k to 5 V

VDD

5 V

GND

GND

On an ESP32, power it from 3.3 V and pull DQ up to 3.3 V instead; the sensor runs from 3.0 V and the same libraries compile.

Click to open it in the editor

This is the simulator itself, running here. Click anything to open it in the editor.

Open this project in the editor Read the full tutorial

Reading a DS18B20 with DallasTemperature

How it is modeled

## What is true about the Temperature sensor, DS18B20, here

In its help article’s own words: what the simulation gets right, and where it stops.

### Modeled

The wire, bit by bit, with the datasheet's timings: the 480 µs reset and the presence
pulse after it, write slots sampled 30 µs in, read slots where a 0 holds the line low
from the master's fall. The ROM commands (READ ROM, MATCH ROM, SKIP ROM, SEARCH ROM
and ALARM SEARCH) and the function commands (CONVERT T, READ and WRITE SCRATCHPAD,
COPY SCRATCHPAD, RECALL E2, READ POWER SUPPLY), with the Dallas CRC-8 on the ROM code
and on the scratchpad.

The search works because the wire does. Several sensors on one net answer a
SEARCH ROM together and the open-drain line ANDs what they send, exactly as on the
bench, so search() finds every one of them. Nothing in the part arbitrates.

Resolution costs time. Nine bits (half a degree) convert in 93.75 ms and twelve
bits (a sixteenth) in 750 ms, the datasheet's worst case, and the undefined low bits
of a coarse reading read zero. Read slots after CONVERT T return 0 until it is done.

Before the first conversion the temperature register holds +85 °C, as a real one
does at power-up. A sketch that reads without converting prints 85, which is the most
famous number in the datasheet.

### Not modeled

Parasite power. A real DS18B20 can run with VDD tied to ground, living off the
data line, if the master holds the line hard high during a conversion. Here a DS18B20
with no VDD is off the bus, and READ POWER SUPPLY always answers "external".

No error in the reading. The part reports temperature exactly, to its
resolution, with none of the ±0.5 °C a real one is allowed, and it does not warm
itself up. The EEPROM keeps the alarm limits and resolution for the run, not between
runs.

From DS18B20 1-Wire thermometer, in full.

Projects

## See the Temperature sensor, DS18B20 in a project

5 built-in projects use it. Each opens in the editor, already wired.

Lessons

## Where it turns up in a lesson

One lesson places it in its own circuit.

### Learn articles

1 lesson

- Arduino DS18B20 Temperature Sensor: Wiring and Code

Boards

## The boards it is shown on

This board has a built-in project with the Temperature sensor, DS18B20 in it.

- Arduino Uno R3

Boards

## The Temperature sensor, DS18B20 on each board

The pins, the voltage and the code change from board to board. Each page has that board’s wiring and a circuit you can run.

- Arduino Uno and DS18B20
- ESP32 and DS18B20
- Arduino Nano and DS18B20
- Arduino Mega and DS18B20
- ESP32-C3 and DS18B20
- ESP32-S3 and DS18B20
- Raspberry Pi Pico and DS18B20
- Arduino Uno R4 and DS18B20

Libraries

## Arduino libraries for the Temperature sensor, DS18B20

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

- OneWire
- DallasTemperature

More parts

## The rest of the bench

Every one of these is drawn and simulated the same way.

Full-size breadboard

A real 0.1 inch grid with the rails and the center channel, 63 columns wide.

Jumper wires

Drag from any pin or hole to any other. Corners snap, and you can drag them.

Power

A supply rail at the voltage you choose.

Ground

The other end of every circuit.

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

Filament lamp

A tungsten bulb in a holder: an inrush when it is switched on cold, tens of milliseconds to warm up, and dim on half its voltage.

Resistor

Any value you like, with the color bands drawn to match.

ESP32-C3-DevKitM-1

A RISC-V board that runs your firmware at 160 MHz on the real memory map.

Pushbutton

A 12 mm tactile switch. Hold it while the simulation runs.

Raspberry Pi Pico

The RP2040 board on our own Cortex-M0+ core. Pick a program and press Run.

Raspberry Pi Pico W

Raspberry Pi Pico W (RP2040). The same board and the same pinout as a Pico, with the CYW43439 on it. The WiFi is simulated (no radio; real internet through the Cloud panel’s switch), and the on-board LED, which hangs off that chip rather than off GP25, is driven through the same path. Everything else is the Pico.

Raspberry Pi 4 Model B

Raspberry Pi 4 Model B: the 40-pin header, driven by main.py with RPi.GPIO or gpiozero.

See every part

## Wire up the Temperature sensor, DS18B20

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.

Start building free Open the editor
