Unit 3: Sensor Systems & Data Acquisition

ECE140 — Workshop On Iot For Digital Society 10 min read

I. Foundations of Sensor Systems and Data Acquisition

A sensor system converts a physical quantity—such as temperature, pressure, gas concentration, humidity, or distance—into an electrical signal that an IoT device can measure, process, transmit, and interpret. Data acquisition encompasses sensing, signal conditioning, sampling, conversion, filtering, and digital communication.

  • Measurement chain: A typical IoT acquisition path is:
    • Physical quantity → sensor → signal conditioning → ADC or digital interface → processor → filter → network.
  • Transducer principle: A sensor acts as a transducer by converting energy or a physical effect into voltage, current, resistance, capacitance, frequency, or digital data.
  • Analog signal: A continuously varying voltage or current represents the measured quantity; examples include a thermistor voltage and a pressure sensor’s 0–5 V output.
  • Digital signal: Information is represented by discrete logic levels or encoded data transmitted through GPIO, I²C, SPI, UART, or 1-Wire.
  • Signal conditioning: Amplifiers, voltage dividers, filters, buffers, and level shifters adapt sensor output to the acquisition circuit.
  • Sampling requirement: For a signal with maximum frequency (f_{\max}), the sampling frequency should satisfy the Nyquist condition:
    TEXT
    f_s ≥ 2f_max
    • (f_s): sampling frequency in hertz.
    • (f_{\max}): highest relevant signal frequency in hertz.
  • Measurement quality:
    • Accuracy: Closeness to the true value.
    • Precision: Repeatability of measurements.
    • Resolution: Smallest detectable change.
    • Sensitivity: Output change per unit input, such as (10\text{ mV}/^\circ\text{C}).
    • Calibration: Comparison with a known reference to correct offset, gain, or nonlinear error.

II. Sensor Interfacing through Analog-to-Digital Conversion

An analog-to-digital converter translates a conditioned analog voltage into a binary number that a microcontroller can process. Digital sensors, by contrast, perform conversion internally and communicate encoded measurements.

A. Digital and analog sensor interfacing using ADCs

The interface method depends on whether the sensor supplies a continuous electrical output or already digitized data.

  1. Analog sensor interfacing

    • ADC conversion: For an ideal (N)-bit ADC with reference voltage (V_{\text{ref}}), the digital code is:
      TEXT
      D = round[(V_in / V_ref)(2^N − 1)]
      • (D): ADC output code.
      • (V_{\text{in}}): input voltage.
      • (V_{\text{ref}}): reference voltage.
      • (N): ADC resolution in bits.
    • Voltage resolution: The approximate least significant bit size is:
      TEXT
      ΔV = V_ref / 2^N

      A 12-bit ADC using (3.3\text{ V}) has (\Delta V = 3.3/4096 \approx 0.806\text{ mV}).
    • Input range: The sensor output must remain between ground and (V_{\text{ref}}), unless the ADC supports differential or bipolar inputs.
    • Signal conditioning:
      • An operational amplifier can amplify millivolt-level bridge outputs.
      • A voltage divider converts resistance changes into voltage.
      • An RC low-pass filter suppresses high-frequency noise before sampling.
    • Source impedance: A high-impedance sensor may require a voltage-follower buffer because an ADC’s sample-and-hold capacitor draws brief charging current.
    • Reference stability: ADC results scale directly with (V_{\text{ref}}); a noisy supply used as the reference introduces measurement noise.
  2. Digital sensor interfacing

    • Direct communication: Digital sensors connect through protocols such as I²C, SPI, UART, 1-Wire, or pulse-width output rather than an external ADC.
    • I²C interface: Uses SDA for data and SCL for clock, normally with pull-up resistors; multiple addressed sensors can share the bus.
    • SPI interface: Uses clock, data-in, data-out, and chip-select lines; it generally offers higher speed than I²C.
    • Internal processing: A digital temperature sensor may contain a sensing element, amplifier, ADC, calibration memory, and communication controller.
    • Comparison: Analog interfaces provide direct access and flexibility, whereas digital interfaces simplify wiring, calibration, and noise-resistant transfer.

B. Applications and limitations

ADC selection must balance resolution, speed, power, cost, and the sensor’s effective accuracy.

  • Resolution versus accuracy: A 16-bit output does not guarantee 16-bit accuracy because reference error, thermal noise, offset, and nonlinearity reduce usable resolution.
  • Aliasing: Frequencies above (f_s/2) can appear as false lower frequencies; an analog anti-aliasing filter must operate before the ADC.
  • Quantization error: Ideal rounding introduces an error of approximately (\pm 0.5) least significant bit.
  • Grounding: Shared return paths for radios, motors, and analog sensors can create ground noise; careful grounding and decoupling are required.

