Why VCC cancels out
SIGNAL is a fraction of VCC. The Uno's ADC also measures as a fraction of VCC, so VCC appears on both sides and cancels: a USB port at 4.8 V gives the same temperature as one at 5.0 V. An ESP32 measures against its own reference, and there it does not cancel.
Two fractions of the same thing
The divider gives SIGNAL as a fraction of VCC. At 25 °C that fraction is one half, whatever VCC is.
An Uno's ADC measures the same way. Its reference is AVCC, which on an Uno is
the same 5 V as the 5V pin, and analogRead returns SIGNAL as a fraction of it,
out of 1023. So the count is the divider's fraction, and VCC appears nowhere:
count / 1023 = R_ntc / (R_ntc + 10 kΩ)A measurement where the supply cancels out like this is called ratiometric. It is the reason the Uno is the easy case for this block.
Pick VCC (Uno) and move the slider. A USB port is often a little under 5 V. SIGNAL moves with it, but so does the top of the ADC's scale, and the count stays at 512. The temperature does not move.
The Pico works the same way, close enough: its ADC measures against the Pico's own 3.3 V, filtered on the board, and the block runs from the same 3.3 V.
Where it breaks
An ESP32 or ESP32-S3 measures against a reference inside the chip, not against VCC. Its readings are in volts, not in fractions of anything. To get back to the fraction, the sketch has to divide by what it believes VCC to be, and that is 3.3 V unless you tell it otherwise.
Pick its own reference (ESP32) and move the slider. With the 3V3 rail 1 % high, the sketch reports about half a degree low; 3 % low, about 1.4 °C high. The ADC is reading correctly. The sketch's assumption is what is wrong.
The fix is one number. Measure the 3V3 pin with a multimeter while the board
is running and put it into the sketch as VCC_MV. Reading it on an
ESP32 covers the
rest of what is different there.
When it does not work
No. The count analogRead returns is SIGNAL as a fraction of the Uno's 5 V, and SIGNAL is itself a fraction of the same 5 V. The sketch never needs the voltage, only the count and the 1023 it is out of. That is the point of the arrangement.
Nearly. The Pico's ADC measures against its own 3.3 V supply, filtered on the board, and the block's VCC comes from the same 3.3 V. So the same shortcut works. The filter and the ADC's own quirks mean it is close rather than perfect.
About half a degree near 25 °C for every per cent the 3V3 rail is away from the 3.3 V the sketch assumes. Measure the 3V3 pin with a multimeter and put what it reads into the sketch's VCC_MV, and the error goes away.
No. On a cold day SIGNAL can climb towards VCC, and 5 V on an ESP32 pin is past its rating. It would also break the arithmetic: the sketch has to know VCC. Use 3V3.
Edit this page — content/books/ntc-thermistor/why-vcc-cancels-out.mdx
Questions about this product
See what other owners have asked, and read their solutions.
NTC Thermistor
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.