%%{init: {'theme': 'base', 'themeVariables': {'primaryColor':'#2C3E50','primaryTextColor':'#fff','primaryBorderColor':'#16A085','lineColor':'#16A085','secondaryColor':'#E67E22','tertiaryColor':'#7F8C8D','clusterBkg':'#ECF0F1','clusterBorder':'#16A085','edgeLabelBackground':'#ECF0F1'}}}%%
flowchart LR
A["Analog Signal<br/>(Continuous)"] --> B["Anti-Aliasing<br/>Filter<br/>(Low-Pass)"]
B --> C["Sample & Hold<br/>Circuit"]
C --> D["ADC<br/>(Analog-to-Digital<br/>Converter)"]
D --> E["Digital Value<br/>(Discrete)"]
style A fill:#E67E22,stroke:#2C3E50,stroke-width:3px,color:#fff
style B fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
style C fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
style D fill:#2C3E50,stroke:#16A085,stroke-width:3px,color:#fff
style E fill:#E67E22,stroke:#2C3E50,stroke-width:3px,color:#fff
66 Signal Processing Overview
66.1 Learning Objectives
By the end of this chapter, you will be able to:
- Distinguish Analog from Digital: Understand why sensors produce analog signals and why processors need digital data
- Apply Sampling Concepts: Explain the Nyquist theorem and calculate appropriate sampling rates
- Understand the ADC Pipeline: Trace signal flow from analog sensor to digital value
- Select Appropriate Sample Rates: Choose sampling rates for different IoT applications
- Avoid Common Pitfalls: Recognize when oversampling wastes resources
Fundamentals: - Data Representation - Binary numbers and ADC resolution - Sensor to Network Pipeline - Complete signal journey - Aliasing and ADC Resolution - Next in series - Voice Compression - Audio signal processing - Sensor Dynamics - Temporal response characteristics
Sensing: - Sensor Fundamentals - Sensor types and outputs - Sensor Circuits - Signal conditioning circuits - Sensor Interfacing - Reading analog sensors - Electronics Basics - Voltage and current fundamentals - Analog/Digital Electronics - ADC deep dive
Data Processing: - Data Formats for IoT - Encoding processed data - Multi-Sensor Fusion - Combining signals - Modeling and Inferencing - ML on sensor data
Design: - Hardware Prototyping - ADC selection - Sensor Labs - Hands-on ADC - Network Traffic Analysis - Signal analysis tools
Learning: - Knowledge Gaps Hub - Start here - Simulations Hub - Signal processing tools
66.2 Prerequisites
Before diving into this chapter, you should be familiar with:
- Sensor Fundamentals and Types: Understanding different sensor types and their output characteristics provides context for why signal processing is necessary
- Data Representation Fundamentals: Knowledge of binary numbers, bits, and bytes is essential for understanding ADC resolution and digital signal representation
- Basic electronics: Familiarity with voltage, current, and simple circuits helps understand analog signal characteristics
The Problem: Sensors measure the real world (temperature, light, pressure), which is continuous and smooth. But microcontrollers and computers only understand discrete numbers (0s and 1s).
The Solution: Signal processing bridges this gap by converting continuous analog signals into discrete digital values that computers can process.
Real-World Analogy: Imagine watching a movie. The real world moves smoothly, but a movie is actually 24 still pictures per second. Your brain fills in the gaps, so it looks smooth. Signal processing does the same thing—it takes “snapshots” of sensor values fast enough that we capture all the important information.
Key Terms:
| Term | Simple Definition |
|---|---|
| Analog Signal | Continuous value that can be anything (like temperature: 23.456789…°C) |
| Digital Signal | Discrete value limited to specific numbers (like 23, 24, 25°C) |
| Sampling | Taking snapshots of an analog signal at regular intervals |
| Sampling Rate | How many snapshots per second (measured in Hz) |
| Resolution | How precisely we can measure each snapshot (8-bit = 256 levels) |
| Aliasing | Distortion when sampling too slowly (makes fast signals look slow) |
The Bottom Line: Sample fast enough (at least 2× the fastest change you care about) and with enough precision (10-12 bits for most IoT) to capture what matters without wasting resources.
A wearable ECG sensor demonstrates the complete signal processing pipeline:
Raw Signal Characteristics: - Cardiac signal: 0.5-40 Hz frequency range (heart rate + waveform shape) - Powerline noise: 50/60 Hz interference from electrical environment - Muscle artifacts: High-frequency noise from arm movement - DC drift: Baseline wander from electrode contact variation
Processing Chain:
- High-pass filter (0.5 Hz cutoff): Removes DC drift and baseline wander
- Notch filter (50/60 Hz): Eliminates powerline interference
- Low-pass filter (40 Hz cutoff): Removes muscle artifacts and high-frequency noise
- Anti-aliasing filter (100 Hz): Prevents sampling distortion
- ADC sampling (250 Hz): Nyquist requires 2× the max frequency = 200 Hz minimum; 250 Hz provides 25% safety margin above Nyquist
- R-peak detection: Pan-Tompkins algorithm identifies heartbeat peaks
- Heart rate calculation: 72 BPM from R-R interval measurement (833 ms between peaks)
System Performance: - ADC resolution: 12-bit (0.8 mV precision for 3.3V range) - Power consumption: 1.2 mW continuous operation - Battery life: 8 hours on 50 mAh battery - Accuracy: ±2 BPM compared to medical-grade ECG - Latency: <100 ms from heartbeat to BPM update
Why This Matters: Without proper filtering, the 60 Hz powerline noise would overwhelm the 1-2 Hz heart rate signal (30× stronger!). The multi-stage filter cascade removes interference while preserving the cardiac waveform. Sampling at 250 Hz (not 1000 Hz) saves 75% power without losing essential information.
Key Lesson: Signal processing isn’t just about converting analog to digital—it’s about intelligently filtering noise, choosing appropriate sample rates, and balancing accuracy with power consumption.
In one sentence: Signal processing converts continuous analog sensor signals to discrete digital values through sampling (time discretization) and quantization (amplitude discretization), and getting both right prevents aliasing artifacts and wasted resources.
Remember this rule: 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 concepts appear throughout IoT systems. Here’s where to explore deeper:
Learning Hubs: - Simulations Hub: Try the Quick Sensor Selector tool to see how sampling rate and resolution affect different sensor types - Knowledge Gaps Hub: Common misconceptions about aliasing and resolution - Quizzes Hub: Test your Nyquist theorem understanding with interactive scenarios
Practical Applications: - Sensor Labs: Hands-on ADC configuration with real sensors - Prototyping Hardware: ADC selection for Arduino, ESP32, Raspberry Pi - Network Traffic Analysis: Wireshark uses signal processing to analyze packet timing
Advanced Topics: - Multi-Sensor Fusion: Combining signals from multiple sensors with different sampling rates - Anomaly Detection: Detecting outliers in filtered sensor streams - Edge Computing Patterns: Processing signals locally to reduce bandwidth
Explore these connections to see how signal processing fundamentals apply across diverse IoT applications!
66.3 Analog vs Digital Signals
66.3.1 The Continuous World
Physical phenomena are inherently continuous—temperature changes smoothly, light intensity varies gradually, and sound waves oscillate continuously.
Example: A thermometer might show 23.456789…°C at one instant and 23.458123…°C a moment later. There are infinite possible values between any two measurements.
66.3.2 The Digital Constraint
Microcontrollers and computers work with discrete digital values: - 8-bit number: Can only represent 256 different values (0-255) - 12-bit number: 4,096 different values (0-4095) - 16-bit number: 65,536 different values (0-65535)
This creates two challenges:
- Sampling: How often do we measure the signal? (temporal discretization)
- Quantization: How precisely do we measure each sample? (amplitude discretization)
ADC Pipeline: The complete analog-to-digital conversion process. Anti-aliasing filter removes high frequencies before sampling to prevent distortion. Sample & hold captures instantaneous voltage. ADC quantizes to nearest digital level. {fig-alt=“Flowchart showing analog-to-digital conversion pipeline: analog signal flows through anti-aliasing filter, sample-and-hold circuit, ADC, and outputs digital value. Components colored orange (input/output), teal (preprocessing), and navy (ADC core).”}
This variant shows the same ADC pipeline with concrete values from a real temperature sensor - making abstract concepts tangible:
%% fig-alt: "ADC pipeline with concrete temperature sensor example showing actual values at each stage. Analog Signal shows NTC thermistor outputting 1.234V for 23.5°C room temperature. Anti-Aliasing Filter with 10Hz cutoff removes HVAC cycling noise, output unchanged at 1.234V. Sample & Hold captures voltage 1000 times per second, holds 1.234V during conversion. 12-bit ADC converts 1.234V to digital value 1534 (range 0-4095 for 0-3.3V). Finally, microcontroller maps 1534 back to 23.5°C temperature reading. This concrete example shows what happens to real sensor data at each pipeline stage."
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor':'#2C3E50','primaryTextColor':'#fff','primaryBorderColor':'#16A085','lineColor':'#16A085','secondaryColor':'#E67E22','tertiaryColor':'#7F8C8D','fontSize':'11px'}}}%%
flowchart TD
subgraph analog["1. ANALOG SIGNAL"]
A1["NTC Thermistor<br/>outputs 1.234V"]
A2["(23.5°C room temp)"]
end
subgraph filter["2. ANTI-ALIASING FILTER"]
F1["10Hz Low-Pass<br/>removes HVAC noise"]
F2["Output: 1.234V<br/>(noise removed)"]
end
subgraph sample["3. SAMPLE & HOLD"]
S1["Captures voltage<br/>1000× per second"]
S2["Holds 1.234V<br/>during conversion"]
end
subgraph adc["4. ADC CONVERSION"]
D1["12-bit ADC"]
D2["1.234V → 1534<br/>(0-4095 range)"]
end
subgraph digital["5. DIGITAL OUTPUT"]
O1["Microcontroller<br/>reads: 1534"]
O2["Maps back:<br/>23.5°C"]
end
analog --> filter --> sample --> adc --> digital
style analog fill:#E67E22,stroke:#2C3E50,color:#fff
style filter fill:#16A085,stroke:#2C3E50,color:#fff
style sample fill:#16A085,stroke:#2C3E50,color:#fff
style adc fill:#2C3E50,stroke:#16A085,color:#fff
style digital fill:#E67E22,stroke:#2C3E50,color:#fff
Why this variant helps: The original shows abstract component names. This variant shows actual values flowing through a real temperature sensor - you can trace 23.5°C from voltage (1.234V) through digital value (1534) and back. Understanding what happens to real data at each stage makes the pipeline tangible.
66.4 The Nyquist Theorem: How Fast to Sample?
The fundamental question: How many times per second must we sample to accurately capture a changing signal?
Nyquist-Shannon Sampling Theorem: > To accurately capture a signal, you must sample at more than twice the highest frequency component.
Minimum Sampling Rate = 2 × Maximum Signal Frequency
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor':'#2C3E50','primaryTextColor':'#fff','primaryBorderColor':'#16A085','lineColor':'#16A085','secondaryColor':'#E67E22','tertiaryColor':'#7F8C8D','clusterBkg':'#ECF0F1','clusterBorder':'#16A085','edgeLabelBackground':'#ECF0F1'}}}%%
graph TB
subgraph under["❌ Undersampling (< 2f)"]
U1["Sampling Rate: 0.8f<br/>(Too Slow)"]
U2["Result: Aliasing<br/>Signal appears distorted<br/>Fast signal looks slow"]
end
subgraph nyquist["⚠️ Nyquist Minimum (= 2f)"]
N1["Sampling Rate: 2f<br/>(Barely Adequate)"]
N2["Result: Reconstructible<br/>Theoretically correct<br/>No margin for error"]
end
subgraph over["✅ Oversampling (> 2f)"]
O1["Sampling Rate: 5-10f<br/>(Practical Choice)"]
O2["Result: Accurate<br/>Clean reconstruction<br/>Safety margin"]
end
U1 --> U2
N1 --> N2
O1 --> O2
style under fill:#E67E22,stroke:#2C3E50,stroke-width:3px,color:#000
style nyquist fill:#7F8C8D,stroke:#2C3E50,stroke-width:3px,color:#fff
style over fill:#16A085,stroke:#2C3E50,stroke-width:3px,color:#fff
style U1 fill:#ECF0F1,stroke:#E67E22,stroke-width:2px,color:#000
style U2 fill:#ECF0F1,stroke:#E67E22,stroke-width:2px,color:#000
style N1 fill:#ECF0F1,stroke:#7F8C8D,stroke-width:2px,color:#000
style N2 fill:#ECF0F1,stroke:#7F8C8D,stroke-width:2px,color:#000
style O1 fill:#ECF0F1,stroke:#16A085,stroke-width:2px,color:#000
style O2 fill:#ECF0F1,stroke:#16A085,stroke-width:2px,color:#000
Nyquist Sampling Comparison: Undersampling causes aliasing distortion. Sampling exactly at 2f is theoretically sufficient but risky. Practical systems oversample at 5-10× the signal frequency for reliability. {fig-alt=“Three-column comparison showing undersampling (red, causes aliasing), Nyquist minimum (gray, barely adequate), and oversampling (teal, practical choice with safety margin). Each shows sampling rate and resulting signal quality.”}
This variant uses a movie filming analogy to make sampling rate intuitive:
%% fig-alt: "Analogy comparing Nyquist sampling to movie frame rates. A spinning wheel at 30 rotations per second (like a car wheel at highway speed) is filmed at different frame rates. At 24 fps (too slow, below Nyquist), wheels appear to spin backward - this is aliasing, the same effect as undersampling. At 60 fps (exactly 2x, Nyquist minimum), wheels appear frozen - technically correct but no margin for faster motion. At 120 fps (4x, oversampled), wheels spin correctly with smooth motion - this is the practical choice like sampling at 5-10x signal frequency. Key insight: just as movies need enough frames to capture motion, IoT sensors need enough samples to capture signal changes."
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#16A085', 'lineColor': '#16A085', 'secondaryColor': '#E67E22', 'tertiaryColor': '#7F8C8D'}}}%%
graph TB
subgraph MOTION["Spinning Wheel: 30 rotations/sec"]
WHEEL["Like a car wheel<br/>at highway speed"]
end
subgraph SLOW["24 fps: TOO SLOW"]
S1["Below Nyquist (< 2×30)"]
S2["Wheel appears to<br/>spin BACKWARD"]
S3["This is ALIASING!"]
end
subgraph EXACT["60 fps: EXACTLY 2×"]
E1["At Nyquist limit"]
E2["Wheel appears<br/>FROZEN in place"]
E3["No margin for error"]
end
subgraph FAST["120 fps: OVERSAMPLED"]
F1["4× frequency (safe)"]
F2["Wheel spins smoothly<br/>FORWARD correctly"]
F3["Practical choice!"]
end
MOTION --> SLOW
MOTION --> EXACT
MOTION --> FAST
style WHEEL fill:#2C3E50,stroke:#16A085,stroke-width:2px,color:#fff
style S1 fill:#E67E22,stroke:#2C3E50,stroke-width:1px,color:#fff
style S2 fill:#E67E22,stroke:#2C3E50,stroke-width:1px,color:#fff
style S3 fill:#E67E22,stroke:#2C3E50,stroke-width:2px,color:#fff
style E1 fill:#7F8C8D,stroke:#2C3E50,stroke-width:1px,color:#fff
style E2 fill:#7F8C8D,stroke:#2C3E50,stroke-width:1px,color:#fff
style E3 fill:#7F8C8D,stroke:#2C3E50,stroke-width:1px,color:#fff
style F1 fill:#16A085,stroke:#2C3E50,stroke-width:1px,color:#fff
style F2 fill:#16A085,stroke:#2C3E50,stroke-width:1px,color:#fff
style F3 fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
Why this variant helps: The original shows abstract frequency ratios (2f, 0.8f). Everyone has seen the “wagon wheel effect” in movies where car wheels appear to spin backward. This directly connects Nyquist undersampling to a visible, memorable phenomenon that students can visualize.
66.4.1 Practical Examples
Example 1: Temperature Sensor - Building HVAC changes slowly: ~0.01 Hz (1 cycle per 100 seconds) - Nyquist requirement: Sample > 0.02 Hz - Practical choice: 0.1 Hz (once every 10 seconds) provides 5× margin
Example 2: Heart Rate Monitor - Heart rate: 0.5-3 Hz (30-180 bpm) - Nyquist requirement: Sample > 6 Hz - Practical choice: 100-500 Hz to capture waveform shape, not just frequency
Example 3: Accelerometer for Vibration - Machine vibration: 0-1000 Hz - Nyquist requirement: Sample > 2000 Hz - Practical choice: 5000-10000 Hz for safety margin
The Myth: “I should sample as fast as possible to get the best data quality.”
Why It’s Wrong: Higher sampling rates don’t improve signal quality beyond Nyquist requirements—they just waste resources.
The Reality:
Misconception #1: “1000 Hz is better than 100 Hz for all sensors” - Reality: Temperature changes at 0.01 Hz. Sampling at 1000 Hz captures the same 0.01 Hz signal 100,000 times without gaining new information. - Cost: 10× higher sampling rate = 10× more power, 10× more data storage, 10× more bandwidth - Better approach: Match sampling rate to signal bandwidth (5-10× Nyquist, not 1000×)
Misconception #2: “16-bit ADC is always better than 12-bit” - Reality: If your sensor accuracy is ±1% (e.g., thermistor), 12-bit resolution (0.025%) already exceeds sensor precision by 40×. Using 16-bit (0.0015%) provides 667× more precision than the sensor can deliver! - Cost: 16-bit ADCs typically consume 3-5× more power than 12-bit - Better approach: Match ADC resolution to sensor precision, not maximum available bits
Misconception #3: “Filtering removes important data” - Reality: Filtering removes noise, not signal. A low-pass filter with 40 Hz cutoff removes 60 Hz powerline interference (noise) while preserving your 1 Hz heart rate signal (data). - Analogy: Noise-canceling headphones don’t remove music—they remove background noise so you hear music better - Better approach: Apply appropriate filters to improve signal-to-noise ratio (SNR)
Real-World Example: - Inefficient design: Soil moisture sensor sampled at 1 kHz, 16-bit ADC, no filtering - Soil moisture changes over hours (0.0003 Hz) - Power consumption: 5 mA continuous - Battery life: 20 hours
- Optimized design: Same sensor sampled at 0.01 Hz (once per 100 seconds), 10-bit ADC, median filter
- Captures all relevant changes (30× Nyquist margin)
- Power consumption: 50 μA average (100× reduction!)
- Battery life: 2000 hours (83 days)
- Data quality: Identical for the application
Key Lesson: “Good enough” signal processing saves 100× power without sacrificing data quality. Over-specification wastes resources on precision you can’t use.
Rule of Thumb: 1. Identify maximum signal frequency (fmax) 2. Sample at 5-10× fmax (not 100× or 1000×) 3. Match ADC resolution to sensor accuracy ±20% margin 4. Filter intelligently to remove noise, not signal
Your Challenge: You’re designing a predictive maintenance system for industrial machinery. Your accelerometer detects vibrations indicating bearing wear.
Scenario Details: - Bearing frequency: Healthy bearings vibrate at 200 Hz (shaft rotation rate) - Wear signature: Damaged bearings show harmonics up to 500 Hz (2.5× fundamental) - Your accelerometer: ADXL345 digital accelerometer - Available sample rates: 25 Hz, 50 Hz, 100 Hz, 200 Hz, 400 Hz, 800 Hz, 1600 Hz, 3200 Hz - Power consumption scales with sample rate: 40 μA @ 100 Hz, 140 μA @ 3200 Hz - Power budget: Battery-powered sensor node, need 1-year battery life
Your Task: What sample rate should you choose? Show your reasoning.
Solution: Step-by-Step Analysis
Step 1: Identify Maximum Signal Frequency - Bearing fundamental: 200 Hz - Wear harmonics: up to 500 Hz - Maximum frequency to detect: 500 Hz (fmax)
Step 2: Apply Nyquist Theorem - Nyquist minimum: Sample rate > 2 × fmax = 2 × 500 Hz = 1000 Hz - Practical target: 5-10× margin → 1250-1500 Hz minimum
Step 3: Evaluate Available Options
| Sample Rate | Nyquist Margin | Power (μA) | Meets Requirements? |
|---|---|---|---|
| 400 Hz | 0.8× (too slow!) | ~60 | ❌ Aliasing risk |
| 800 Hz | 1.6× (barely) | ~85 | ⚠️ Marginal |
| 1600 Hz | 3.2× (good) | ~115 | ✅ Adequate |
| 3200 Hz | 6.4× (excellent) | ~140 | ✅ Overkill? |
Step 4: Power Budget Analysis - Battery capacity: 1000 mAh (typical AA battery) - Target lifetime: 1 year = 8760 hours - Allowed current: 1000 mAh / 8760 h = 114 μA average
Power consumption breakdown: - Accelerometer @ 1600 Hz: 115 μA - Microcontroller sleep mode: 20 μA - Wireless transmission (1% duty): 5 μA average - Total: ~140 μA (exceeds budget by 26 μA!)
Step 5: Optimization Strategy
Option A: Accept shorter battery life - Use 1600 Hz sampling - Battery life: 1000 mAh / 0.14 mA = 7142 hours ≈ 10 months - ⚠️ Misses 1-year target
Option B: Duty-cycle the accelerometer - Sample at 1600 Hz for 1 second every 10 seconds (10% duty cycle) - Accelerometer power: 115 μA × 10% = 11.5 μA average - Total: 11.5 + 20 + 5 = 36.5 μA - Battery life: 1000 mAh / 0.0365 mA = 27,400 hours ≈ 3.1 years ✅
Option C: Use edge processing - Sample at 1600 Hz - Compute FFT locally (frequency spectrum) - Transmit only anomaly alerts (not raw data) - Saves 80% wireless transmission power - Total: 115 + 20 + 1 = 136 μA - Battery life: 7350 hours ≈ 10.2 months ⚠️ Close
Best Choice: Option B - 1600 Hz with 10% duty cycle
Why This Works: - Nyquist-compliant: 1600 Hz > 1000 Hz requirement (3.2× margin) - Catches transient events: 1-second bursts at 1600 Hz = 1600 samples per measurement window - Power-efficient: 10% duty cycle saves 90% accelerometer power - Exceeds 1-year target: 3+ years battery life - Practical: Bearings don’t wear instantly—sampling every 10 seconds catches degradation trends
Key Lessons: 1. Nyquist is non-negotiable: 400 Hz would alias 500 Hz signals to 100 Hz (false readings!) 2. Oversampling has costs: 3200 Hz provides no benefit over 1600 Hz for this application 3. Duty cycling saves power: 10% duty cycle = 10× battery life extension 4. Match sampling to physics: Bearing wear develops over days/weeks, not milliseconds
Real-World Validation: Industrial IoT vendors (e.g., Samsara, Augury) use similar strategies—burst sampling at high rates with long sleep periods between measurements.
66.5 Summary
This chapter introduced the fundamentals of analog-to-digital signal conversion:
Key Concepts: 1. Analog vs Digital: Sensors produce continuous signals; computers need discrete values 2. ADC Pipeline: Anti-aliasing filter → Sample & Hold → ADC → Digital value 3. Nyquist Theorem: Sample at >2× the maximum signal frequency 4. Practical Sampling: Use 5-10× Nyquist for safety margin 5. Resource Optimization: Match sampling rate and ADC resolution to actual signal characteristics
Common Pitfalls to Avoid: - Over-sampling wastes power, storage, and bandwidth - Under-sampling causes aliasing distortion - Excessive ADC resolution doesn’t improve accuracy beyond sensor precision - Filtering removes noise, not signal—apply intelligently
What’s Next: - Aliasing and ADC Resolution - Deep dive into aliasing prevention and quantization - Digital Filtering - Implementing filters in software - Signal Processing Labs - Hands-on ADC configuration with ESP32