III. Interfacing Common Analog Sensors

Analog sensors encode a physical condition as a variable voltage, current, resistance, or capacitance. Their outputs usually require excitation, conversion, calibration, and protection before connection to an ADC.

A. Analog sensor interfacing, including gas, temperature, humidity, pressure, and proximity sensors

Each sensor category uses a distinct physical principle and therefore requires appropriate conditioning.

  • Gas sensors: Metal-oxide sensors alter resistance when exposed to gases.

    • A sensing resistance (R_s) is commonly measured through a load resistor (R_L):
      TEXT
      V_out = V_c × R_L / (R_s + R_L)
    • (Vc): circuit voltage; (V{\text{out}}): measured voltage.
    • Concentration estimation requires a calibrated relationship between (R_s/R_0) and gas concentration, often expressed in parts per million.
    • Heater elements can consume tens or hundreds of milliwatts and may require warm-up time.
  • Temperature sensors: Thermistors, semiconductor sensors, and resistance temperature detectors are common.

    • For an NTC thermistor, resistance decreases as temperature increases.
    • A voltage divider converts thermistor resistance into ADC voltage.
    • The Beta approximation is:
      TEXT
      1/T = 1/T₀ + (1/B) ln(R/R₀)
    • (T) and (T_0): absolute temperatures in kelvin; (R) and (R_0): corresponding resistances; (B): thermistor constant in kelvin.
  • Humidity sensors: Capacitive humidity elements change capacitance with relative humidity, while integrated modules provide a conditioned analog voltage.

    • Relative humidity is expressed as a percentage of the maximum water-vapour content possible at the same temperature.
    • Temperature compensation is important because humidity response and saturation pressure vary with temperature.
  • Pressure sensors: Piezoresistive diaphragms change resistance under applied pressure.

    • Four resistive elements may form a Wheatstone bridge that produces a small differential voltage.
    • An instrumentation amplifier provides high input impedance and rejects common-mode voltage.
    • Pressure units include pascal, kilopascal, bar, and millibar; (1\text{ Pa}=1\text{ N/m}^2).
  • Proximity sensors: Infrared reflective, inductive, capacitive, and ultrasonic devices detect nearby objects.

    • An analog infrared sensor maps reflected-light intensity to voltage, but surface colour affects the result.
    • Inductive sensors detect conductive targets through changes in an electromagnetic field.
    • Capacitive sensors respond to dielectric changes and can detect non-metallic materials.

B. Calibration and practical limitations

Reliable sensor interfacing requires conversion of raw ADC codes into engineering units while accounting for environmental and device-specific errors.

  • Two-point calibration: If raw readings (x_1,x_2) correspond to reference values (y_1,y_2), use:
    TEXT
    y = y₁ + (x − x₁)(y₂ − y₁)/(x₂ − x₁)
  • Cross-sensitivity: A gas sensor may respond to several gases, while a humidity sensor may also vary with temperature.
  • Drift and ageing: Sensor characteristics change over time, requiring periodic recalibration.
  • Placement: Heat from processors, airflow obstruction, condensation, and enclosure design can bias environmental measurements.

IV. Energy-Efficient Sensing

Battery-powered IoT nodes must minimize sensor, processor, and communication energy while still sampling often enough to detect meaningful events.

A. Low-power sensor operation strategies

Low-power operation reduces average current by keeping components inactive whenever measurement or communication is unnecessary.

  • Duty cycling: Alternate between short active periods and long sleep periods:
    TEXT
    I_avg = D I_active + (1 − D) I_sleep
    • (I_{\text{avg}}): average current.
    • (D): active-time fraction.
    • (I{\text{active}}), (I{\text{sleep}}): active and sleep currents.
  • Power gating: A MOSFET or load switch disconnects sensor power during sleep; this is useful when standby current exceeds the switch leakage.
  • Warm-up management: Sensors should be activated early enough to stabilize, but not left powered continuously; gas sensors may restrict this strategy because their heaters require long stabilization.
  • Adaptive sampling: Sample slowly when measurements are stable and increase the rate when rapid change or an event is detected.
  • Interrupt operation: Motion, threshold, or comparator interrupts wake the microcontroller only when necessary.
  • Batch processing: Store several readings and transmit them together because radio startup and connection overhead can consume more energy than sensing.
  • Local thresholding: Send data only when a value changes beyond a defined limit, such as (2^\circ\text{C}), rather than transmitting every sample.
  • Efficient hardware: Select sensors with low shutdown current, short conversion time, configurable data rate, and built-in FIFO storage.

