Convert an NTC ADC reading to temperature
Use the Steinhart–Hart equation to convert thermistor resistance into temperature.

Physics Phoebe
Predict the reading, then compare it with the measurement.
Wokwi ESP32
Third party ToolUse the Steinhart–Hart equation to convert thermistor resistance into temperature.
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
- In the Simulation panel, inspect the NTC sensor wiring after pasting both supplied files.
- You will see
- The NTC sensor has power and ground connections, with OUT connected to ESP32 pin 32.
- Why it matters
- A calibration equation needs a named input before its result can be checked. Following OUT identifies the raw channel used by this setup.

Step 1 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 2
- Do
- In the sketch.ino editor tab, find analogRead(32) and the raw-value range check.
- You will see
- The sketch reads 12-bit counts and rejects values at 0 or 4095 before calculating resistance.
- Why it matters
- The chapter distinguishes calculating a value from validating it. Range guards keep an invalid input from becoming a plausible corrected result.

Step 2 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 3
- Do
- In the Simulation toolbar, click the play button and wait for compilation.
- You will see
- The timer starts and the Serial Monitor opens with ADC, resistance, and temperature results.
- Why it matters
- Fresh readings test the equation’s claim. Keeping raw and corrected values together makes the conversion open to review.

Step 3 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 4
- Do
- In the Serial Monitor panel, read ADC, resistance, and temperature at the initial 25 °C setting.
- You will see
- The 25 °C setting produces 2048 counts, 10005 Ω, and 24.99 °C in the recorded run.
- Why it matters
- Residual error compares a corrected result with its reference. Here the model setting provides that comparison, rather than an independent temperature standard.

Step 4 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 5
- Do
- In the sketch.ino editor tab, find the resistance calculation 10000.0*raw/(4095.0-raw).
- You will see
- The line uses a 10000 Ω reference value and the raw ADC count to reconstruct resistance.
- Why it matters
- The chapter keeps conversion coefficients with their input and output units. Here the intermediate resistance makes the path from counts to temperature visible.

Step 5 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 6
- Do
- In the Simulation panel, select the NTC sensor and set its temperature control to 35 °C.
- You will see
- The 35 °C setting produces 1614 counts, 6505 Ω, and 35.00 °C in the recorded run.
- Why it matters
- A second input tests the conversion away from its starting point. The chapter warns that a straight calibration line can leave errors in a curved response.

Step 6 · Wokwi ESP32; numbered callout added to a real capture. Enlarge screenshot (new tab) Step 7
- Do
- In the NTC control panel, restore temperature to 25 °C.
- You will see
- The Serial Monitor returns to 2048 counts, 10005 Ω, and 24.99 °C in the recorded run.
- Why it matters
- Repeating a known value checks whether the result returns. The chapter still calls for reference standards across the range and recorded recalibration conditions.

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.
A sensor reads 20% when the true value is 10%, and reads 80% when the true value is 90%. What is the gain (slope) coefficient?
Return to the chapter’s knowledge checkA deployed outdoor temperature sensor gradually shows readings 1.5C higher than a reference thermometer after 6 months. The sensor worked correctly when first installed. What is the most likely cause and solution?
Return to the chapter’s knowledge check
Return to Sensor Calibration: Math and Validation · Browse Labs