24  Signal Processing Essentials

fundamentals
signal-processing
ADC
filtering
sensors
In 60 Seconds

Signal processing essentials explains how IoT systems turn messy analog sensor voltages into reliable digital data. The core decisions are choosing an appropriate sample rate, matching ADC resolution to the actual measurement need, and applying the right filter for noise or interference without wasting power, storage, or compute. If you oversample, undersample, or choose the wrong filter, the system can look precise while still being wrong.

24.1 Learning Objectives

By completing this chapter series, you will be able to:

  • Distinguish Analog from Digital: Explain why sensors produce analog signals and why processors require digital data
  • Apply Sampling Concepts: Calculate appropriate sampling rates using the Nyquist-Shannon theorem for IoT sensor signals
  • Evaluate Quantization Trade-offs: Calculate ADC resolution, step size, and their impact on measurement accuracy and power consumption
  • Diagnose Aliasing Artifacts: Identify when sampling rates are insufficient and design anti-aliasing strategies to prevent signal distortion
  • Select Appropriate Filters: Compare low-pass, high-pass, median, and moving average filters to choose the optimal noise reduction approach
  • Configure ADC Parameters: Set up analog-to-digital conversion with matched resolution and sampling rate for real IoT sensor applications
MVU: Minimum Viable Understanding

Core Concept: Signal processing converts continuous analog sensor signals to discrete digital values through sampling (time discretization) and quantization (amplitude discretization). Getting both right prevents aliasing artifacts and wasted resources.

Why It Matters: Every IoT sensor generates analog signals, but microcontrollers only understand digital numbers. Poor signal processing leads to missed events (undersampling), false readings (aliasing), or wasted power and storage (oversampling). A $2 temperature sensor with proper signal processing outperforms a $20 sensor with poor processing.

Key Takeaway: Sample at 2.5-5x the highest frequency you care about (not higher), and match ADC resolution to sensor accuracy - there’s no point having 16-bit precision if your sensor is only accurate to 1%.

Signal processing is about turning the raw, messy electrical signals from sensors into clean, accurate digital numbers that a computer can work with. Imagine trying to have a phone conversation in a noisy room – signal processing is like the noise-cancellation technology that filters out background sounds so you hear only the voice. For IoT, it means converting a temperature sensor’s voltage into a reliable temperature reading, filtering out electrical noise, and doing it all efficiently enough to run on a tiny battery-powered device.

24.2 Overview

Signal processing bridges the continuous analog world of sensors with the discrete digital world of microcontrollers. This chapter series covers the complete journey from raw sensor signals to clean, usable digital data.

Hey friends! I’m Signal Sally, and I help sensors talk to computers!

24.2.1 The Translation Problem

Imagine you speak only English, and your friend speaks only Spanish. You need a translator, right? That’s what signal processing does! Sensors “speak” in smooth, wiggly waves (analog), but computers only understand numbers (digital). Signal processing is the translator!

24.2.2 The Movie Trick

Here’s a fun secret: Movies aren’t really moving! They’re just pictures shown REALLY fast - 24 pictures every second! Your eyes think it’s moving because it’s so quick.

Signal processing works the same way:

  • Sampling = Taking lots of “pictures” of the sensor’s wiggly signal
  • Fast enough = It looks like the real thing!
  • Too slow = Weird glitchy stuff happens (like a car wheel spinning backward in videos!)

24.2.3 Sammy’s Sampling Story

Temperature Terry measures the temperature in your room:

Real temperature: Goes up and down smoothly all day
                  ~~~~~/\~~~~~/\~~~~~

Terry takes a "picture" every minute:
                  * * * * * * * * * *
                  (These dots are the samples!)

The computer sees: 22, 23, 24, 24, 23, 22, 21...

24.2.4 Why Does This Matter?

  • Sample too slowly: You might miss when the room got really hot for a moment
  • Sample too fast: You waste battery and memory for no reason
  • Just right: You catch everything important without wasting energy!

