Sensors & Measurement · Study deck

Sensor Processing: Filter Selection and Validation

A vibration filter can remove noise and erase the fault at the same time.

Physics Phoebe is your guide for this deck.

sensordataprocessing
Physics Phoebe, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Explain: The Mistake: Using a large moving average window (N=32 or N=64 samples) to filter sensor data that changes rapidly, introducing unacceptable lag that makes control systems sluggish or miss transient events entirely.
  • Explain: Result: The two-stage filter detects bearing wear threshold crossings within approximately 0.5 seconds (the N=50 averaging window fill time at 100 Hz) while completely rejecting electrical interference spikes.
  • Explain: The dry-to-trigger region is the important operating span, so the ±1.5% and ±2.0% errors support a 30% irrigation threshold with more margin than the wetter end.
iotclass.org

Major section

Vibration Filter Selection

Scenario: A food processing plant needs to monitor vibration on 12 conveyor belt motors.

  • At 100 Hz, a 5-sample window covers 50 ms -- fast enough to preserve real vibration changes.
  • Reports stable RMS value for threshold comparison.
  • The 10-minute sustained-threshold requirement is evaluated by comparing consecutive 0.5-second RMS averages over a sliding evaluation period.
iotclass.org

Major section

Vibration Filter Selection (continued)

Result: The two-stage filter detects bearing wear threshold crossings within approximately 0.5 seconds (the N=50 averaging window fill time at 100 Hz) while completely rejecting electrical interference spikes.

  • Key Insight: For vibration monitoring, always use a median filter as the first stage to eliminate electrical spikes.
  • A moving average alone will spread spike energy across the window, potentially triggering false bearing-wear alerts.
  • The two-stage approach costs negligible additional resources on modern MCUs.
iotclass.org

Major section

Sensor Calibration

Filtering removes random noise, but it cannot fix systematic errors built into the sensor itself.

  • A sensor that consistently reads 2 degrees too high will still read 2 degrees too high after filtering -- just with less jitter.
  • You have cleaned random variation.
  • The next failure mode is bias: a value can be stable and still be wrong.

Why it matters

The process needs two separated known values because one point cannot distinguish slope error from offset.

Sensor measurement error types
Sensor measurement error types
iotclass.org

Major section

Sensor Calibration (continued)

The process needs two separated known values because one point cannot distinguish slope error from offset.

  • Each error leaves a different pattern, so one calibration or filter cannot repair them all.
  • To see how both systematic terms can be estimated, inspect Figure: Two-point calibration process before using the formula.
  • This sequence connects calibration arithmetic to evidence that the corrected line works between its endpoints.
iotclass.org

Major section

Soil Moisture Calibration

Scenario: You are deploying a soil moisture monitoring system for a greenhouse.

  • The capacitive soil moisture sensor outputs an analog voltage (0-3.3V) that varies with soil moisture content.
  • However, the raw ADC readings do not correspond to meaningful moisture percentages.
  • You need accurate readings to trigger irrigation at 30% moisture.

Numbers to remember

30%You need accurate readings to trigger irrigation at 30% moisture.
0-60%confirming this sensor has good linearity in the 0-60% range.
40–60%From 40–60%, the ±2.5% result is still accepted for this use
iotclass.org

Major section

Soil Moisture Calibration (continued)

The data points fall closely on the linear model, confirming this sensor has good linearity in the 0-60% range.

  • For readings beyond 60% (saturated soil), the linear model extrapolates but accuracy degrades -- use multi-point calibration if the full 0-100% range is needed.
  • The dry-to-trigger region is the important operating span, so the ±1.5% and ±2.0% errors support a 30% irrigation threshold with more margin than the wetter end.
  • From 40–60%, the ±2.5% result is still accepted for this use, but it should not be silently generalised beyond the highest calibration reference.
iotclass.org

Major section

Common Processing Pitfalls

The Mistake: Using a large moving average window (N=32 or N=64 samples) to filter sensor data that changes rapidly, introducing unacceptable lag that makes control systems sluggish or miss transient events entirely.

  • For slowly-changing signals (room temperature sampled at 1Hz), a 10-second window works well.
  • This works for sensors with linear response and negligible gain error.
  • But many sensors are inherently non-linear: thermistors follow the Steinhart-Hart equation (exponential), pH electrodes have temperature-dependent Nernst slope, photodiodes have logarithmic response at high intensity.
