A device may read I²C data with changing values, yet not necessarily measure the desired physical quantity. A thermometer attached to a heating PCB may primarily measure the board temperature; an accelerometer in motion cannot calculate tilt angles based solely on gravity; and the CO₂ equivalent value output by a VOC algorithm is not a directly measured CO₂ concentration. Understanding sensors requires tracing layer by layer: physical object, sensitive element, sampling, and result interpretation.
Problem
Reference Entry
Distinguish First
Spec says 16 bit, is it precise?
Error vs. Resolution
Minimum code step, noise, offset
NTC temperature calculation direction is reversed
Voltage divider & inversion
Upper/lower arm resistors and temperature units
Data is smoothed but motion is incorrect
Sampling & Filtering
Aliasing, latency, and true changes
Why does IMU integration drift?
Inertial Measurement & Fusion
Angular velocity, specific force, observable directions
Are environmental values trustworthy?
Installation & Model
Direct measurement, compensation, derivation
ID is normal but data is abnormal
Complete Read Process
Configuration, conversion complete, atomic read, and calibration
Resolution, Repeatability, and Accuracy Answer Different Questions
An ideal 12-bit ADC over a 3.3 V range has a code width of approximately 3.3/4096 = 0.806 mV. This is merely the quantization step; in reality, it also includes offset, gain, nonlinearity, reference error, and noise. Displaying a digital value to 0.01°C does not mean the measurement error is less than 0.01°C; similar results over multiple trials indicate good repeatability, but the values might still be consistently high.
Error budgets must distinguish between deterministic bias and random uncertainty. If two errors only have maximum bounds, the conservative total bound can be the sum of the two; only when they have corresponding statistical definitions and are approximately independent is it appropriate to use the root sum of squares (RSS). You cannot directly RSS two "± maximum error" values from a datasheet and treat the result as a guaranteed worst-case error.
Range also comes with costs: a larger range usually means each LSB corresponds to more physical quantity, but noise, overload recovery, and bandwidth do not necessarily scale by the same factor. First, confirm that peak values will not saturate, then evaluate effective results under the target bandwidth and temperature.
NTC: Deriving Resistance from the Actual Voltage Divider Direction
In the diagram, the fixed resistor is on top and the NTC is on the bottom, so V = VEX·RNTC/(R_fixed+RNTC), which rearranges to RNTC = R_fixed·V/(VEX−V). Swapping the upper and lower resistors changes the formula accordingly. As NTC temperature rises, its resistance drops, so in this diagram, the voltage decreases as temperature rises; this is a simple basis for checking the direction of the formula.
Within the applicable temperature range, the B-parameter approximation can be written as 1/T = 1/T25 + ln(R/R25)/B, where T and T25 are in Kelvin, and 273.15 is subtracted at the end to convert to Celsius. Assuming R25=10 kΩ and B=3950 K, the node is 1.65 V at 25°C; at 50°C, the resistance is approximately 3.588 kΩ, and the node is approximately 0.871 V. This parameter set is just an example and does not represent all 10 kΩ NTCs.
If the divider excitation and ADC reference come from the same power supply, using normalized readings q≈V/VEX allows writing RNTC=R_fixed·q/(1−q), which ideally eliminates excitation amplitude errors. It cannot eliminate resistor tolerance, ADC offset, reference path noise, and NTC model errors. ADI: Ratioed NTC Interface
Current also causes self-heating: at 25°C, two 10 kΩ resistors in series at 3.3 V result in NTC power dissipation of approximately 0.272 mW. Temperature rise must be calculated based on the dissipation coefficient in the actual medium; one cannot claim that temperature error is negligible simply because "power dissipation is small." Increasing resistance or using intermittent power supply can reduce power dissipation, but it also increases source impedance or the need to wait for stability. For wider temperature ranges, follow manufacturer curves, lookup tables, or the Steinhart–Hart model; a single B value cannot be guaranteed to cover all temperatures. ADI: Thermistor Measurement Design
When the node approaches 0 or the supply voltage, first determine if it is a short circuit, open circuit, or out-of-range condition before proceeding with inversion, to avoid division by zero or obtaining seemingly valid extreme temperatures. Specific fault responses depend on the break point location, leakage, and protection networks.
Swapping divider arms reverses the temperature curve
Swapping arms at one temperature changes q to 1−q, while correct inversion returns the same temperature. Changing slope means equal ADC steps do not give equal temperature resolution everywhere. Ratiometric conversion removes excitation magnitude, not component or model error.
Preparing the visual
Swapping divider arms reverses the temperature curve
Resistance falls with temperature, but voltage direction depends on divider position. Inversion must match the circuit.
Temperature Measurement: How Sensor Temperature Represents the Measured Object
NTC, RTD, and digital thermometers all require thermal coupling; response speed is determined jointly by packaging, installation, medium, and thermal capacity. High-precision platinum resistors also need to consider excitation self-heating, two-wire lead resistance, and three/four-wire compensation; one cannot guarantee ±0.1°C accuracy simply based on "PT100." Digital devices eliminate some analog design but do not eliminate the effects of packaging and on-board heat sources.
DS18B20 supports optional resolution and multi-point 1-Wire; the maximum conversion time for 12-bit resolution can reach 750 ms; resolution settings, power supply modes, and bus load affect system behavior. During parasitic power supply, the conversion phase may require a strong pull-up; one cannot ignore power supply and return paths by connecting only a single data line. ADI DS18B20 Datasheet
Thermocouples generate thermoelectric potentials related to the temperatures at both ends, not an absolute temperature output from a single solder joint. Cold junction compensation measures the temperature at the connection terminals, converts it to the equivalent thermoelectric potential of that type relative to the reference temperature, and synthesizes it with the measured voltage to reverse-search the hot junction temperature; due to non-linearity, one cannot simply add the two temperatures across all temperature ranges. The compensation sensor should represent the actual connection terminal temperature, not the temperature of nearby chips. ADI: Cold Junction Compensation
Both Analog and Digital Sampling Require a Time Model
SAR ADC sampling capacitors need to be charged through the signal source. Simplified to a single-pole model, a full-scale step needs to converge to half an N-bit LSB, requiring approximately t ≥ (N+1)ln2·R_sourceC_sampling; for 12 bits, this is about 9 time constants. Assuming 10 kΩ and 10 pF, this part alone is approximately 0.90 μs; in practice, switch impedance and driver stabilization processes must also be accounted for. ADI: Source Impedance and Sampling Settling Time
Sampling rate must be coordinated with analog bandwidth and anti-aliasing filters. For example, sampling a 900 Hz sine wave at 1 ksample/s makes it indistinguishable from a certain 100 Hz sine wave in discrete data; moving average after sampling cannot restore the original 900 Hz identity. Digital sensors already have internal sampling/filtering, but one still needs to verify output data rate, bandwidth, and filter configuration.
Averaging can reduce random noise that meets the conditions, but it increases latency. A simple moving average of length N has a group delay of (N−1)/2 sampling intervals in its linear phase model; at 1 ksample/s with N=21, this is approximately 10 ms. It cannot eliminate fixed bias, and correlated noise does not necessarily decrease by 1/√N; control systems should include latency in the closed-loop budget.
Digital interface speed is only transmission capability, not measurement update rate. UART itself does not specify long-distance physical layers, and I²C power consumption is not fixed to be lower than SPI. Selecting an interface requires considering cable electrical characteristics, effective data volume, addressing or chip select, timestamps, and FIFO depth; specific levels are seen in Interface Physical Layers.
The same samples can belong to different signals
At 900 Hz, the curve meets the 100 Hz alias at every sample but differs between samples. At 1000 Hz all samples become identical. Cosine keeps the phase correspondence simple here; aliases in general still require phase handling.
cos(2π(fs−f)n/fs)=cos(2πfn/fs)
Preparing the visual
The same samples can belong to different signals
Discrete samples can coincide exactly; no later algorithm can infer the original frequency from these points alone.
Accelerometers measure specific force, which can be expressed in a common coordinate convention as f = Rᵀ(a−g): R maps from body to world, a is translational acceleration, and g is the gravity vector. When stationary and supported, the magnitude is approximately 1g; whether an axis is positive or negative depends on installation and coordinate definition; in free fall, the ideal output is close to zero. Using it to estimate tilt angle relies on conditions such as translational acceleration being negligible relative to gravity. ADI: Accelerometer Tilt Measurement
Gyroscopes provide angular velocity; integration can track attitude changes over short periods, but zero bias accumulates. An uncorrected constant bias of 0.1°/s can cause an angle error of approximately 6° after 60 seconds; for three-dimensional motion, quaternions or rotation matrices must be updated according to rotational relationships; one cannot arbitrarily add three Euler angles individually.
Observable
What it Constrains
Main Limitations
Gyro Angular Velocity
Short-term rotational changes
Zero bias, temperature drift, noise integration
Acceleration Specific Force
Gravity direction in quasi-static states
Translation, vibration; cannot independently determine yaw around the gravity axis
Magnetic Field Vector
Provides heading reference under suitable conditions
Hard iron/soft iron, nearby currents, local magnetic field, and tilt angle
Fusion algorithms utilize complementary information and estimate errors; they cannot promise "nine axes yield drift-free absolute attitude." Forcing trust in the magnetometer when magnetic fields are disturbed may pull the heading in the wrong direction; sustained acceleration may also be misinterpreted as tilt. Time synchronization, installation axis transformation, validity judgment, and reasonable noise/bias models are required, rather than just changing the algorithm name.
Stationary gyro mean can estimate the zero bias under those conditions; accelerometers cannot subtract all three stationary axis readings to zero, otherwise, the gravity observation will be deleted together. Multi-attitude calibration is used to distinguish bias, scale, and inter-axis errors; temperature changes may still require additional compensation.
Environmental Sensors: Output Units Do Not Equal Full Interpretation
Humidity and temperature are correlated; housing ventilation, heat sources, contamination, and condensation all change measurements. Even if the chip is calibrated, it does not mean it can still represent indoor air after being installed in a sealed, heating enclosure; environmental temperature and humidity installation should be designed around thermal isolation and gas exchange. Sensirion: Temperature & Humidity Design Guide
Converting barometric pressure to altitude requires reference pressure and atmospheric models. Near sea level, assuming a density of 1.225 kg/m³, Δh≈−Δp/(ρg), where 100 Pa corresponds to approximately 8.32 m; this is only a local approximation, and weather-induced pressure changes will also be interpreted as altitude changes. A certain barometric pressure accuracy cannot be directly converted to a fixed altitude accuracy at all altitudes. Raw data from devices like the BME280 also needs to be converted using factory compensation parameters; one cannot directly treat ADC registers as Pa or %RH. Bosch BME280 Datasheet
Illuminance lux contains human eye spectral weighting; housing light transmittance, light source spectrum, and angle of incidence all affect system results; digital sensors outputting lux may also require whole-unit correction. Particulate matter light scattering measurement relies on conditions such as particle size, refractive index, and humidity; "using laser" does not directly imply error-free mass concentration.
The CO₂eq/eCO₂ calculated by VOC devices is different from measurements directly targeting physical characteristics such as CO₂ absorption. For example, the SGP30 explicitly outputs algorithm-calculated TVOC and CO₂ equivalent signals; one cannot treat it as a universal substitute for real CO₂ concentration, nor should one summarize all air quality using a single gas indicator. Sensirion SGP30 Datasheet
Reading Flow from Communication to Trusted Results
Reading the ID only proves that a communication session obtained the expected identification value; one still needs to configure and read back range, output rate, and operating mode, wait for conversion to complete, verify status/CRC, and obtain multi-byte data for the same frame according to the specified continuous read or latch mechanism. All zeros or 0xFF may be due to bus, power, unconverted, configuration, or real data; one cannot determine the fault based on a single bit pattern.
When parsing, clarify signed format, endianness, unit scale, and timestamp; check for overflow, FIFO dropouts, and data staleness. Save raw data and configuration before filtering; for calibration, use known conditions and appropriate references; one cannot assume that ordinary ice water and local boiling water precisely constitute the 0/100°C calibration points for all thermometers. Finally, incorporate reference error, installation, and repeatability together into the trusted range of results.
Recalculation Model
frommathimportexp,log,isclose,sin,pir25, beta, t25=10000, 3950, 298.15r50=r25*exp(beta*(1/323.15-1/t25))v50=3.3*r50/(10000+r50)r_back=10000*v50/(3.3-v50)t_back=1/(1/t25+log(r_back/r25)/beta)-273.15assertisclose(t_back,50)assert3588<r50<3589and0.871<v50<0.872assertisclose((3.3/20000)**2*10000*1000,0.27225)assert0.9<13*log(2)*10000*10e-12*1e6<0.91assertisclose((21-1)/2/1000,0.010)assertisclose(0.1*60,6)assert8.32<100/(1.225*9.80665)<8.33forninrange(20):assertisclose(sin(2*pi*900*n/1000),-sin(2*pi*100*n/1000),abs_tol=1e-12)print('NTC inversion, self-heating, settling time, aliasing, delay, and local barometric altitude model passed')
These models distinguish transduction, sampling and error sources; actual accuracy requires calibration against traceable reference quantities.