B. Design trade-offs

Energy savings must not make the sensing system unresponsive or inaccurate.

  • Latency: Long sleep intervals delay event detection.
  • Stabilization error: Reading immediately after power-up may produce inaccurate values.
  • Sampling loss: Aggressive duty cycling can miss short events.
  • Battery estimate: Ideal operating time is battery capacity divided by average current, although self-discharge, temperature, and conversion losses reduce actual life.

V. Smoothing with a Moving Average

A moving average is a finite-window filter that replaces each measurement with the arithmetic mean of recent samples, thereby reducing random high-frequency variation.

A. Data filtering using moving average

The filter smooths noisy sensor readings using limited computation and memory.

  • Equation: For a window of (M) samples:
    TEXT
    y[k] = (1/M) Σ x[k − i],  i = 0 to M − 1
    • (x[k]): current raw sample.
    • (y[k]): filtered output.
    • (M): window length.
    • (k): sample index.
  • Worked example: For readings (20, 22, 21, 25), a four-sample average is ((20+22+21+25)/4=22).
  • Efficient update: Maintain a running sum:
    TEXT
    sum = sum + new_sample − oldest_sample
    average = sum / M
  • Window effect: A larger (M) produces stronger smoothing but increases delay and weakens the response to rapid changes.
  • Noise assumption: Averaging is most effective for zero-mean, uncorrelated measurement noise.
  • Implementation: A circular buffer stores the latest (M) samples without shifting the entire array.

B. Applications and limitations

Moving averages suit slowly changing measurements but do not model system dynamics.

  • Applications: Temperature, humidity, battery voltage, and light-level monitoring.
  • Delay: A trailing window introduces an approximate group delay of ((M-1)/2) samples.
  • Outliers: One extreme reading affects several subsequent outputs until it leaves the window.
  • Memory: Exact windowed averaging requires storage for (M) samples.

VI. State Estimation with a Kalman Filter

A Kalman filter recursively estimates an unobserved system state by combining a mathematical process model with noisy measurements, weighted according to their uncertainties.

A. Data filtering using Kalman filter

The algorithm alternates between prediction and measurement correction for approximately linear systems with Gaussian noise.

  • Prediction equations:

    TEXT
    x̂⁻ₖ = A x̂ₖ₋₁ + B uₖ
    P⁻ₖ = A Pₖ₋₁ Aᵀ + Q
    • (\hat{x}): estimated state; (A): state-transition model.
    • (u): control input; (B): control-input model.
    • (P): estimate-error covariance; (Q): process-noise covariance.
  • Correction equations:

    TEXT
    Kₖ = P⁻ₖ Hᵀ(H P⁻ₖ Hᵀ + R)⁻¹
    x̂ₖ = x̂⁻ₖ + Kₖ(zₖ − Hx̂⁻ₖ)
    Pₖ = (I − KₖH)P⁻ₖ
    • (K): Kalman gain; (z): measurement.
    • (H): measurement model; (R): measurement-noise covariance.
    • (I): identity matrix.
  • Innovation: The term (z_k-H\hat{x}^{-}_k) is the difference between the actual and predicted measurement.

  • Uncertainty weighting: Large (R) makes the filter trust the model more; large (Q) makes it adapt more strongly to measurements.

  • Scalar use: A one-dimensional filter can smooth temperature or distance readings with only scalar arithmetic.

  • Initialization: The initial state estimate and covariance should represent the best available starting value and its uncertainty.

B. Applications and limitations

Kalman filtering is valuable when both sensor noise and system motion must be considered.

  • Applications: GPS and inertial fusion, object tracking, pressure-based altitude estimation, and robotic localization.
  • Advantage over moving average: It predicts physical evolution and adjusts weighting from uncertainty rather than assigning equal weight to a fixed window.
  • Model dependence: Incorrect (A), (Q), or (R) values can produce slow, noisy, or unstable estimates.
  • Computational cost: Matrix multiplication and inversion require more processing and memory than a moving average.
  • Nonlinear systems: Extended or unscented Kalman filters are used when state-transition or measurement relationships are significantly nonlinear.