Analog Front-End

ADC Resolution, LSB & NTC Thermistor Calculator

Convert raw ADC counts to pin voltage, scale resistor dividers, solve Beta NTC thermistor lookup points, and export a ready-to-run suite.yaml stimulus block.

3.3 V STM32/RP2040, 5.0 V AVR, 2.048 V ADS1115
Beta model for low-side NTC with pull-up to Vref
Quick presets:
1 LSB Step0.8057 mV4,096 total codes
Pin Voltage (ADC)1.6504 VAt count 2048 / 4095
Pre-Divider Input3.301 VScale x2.00 (10k / 10k)
NTC @ 200 Ccode 5600.745 kOhm / 0.451 V
Code -> NTC Temp114.4 CImplied by raw count 2048
CircuitTwin sensor-stimulus suite.yaml snippet
version: 1
board: arduino-mega2560
firmware: build/app.elf
tests:
  - name: ntc-adc-stimulus-and-open-circuit
    stimuli:
      - at_ms: 0
        target: mcu
        pin: ADC0
        voltage_v: 0.4513 # 200 C (0.745 kOhm, code 560)
      - at_ms: 500
        target: mcu
        pin: ADC0
        voltage_v: 3.300 # unplugged NTC open-circuit fault
    expect:
      console_contains: "THERMISTOR_OPEN_FAULT"
      exit_code: 0

Key ADC and thermistor equations

Analog regressions often hide inside fixed-point integer scaling. Testing open-circuit and shorted-sensor voltages in CI catches thermal runaway bugs before a heater board ever powers up.

QuantityEquationFirmware note
1 LSBVref / 2^N0.8057 mV/LSB on a 12-bit 3.3 V MCU ADC.
Divider scaleV_in = V_adc * (R_top + R_bot) / R_botUse 32-bit integer arithmetic before shifting to prevent overflow.
NTC BetaR(T) = R25 * exp(B * (1/T - 1/298.15))T in Kelvin; check ADC saturation bounds at -40 C and +300 C.

Frequently asked questions

QuestionAnswer
Should ADC scaling divide by 2^N or (2^N - 1)?Step width (1 LSB) is Vref / 2^N for an ideal N-bit SAR converter. Full-scale code 2^N - 1 maps to Vref - 1 LSB, though many firmware lookup tables approximate code / (2^N - 1) * Vref to map max code directly to Vref.
Why do high-impedance resistor dividers distort STM32 SAR ADC readings?The internal sampling capacitor must charge through the external source impedance during the configured sampling window. If R_top || R_bottom exceeds 10 kOhm, lengthen ADC_SMPR sample cycles or add a 10 nF filter capacitor at the pin.
How does firmware detect an unplugged NTC thermistor?In a low-side NTC divider with a pull-up to Vref, an open wire drives the ADC input to full-scale code (e.g. 1023 on 10-bit AVR or 4095 on 12-bit STM32). A shorted probe pulls the pin to 0 counts.