iotclass.org

Major section

Common Pitfalls

The calibrated sensor can never be more accurate than the reference standard you calibrated against.

  • A moving average window that is too large smooths out genuine rapid changes in the measured quantity.
  • A temperature spike from a briefly opened oven door may be a real event, not noise.
  • Flashing new firmware can erase EEPROM calibration data depending on memory layout.
iotclass.org

Deck summary

Key takeaways

Scenario: A food processing plant needs to monitor vibration on 12 conveyor belt motors.

  • Result: The two-stage filter detects bearing wear threshold crossings within approximately 0.5 seconds (the N=50 averaging window fill time at 100 Hz) while completely rejecting electrical interference spikes.
  • Filtering removes random noise, but it cannot fix systematic errors built into the sensor itself.
  • The process needs two separated known values because one point cannot distinguish slope error from offset.
  • Scenario: You are deploying a soil moisture monitoring system for a greenhouse.
iotclass.org

Retrieval practice

Recall check 1 of 3

Physics Phoebe says: answer from memory, then check your reasoning.

Q1You have a noisy temperature sensor that occasionally produces spike values (e.g., 22C, 23C, 55C, 22C). Which filter is better for removing these spikes?

AMoving average filter - it averages out the spikes
BMedian filter - it ignores outliers by selecting the middle value
CKalman filter - it uses state prediction
DNo filter needed - spikes are valid data
Show answer

Answer: B The median filter is the best choice for removing spike noise.

Q2Your temperature sensor reads 1.2C in an ice bath (should be 0C) and 98.8C in boiling water (should be 100C). What is the calibration slope?

ASlope = 0.976
BSlope = 1.000 (no correction needed)
CSlope = 1.025
DSlope = 1.200
Show answer

Answer: C

iotclass.org

Retrieval practice

Recall check 2 of 3

Physics Phoebe says: answer from memory, then check your reasoning.

Q3Why is regular calibration important for IoT sensors deployed in the field?

ASensors run out of calibration memory over time
BCalibration improves battery life
CSoftware updates reset calibration values
DSensor drift changes offset and gain over time.
Show answer

Answer: D Sensors experience drift over time due to aging, environmental exposure (temperature cycles, humidity, contamination), mechanical stress, and component degradation.

Q4For a moving average filter with window size N=10 sampling at 100Hz, what is the approximate latency introduced?

A10 milliseconds
B50 milliseconds (N/2 samples delay)
C100 milliseconds (N samples delay)
DNo latency - filtering happens instantly
Show answer

Answer: B A moving average filter introduces a group delay of N/2 samples.

iotclass.org

Retrieval practice

Recall check 3 of 3

Physics Phoebe says: answer from memory, then check your reasoning.

Q5Place each data-processing responsibility where it lives so you can preserve measurement meaning from raw samples through a result that an application can safely use.

AData Acquisition
BData Cleaning
CData Transformation
DData Analysis
Show answer

Answer: A Place each data-processing responsibility where it lives so you can preserve measurement meaning from raw samples through a result that an application can safely use.

Q6Complete the moving average filter for sensor data:

Awindow = deque(maxlen=10)
Bwindow = list(10)
Cwindow = deque(size=10)
Dwindow = array(10)
Show answer

Answer: A A deque with maxlen automatically drops old values when full, creating a sliding window.

iotclass.org

Print reference

Answers 1 of 2

Answer key.

  1. B · The median filter is the best choice for removing spike noise.
  2. C
  3. D · Sensors experience drift over time due to aging, environmental exposure (temperature cycles, humidity, contamination), mechanical stress, and component degradation.
  4. B · A moving average filter introduces a group delay of N/2 samples.
  5. A · Place each data-processing responsibility where it lives so you can preserve measurement meaning from raw samples through a result that an application can safely use.
iotclass.org

Print reference

Answers 2 of 2

Answer key.

  1. A · A deque with maxlen automatically drops old values when full, creating a sliding window.
iotclass.org