24.2.5 The Goldilocks Rule

  • Too few samples = Miss important changes (like missing your friend wave at you!)
  • Too many samples = Waste energy (like taking 1000 photos when 10 would work!)
  • Just right = Sample at least 2x faster than things change!

Fun Fact: When you hear music, your ear does signal processing too! It turns wiggly air vibrations into signals your brain understands. Your ear can detect sounds vibrating up to 20,000 times per second – and digital music players sample sound at 44,100 times per second (more than 2x that!) to capture everything you can hear!

Try This: Count how many times you blink in one minute. That’s like sampling your eyes! If someone waved at you between blinks, you’d miss it - just like a slow sample rate misses fast signals!

24.3 Signal Processing Pipeline

The following diagram shows how analog sensor signals become clean digital data ready for processing:

Flowchart showing the signal processing pipeline in IoT: analog sensor outputs continuous signal, passes through anti-aliasing filter, sampled by ADC, quantized to digital values, then filtered digitally for clean output data

Signal Processing Pipeline: From Analog Sensor to Clean Digital Data

Understanding the Pipeline:

  1. Sensor Output (Orange): The raw analog signal - continuous voltage that varies smoothly with the physical quantity being measured
  2. Anti-Aliasing Filter (Teal): Removes high-frequency components that could cause aliasing artifacts during sampling
  3. ADC (Navy): The Analog-to-Digital Converter samples the signal at fixed intervals and quantizes each sample to a digital value
  4. Digital Filter (Teal): Removes remaining noise through software algorithms like moving average or low-pass filters
  5. Clean Data (Orange): The final processed signal ready for analysis or transmission

24.4 Key Concepts at a Glance

Concept map for signal processing essentials showing four connected areas: sampling and Nyquist, quantization and ADC resolution, filtering strategies, and system trade-offs such as power, bandwidth, and compute

Signal processing essentials concept map

24.5 Quick Reference: Signal Processing Decisions

  • Fast-changing signal looks wrong: you are probably aliasing. Increase the sample rate or add an anti-aliasing filter before the ADC. See ADC Fundamentals.
  • Readings are too coarse: the quantization step is too large. Increase ADC resolution or reduce the reference range if the sensor allows it. See Quantization and Digital Filtering.
  • Random high-frequency noise dominates the reading: use a moving average or low-pass filter when you need smoother trends more than sharp edges. See Quantization and Digital Filtering.
  • Occasional spikes or outliers appear: use a median filter instead of averaging, because averages smear spikes into nearby samples. See Quantization and Digital Filtering.
  • Sensor output is non-linear: add calibration logic such as lookup tables, piecewise linear sections, or polynomial fitting. See Linearization and Practice.
  • Audio or wideband sensor data is too large to transmit: reduce bandwidth with compression only after you confirm the application can tolerate information loss. See Voice Compression.
Common Pitfall: Oversampling Wastes Resources

The Misconception: “Sampling faster is always better - more data means better accuracy!”

The Reality: Sampling faster than ~5x the signal bandwidth wastes: - Power: ADC conversions consume energy (especially at high speeds) - Storage: More samples = more memory/flash usage - Processing: More data to filter and analyze - Bandwidth: More data to transmit over the network

Real-World Example - Smart Agriculture Soil Moisture:

  • Over-engineered plan: 1 Hz sampling, about 4,320 mW/day, around 345 KB/day, and only 99.2% accuracy.
  • Optimized plan: 0.001 Hz sampling, about 0.43 mW/day, around 0.4 KB/day, and still 98.8% accuracy.

The optimized approach uses 10,000x less power with only 0.4% accuracy reduction! Soil moisture doesn’t change in seconds - sampling every 15 minutes captures all meaningful variation.

Rule of Thumb: Match sample rate to the actual rate of change of your measured phenomenon, not your ADC’s maximum capability.

Experiment with different ADC resolutions and reference voltages to see how they affect measurement precision:

