Thermistor linearization trade-off analysis for 0-50°C soil moisture sensor:
Full Steinhart-Hart equation (gold standard, highest accuracy): \(\frac{1}{T} = A + B \ln(R) + C (\ln(R))^3\) \(\text{Coefficients: } A = 0.001129, B = 0.000234, C = 8.76 \times 10^{-8}\) \(\text{Accuracy: } \pm 0.1°C \text{ over full 0-50°C range}\) \(\text{Computation: } 3 \text{ multiplies, } 1 \text{ natural log, } 2 \text{ divisions} = 120\mu\text{s on ESP32}\)
Piecewise linear (3 segments, our recommendation): Segment 1: 0-15°C, \(T = 0.00008R + 2.5\) Segment 2: 15-30°C, \(T = 0.00015R + 12.1\) Segment 3: 30-50°C, \(T = 0.00025R + 25.8\) \(\text{Accuracy: } \pm 1.5°C \text{ max error}\) \(\text{Computation: } 1 \text{ multiply, } 1 \text{ add, } 2 \text{ compares} = 15\mu\text{s on ESP32}\)
Taylor series (1st order, around 25°C): \(R(T) \approx 10000 - 445(T - 298)\) \(\text{Accuracy: } \pm 0.5°C \text{ for 22-28°C, } \pm 2°C \text{ for 20-30°C, } > 10°C \text{ error outside}\) \(\text{Computation: } 1 \text{ multiply, } 2 \text{ adds} = 8\mu\text{s on ESP32}\)
Lookup table (51 entries, 1°C steps): \(\text{Memory: } 51 \times 2 \text{ bytes} = 102 \text{ bytes}\) \(\text{Accuracy: } \pm 0.5°C \text{ (with linear interpolation)}\) \(\text{Computation: } 1 \text{ array lookup, } 1 \text{ interpolation} = 60\mu\text{s}\)
Decision matrix for soil moisture IoT:
- Required accuracy: ±2°C (soil thermal inertia makes 0.1°C meaningless)
- Battery-powered: Yes → favor low computation
- Temperature range: 0-50°C → wide, Taylor series unsuitable
- Memory: 256KB flash → lookup table acceptable, but unnecessary
- Winner: Piecewise linear (±1.5°C accuracy, 8× faster than Steinhart-Hart, 51× less memory than lookup table)
Key insight: Don’t over-engineer. Steinhart-Hart is 8× slower to compute the same soil temperature that has ±2°C natural variation. Save the battery for more samples, not pointless precision.