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 ToolDiscover one addressed DS18B20, wait for its 12-bit conversion, and verify positive and negative readings without accepting protocol error values.
Open 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
- Paste diagram.json and sketch.ino into a new Wokwi ESP32 project, then trace the 1-Wire circuit.
- You will see
- The DS18B20 data pin reaches GPIO4 and a 4.7 kOhm resistor pulls the shared line to 3.3 V.
- Why it matters
- The pull-up is part of the digital bus, so discovery evidence is invalid if it is omitted.

Step 1 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 2
- Do
- Inspect device discovery, the nonblocking conversion request, and the 750 ms wait.
- You will see
- The sketch confirms exactly one address, requests 12-bit conversion, waits 750 ms, and rejects the disconnected sentinel.
- Why it matters
- Address, conversion completion, and validity are separate protocol claims that should remain visible.

Step 2 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 3
- Do
- Start the simulation and read the bus discovery line.
- You will see
- ONEWIRE FOUND reports one sensor on GPIO4 with the 4.7 kOhm pull-up.
- Why it matters
- Counting devices before indexing them prevents an absent sensor from becoming a plausible-looking temperature.

Step 3 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 4
- Do
- Read the discovered sensor's ROM code.
- You will see
- The sketch prints one 64-bit hexadecimal address.
- Why it matters
- A stored address is what lets firmware associate a reading with one physical position on a shared bus.

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.
- You will see
- After the declared 750 ms conversion wait, the result is 24.00 degrees C with status VALID.
- Why it matters
- The result is accepted only after the resolution-dependent conversion time has elapsed.

Step 5 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 6
- Do
- Select the DS18B20 and set its temperature to 30 degrees C.
- You will see
- The next completed conversion reports 30.00 degrees C with status VALID.
- Why it matters
- A controlled positive change checks that new data follows a fresh conversion instead of a cached startup value.

Step 6 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 7
- Do
- Set the DS18B20 temperature to -7 degrees C.
- You will see
- The next completed conversion reports -7.00 degrees C with status VALID.
- Why it matters
- A negative test checks signed temperature handling rather than treating the raw word as unsigned.

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 returns the documented incomplete-conversion value. What should the firmware check?
Return to the chapter’s knowledge check
Return to Temperature Sensor Labs: Comparing Sensor Types · Browse Labs