Example Context: A soil moisture sensor outputs 0-3.3V. You need to detect 1% changes in moisture (50 mV resolution). Try different ADC resolutions above to see which works!

24.5.1 Check Your Understanding: ADC Resolution

24.6 Interactive: Nyquist Sampling Calculator

Use this calculator to determine the minimum and recommended sampling rates for your signal:

24.7 Knowledge Check: Signal Processing Basics

24.8 Choosing the Right Filter

Different filtering approaches suit different situations:

Filter selection guide showing when to use notch, median, moving average, low-pass, and high-pass filters based on whether the issue is periodic interference, spikes, random jitter, high-frequency noise, or baseline drift

Filter selection guide for common IoT noise problems
  • Moving average: best when the sensor has random jitter and you care about a smooth trend. Trade-off: it delays the response and blurs sharp transitions. Implementation: average N samples.
  • Median filter: best when the stream has isolated spikes or outliers. Trade-off: more compute because it has to rank or sort samples. Implementation: keep a small window and emit the middle value.
  • Low-pass filter: best when high-frequency noise sits above the useful signal band. Trade-off: reduces available bandwidth and can hide fast events. Implementation: simple digital IIR or FIR filter.
  • Notch filter: best when interference is concentrated at one known frequency, such as 50/60 Hz mains hum. Trade-off: narrower use case and more tuning effort. Implementation: band-reject filter centered on the offending frequency.
  • High-pass filter: best when the problem is slow baseline drift or DC offset. Trade-off: removes steady-state information along with the drift. Implementation: differentiation or a high-pass IIR stage.

24.8.1 Check Your Understanding: Aliasing

24.9 Chapter Contents

This comprehensive topic has been organized into focused chapters:

24.9.1 1. ADC Fundamentals: Sampling and Aliasing

Core concepts for analog-to-digital conversion:

  • Analog vs digital signals and the continuous/discrete divide
  • The Nyquist-Shannon sampling theorem
  • Understanding and preventing aliasing
  • Anti-aliasing filters and their role

Time: ~25 minutes | Level: Foundational to Intermediate

24.9.2 2. Quantization and Digital Filtering

Precision, resolution, and noise reduction:

  • ADC resolution and quantization levels (8-bit to 16-bit)
  • Step size calculations and precision trade-offs
  • Moving average, median, and low-pass filters
  • Choosing the right filter for your application

Time: ~20 minutes | Level: Intermediate

24.9.3 3. Voice Compression for IoT

Audio processing for bandwidth-constrained devices:

  • Toll quality baseline (64 kbps)
  • Companding: μ-law and A-law encoding
  • Linear Predictive Coding (LPC) and source-filter models
  • Codec selection for IoT applications

Time: ~15 minutes | Level: Advanced

24.9.4 4. Sensor Dynamics and Response

Understanding how sensors behave over time:

  • Mass-spring-damper mechanical model
  • Transfer functions and natural frequency
  • Step response: underdamped, critically damped, overdamped
  • Sensor bandwidth and its relationship to sampling

Time: ~15 minutes | Level: Advanced

24.9.5 5. Linearization and Practice

Handling non-linear sensors and hands-on lab:

  • Taylor series linearization
  • Lookup tables and piecewise approximation
  • Knowledge check scenarios
  • ESP32 Wokwi signal processing lab

Time: ~30 minutes | Level: Intermediate to Advanced

24.10 Prerequisites

Before diving into these chapters, you should be familiar with:

24.12 Worked Example: Choosing ADC Resolution and Sampling Rate for a Soil Moisture System

Worked Example: ADC Selection for Precision Agriculture

Scenario: A vineyard in Napa Valley deploys 200 capacitive soil moisture sensors (Decagon EC-5) across 50 hectares. The sensors output 0-3.0V proportional to volumetric water content (0-60%). The irrigation controller needs to detect 1% changes in soil moisture to trigger precision drip irrigation. Sensors are battery-powered (2x AA lithium, 3.6V, 3000 mAh target: 2-year battery life).

