Verify a DS18B20 conversion
Discover one addressed DS18B20, wait for its 12-bit conversion, and verify positive and negative readings without accepting protocol error values.

Physics Phoebe: I want you to prove identity and conversion completion before trusting the temperature.
Predict the reading, then compare it with the measurement.
Wokwi ESP32
Third party ToolOpen the ESP32 editor, paste diagram.json, then paste sketch.ino.
Open Wokwi to paste in the files (new tab)Get the files
Use both prepared files. This is a paste-in setup; saving a project requires a Wokwi account.
sketch.ino
- Use the launch button above to open the ESP32 editor in Wokwi.
- Select the editor’s diagram.json tab and replace all its text with the supplied diagram.json.
- Select the sketch.ino tab, replace all its text with the supplied sketch.ino, then click Start Simulation.
Steps
Step 1
- Do
- In the Wokwi simulation panel, paste diagram.json and sketch.ino into a new Wokwi ESP32 project, then trace the 1-Wire circuit.
- You will see
- Input: inspect diagram.json beside the running Wokwi circuit. The DS18B20 data lead reaches ESP32 GPIO4. A 4.7 kOhm resistor pulls the shared line to 3.3 V. Serial Monitor reports TEMP value=24.00C status=VALID.
- Why it matters
- The resistor is part of this 1-Wire bus path. The running circuit ties a valid reading to that wiring. Power and ground are visible beside the data connection. Bus discovery would be unreliable without the pull-up.

Step 1 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 2
- Do
- In the Wokwi simulation panel, inspect device discovery, the nonblocking conversion request, and the 750 ms wait.
- You will see
- Input: inspect sketch.ino while its Wokwi run is active. The source sets ONE_WIRE_PIN=4 and CONVERSION_MS_12_BIT=750. It requests a 12-bit conversion without blocking inside the library. Serial Monitor alternates CONVERT requested and TEMP value=24.00C status=VALID.
- Why it matters
- The 750 ms wait belongs to the 12-bit conversion. The repeated valid result follows each request in this run. The source also checks the sensor address and disconnected sentinel. Discovery, completion, and validity are separate claims.

Step 2 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 3
- Do
- Start Wokwi and read the bus discovery line in Serial Monitor.
- You will see
- Input: start the supplied ESP32 and 1-Wire diagram. Observed: "ONEWIRE FOUND count=1 pin=4 pullup=4.7k". Expected: one sensor on GPIO4 with a 4.7k pull-up. An address line followed in the same run.
- Why it matters
- The bus search found one simulated device. The reported pin matches the diagram. Discovery precedes temperature conversion. This is a simulator bus, not a measured resistor.

Step 3 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 4
- Do
- In Serial Monitor, read the discovered sensor ROM code.
- You will see
- Input: read Serial Monitor after bus discovery. Observed: "ONEWIRE ADDRESS 280102030405069E". Expected: a ROM identifier for the one discovered sensor. It matches the real screenshot.
- Why it matters
- The ROM line identifies the simulated device. It follows the count=1 discovery result. The address is a teaching fixture. Keep it with the reading to avoid device confusion.

Step 4 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 5
- Do
- Leave the sensor at 24 degrees C and inspect the request and result in Serial Monitor.
- You will see
- Input: leave the DS18B20 at 24 C. Observed: "CONVERT requested resolution=12bit wait=750ms". Observed: "TEMP value=24.00C status=VALID conversion=750ms". Expected: a valid result after the named wait.
- Why it matters
- The request and result appeared together in this run. The VALID result is for the baseline temperature. The 750 ms label explains the conversion interval. This is protocol simulation, not physical calibration.

Step 5 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 6
- Do
- In the DS18B20 control panel, set temperature to 30 C and read the result in Serial Monitor.
- You will see
- Input: set the DS18B20 temperature control to 30 C in Wokwi. Observed settled line: "TEMP value=30.00C status=VALID conversion=750ms". Expected: a valid 30 C result after conversion. The control displayed 30 C; an intermediate 29.19 C line appeared during slider movement.
- Why it matters
- The settled value matches the real screenshot. The 750 ms conversion interval remains in force. The transient line shows why to wait for the slider to settle. The exercise does not calibrate a physical probe.

Step 6 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 7
- Do
- In the DS18B20 control panel, set temperature to -7 C and read the result in Serial Monitor.
- You will see
- Input: set the DS18B20 temperature control to -7 C in Wokwi. Observed settled line: "TEMP value=-7.00C status=VALID conversion=750ms". Expected: a valid signed negative temperature. The control displayed -7 C; an intermediate 2.81 C line appeared during slider movement.
- Why it matters
- The signed reading matches the real screenshot. The VALID status remained set for this in-range fixture. The transient line is distinct from the settled -7 C result. This verifies simulator conversion, not field accuracy.

Step 7 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab)
Chapter checks
These questions refer to the chapter’s examples. Use the return links to review their answers.
Several DS18B20 sensors share one GPIO. What lets the controller distinguish their readings?
Return to the chapter’s knowledge checkThe lab sensor reads 85 °C immediately after power-up. What should firmware check first?
Return to the chapter’s knowledge check
Return to Temperature Sensor Labs: Comparing Sensor Types · Browse Labs