Given:

  • Sensor output: 0-3.0V maps to 0-60% volumetric water content (VWC)
  • Required resolution: 1% VWC = 50 mV at the sensor output
  • Soil moisture changes slowly: maximum rate of 0.5%/hour during irrigation
  • Power budget: 3000 mAh / (2 years x 8760 hours) = 0.17 mA average
  • ADC reference voltage: 3.3V (from MCU regulator)

Step 1 – Determine minimum ADC resolution:

Required voltage resolution: 50 mV (to detect 1% VWC change)

  • 8-bit ADC: 256 levels and 12.9 mV steps. It technically detects 1% VWC, but only with 3.9 steps per percent, so noise can still hide small moisture changes.
  • 10-bit ADC: 1,024 levels and 3.2 mV steps. This comfortably detects 1% VWC with about 15.6 steps per percent and is a solid practical baseline.
  • 12-bit ADC: 4,096 levels and 0.8 mV steps. This gives excellent margin and can resolve about 0.1% VWC changes if the rest of the sensor chain is stable enough.

Selected: 12-bit ADC (built into ESP32)

Why: The extra resolution (0.8 mV) allows software averaging to further reduce noise. With 16 samples averaged, effective resolution improves by 4x (equivalent to 14-bit). This detects subtle moisture gradients between vine rows that 10-bit would miss.

Step 2 – Determine sampling rate:

  • Maximum signal change: 0.5% VWC/hour = 0.0083%/minute = 0.42 mV/minute
  • Nyquist minimum: Signal changes at 1/120 Hz (one cycle per 2 hours), so minimum sampling: 1/60 Hz = 1 sample per minute
  • Practical sampling: 1 sample per 10 minutes is sufficient (6x Nyquist) given the slow dynamics
  • Oversampling for noise reduction: Take 16 ADC readings per sample (burst mode), average them

Step 3 – Calculate power consumption:

  • Sleep mode: active for 99.97% of the schedule at only 5 uA, for about 0.12 mAh/day.
  • Wake and ADC burst: 15 ms at 30 mA every 10 minutes, for about 0.108 mAh/day.
  • LoRa transmit: 80 ms at 120 mA every 10 minutes, for about 1.38 mAh/day.
  • Total daily energy: about 1.61 mAh/day.

Battery life: 3000 mAh / 1.61 mAh/day = 1,863 days = 5.1 years (exceeds 2-year target by 2.5x)

Result: The 12-bit ADC with 10-minute sampling and 16-sample averaging achieves 0.2% VWC resolution (5x better than the 1% requirement) while consuming only 1.61 mAh/day. The 2.5x margin on battery life accounts for capacity degradation in outdoor temperature extremes (-5 to +45C in Napa Valley).

Key Insight: For slowly-changing environmental measurements like soil moisture, the sampling rate is often 100-1000x lower than the ADC’s maximum capability. The real power savings come from maximizing sleep time (99.97%) and using burst sampling for noise reduction rather than continuous monitoring.

24.13 Knowledge Check

Common Pitfalls

Sampling a 100 Hz vibration signal at 150 Hz (below the required 200 Hz minimum) folds frequencies above 75 Hz back into the spectrum as false low-frequency components. Always sample at ≥2× the highest frequency of interest, plus margin for anti-aliasing filter roll-off.

Applying FFT to a finite signal segment without a window function (Hann, Hamming, Blackman) causes spectral leakage — energy from one frequency bin bleeds into adjacent bins, masking peaks. Always apply a window function before FFT for spectral analysis.

A low-pass filter with 100 Hz cutoff does not eliminate all frequencies above 100 Hz — it begins attenuating at 100 Hz with gradual roll-off (20 dB/decade for first-order, 40 dB/decade for second-order). Design filters with adequate order for the required stop-band attenuation.

24.14 What’s Next

Start with ADC Fundamentals to build your foundation in sampling theory and the Nyquist theorem, then progress through quantization, filtering, and practical applications.