16 IoT Mathematics: Fusion and Sampling Decisions
More
Depth: Practitioner
Progress saves as you read. Mark sections complete as you go; your progress appears in the sidebar.
16.1 Start With the Decision
This section: Start With the Decision — GPS drifts slowly while an accelerometer reacts fast.
GPS drifts slowly while an accelerometer reacts fast. A filter must blend both and still respect the sample limit.
16.2 Route Overview
This section: Route Overview — This is part 2 of 2.
This is part 2 of 2. Review IoT Mathematics: Linear Algebra and Probability for the preceding evidence.
16.3 Learning Objectives
This section: Learning Objectives
- Work through a Kalman filter for GPS and motion data.
- Choose a sample rate with the Nyquist rule.
16.4 Chapter Roadmap
This section: Chapter Roadmap
- Worked Example: Designing a Kalman Filter for GPS-Accelerometer Fusion
- Decision Framework: Choosing Sampling Rates Using Nyquist Theorem
- Common Mistake: Misapplying dB Calculations to Voltage vs. Power
- Knowledge Check
- Auto-Gradable Quick Check
- Try It Yourself
- Hands-On Exercise: Calculate Battery Life with Real Power Measurements
- Concept Relationships
- How Math Concepts Connect in IoT Systems
- See Also
- Related Resources
- Interactive Quiz: Match Mathematical Foundations Concepts
- Interactive Quiz: Sequence the Steps
- What’s Next
- Navigation
You’re building a fleet tracking system using GPS (+/-10m accuracy) and an accelerometer-based dead reckoning system. Here’s how to apply the mathematical foundations to implement sensor fusion.
Step 1: Model the System State
From Section C.2 (Matrices), define state vector as position and velocity:
Where:
- = position (meters)
- = velocity (meters/second)
Step 2: State Transition (Prediction)
From Section A.1 (Derivatives) and A.2 (Integrals), position changes via velocity integration:
In matrix form (Section C.3):
Example: Current state is position (100m, 200m), velocity (15 m/s, 0 m/s),
Predicted position: (101.5m, 200m) after 0.1 seconds.
Step 3: Measurement Update (GPS Reading)
GPS reports position (103m, 201m) with sigma = 10m uncertainty.
From Section D.2 (Gaussian Distribution), GPS measurement has:
- Mean: mu = (103, 201)
- Covariance: (since sigma = 10m)
From Section D.3 (Sensor Fusion), combine prediction with measurement:
Assume prediction uncertainty (accelerometer integration), GPS uncertainty :
X-coordinate:
Y-coordinate:
Fused estimate: (101.8m, 200.2m)
Notice the fused position is closer to the prediction (101.5, 200) than the GPS (103, 201) because prediction is 2x more accurate ( vs ).
Step 4: Uncertainty Reduction
From Section D.3, combined variance:
Interpretation: Fusing 5m-accurate prediction with 10m-accurate GPS yields 4.47m accuracy - better than either sensor alone!
Step 5: Real-World Performance Calculation
For a delivery truck moving at 60 km/h (16.67 m/s):
- GPS update rate: 1 Hz (once per second)
- Dead reckoning uncertainty growth: 2% per second (from accelerometer bias)
Between GPS updates (1 second):
- Distance traveled: 16.67 meters
- Dead reckoning error: 16.67 x 0.02 = 0.33m (grows linearly)
- Fused uncertainty after 1 sec:
After GPS update:
- Pre-update: sigma = 4.48m
- Post-fusion: sigma ≈ 4.09m (the new GPS update reduces uncertainty below its pre-update value)
Key Insight: Kalman filter prevents dead reckoning drift by periodically re-anchoring position with GPS, while smoothing GPS noise with prediction.
Implementation Pseudocode:
# Initialize state
state = [position_x, position_y, velocity_x, velocity_y]
P = [[25, 0, 0, 0], # Position covariance matrix (5m uncertainty)
[0, 25, 0, 0],
[0, 0, 4, 0], # Velocity covariance (2 m/s uncertainty)
[0, 0, 0, 4]]
# Prediction step (every 0.1 seconds)
state_predicted = F @ state # Matrix multiplication from Section C.3
P_predicted = F @ P @ F.T + Q # Add process noise Q
# Measurement step (GPS reading every 1 second)
innovation = gps_reading - H @ state_predicted # H extracts position
S = H @ P_predicted @ H.T + R # Innovation covariance (R = GPS noise)
K = P_predicted @ H.T @ inv(S) # Kalman gain (optimal weighting)
state = state_predicted + K @ innovation # Update state
P = (I - K @ H) @ P_predicted # Update covariance
Math concepts used: Vectors (C.1), matrices (C.2), matrix multiplication (C.3), Gaussian distribution (D.2), sensor fusion (D.3), integrals (A.2).
Use this framework to determine the minimum ADC sampling rate for your sensor based on signal frequency content.
16.4.1 The Nyquist Rule (Section A.1 + Quick Reference)
Here, is the sampling rate and is the highest frequency component in the signal being considered. Choosing a sampling rate therefore starts with identifying the signal’s frequency content, rather than selecting an ADC rate first. The supplied decision framework uses physical time constants, mechanical resonance, expected motion, and relevant harmonics to estimate that content.
The rule gives a minimum sampling rate; practical selection also needs margin for anti-alias filter roll-off. Frequencies above the intended signal range should be attenuated before sampling. Sampling too slowly can make a higher-frequency component appear at a lower frequency. Increasing the rate adds margin but also increases data volume and ADC activity, so the chosen rate should reflect the required signal range.
16.4.2 Step-by-Step Decision Process
| Signal Type | Frequency Estimation Method | Example Calculation | Recommended Sampling Rate |
|---|---|---|---|
| Temperature (slow) | Physical time constant | Thermocouple: tau = 1s -> Hz | 0.5 Hz (1 sample/2 sec) |
| Vibration | Mechanical resonance | Example signal: = 120 Hz | 250 Hz (Nyquist) + anti-alias filter |
| Audio | Human hearing range | Speech: 20 Hz - 8 kHz | 16 kHz (telephone quality) |
| Accelerometer | Expected motion | Hand gesture: 0-10 Hz | 25 Hz (2.5x highest signal frequency for margin) |
| Voltage ripple | Power supply frequency | AC mains: 60 Hz + harmonics -> 300 Hz | 1 kHz (capture up to 5th harmonic) |
16.4.3 Worked Example: Vibration Monitoring on Industrial Motor
Background: 1800 RPM motor (30 Hz rotation), 4-blade fan
Step 1: Identify Frequency Components
From Section B.1 (Exponential Functions) and mechanical theory:
- Fundamental: Motor rotation = 30 Hz
- Blade pass frequency: 4 blades x 30 Hz = 120 Hz
- Harmonics: In this example, include up to the third harmonic of the 120 Hz blade-pass component = 120 x 3 = 360 Hz; shaft imbalance is primarily at the 30 Hz rotation rate.
Step 2: Apply Nyquist Theorem
Step 3: Add Safety Margin
For this example, use 2.5x the 720 Hz Nyquist minimum to allow filter roll-off.
Step 4: Select Standard ADC Rate
Common options: 1 kHz, 2 kHz, 5 kHz, 10 kHz
Decision: 2 kHz (exceeds requirement, standard IC availability)
16.4.4 Anti-Aliasing Filter Design
From Section A.2 (RC Time Constant):
Goal: Attenuate frequencies above 360 Hz before sampling at 2 kHz
Filter cutoff frequency: Hz (between signal and Nyquist/2)
Choose: , then -> Use standard 39 nF capacitor
16.4.5 Real-World Tradeoffs
| Sampling Rate | Data Rate (16-bit samples) | Pros | Cons |
|---|---|---|---|
| 720 Hz (minimum Nyquist) | 11,520 bits/sec | Low power, minimal storage | No margin, aliasing risk |
| 2 kHz (recommended) | 32,000 bits/sec | Safe margin, standard ADCs | 2.8x data volume |
| 10 kHz (over-sampled) | 160,000 bits/sec | Digital filtering, noise averaging | 14x data volume, unnecessary |
Energy Impact (from Section A.2, Energy Budget):
ADC power: 5 mW active, conversion time: 10 us
720 Hz: Duty cycle = 720 x 10 us = 0.72%, average power = 5 mW x 0.0072 = 36 uW 2 kHz: Duty cycle = 2000 x 10 us = 2%, average power = 100 uW 10 kHz: Duty cycle = 10%, average power = 500 uW
Battery life impact (2000 mAh at 3.3V):
2 kHz: 100 uW -> 30 uA -> 2000/0.03 = 66,667 hours = 7.6 years 10 kHz: 500 uW -> 150 uA -> 13,333 hours = 1.5 years
Decision: In this ADC-only model, 2 kHz sampling provides a 2.8x margin over the Nyquist minimum while preserving 7+ years of battery life. In this ADC-only model, 10 kHz over-sampling reduces the projected battery life by about 80% with no required signal-quality benefit for the stated 360 Hz signal.
16.4.6 Common Mistake: Under-Sampling
Example: Student samples 60 Hz mains voltage at 100 Hz
Nyquist requires Hz, so 100 Hz causes aliasing.
What happens: 60 Hz signal appears as 40 Hz after aliasing ( Hz)
Fix: Sample at >=150 Hz (2.5x the 60 Hz signal frequency) -> use 250 Hz for standard ADC compatibility
This section:
The Problem: Students often use the power formula when comparing voltages, leading to 6 dB errors.
Real Example from Student Report:
“Our amplifier increased signal voltage from 0.1V to 1.0V, a gain of 10 dB.”
What’s wrong?
From Section B.2 (Logarithms), dB formulas differ for power vs. voltage:
| Quantity | Formula | Correct Calculation |
|---|---|---|
| Power ratio | 10x power = 10 dB | |
| Voltage ratio | 10x voltage = 20 dB |
Why the factor of 20 for voltage?
From basic electronics (Section A.2, Power formula):
If voltage doubles, power quadruples (voltage squared relationship).
Corrected Calculation:
Voltage gain from 0.1V -> 1.0V:
The student’s 10 dB answer is off by 10 dB (a 10× power-ratio difference, or about 3.16× in voltage ratio).
16.4.7 Decision Matrix: Power vs. Voltage dB
| Measurement Type | Use This Formula | Example |
|---|---|---|
| Transmit power (mW) | 100 mW -> 20 dBm | |
| Antenna gain (power ratio) | 2x power -> 3 dB | |
| Signal voltage (ADC reading) | 1.0 V -> 0 dBV | |
| Path loss (power reduction) | 0.01x power -> -20 dB | |
| Amplifier gain (voltage) | 10x voltage -> 20 dB | |
| SNR (power ratio) | 100:1 -> 20 dB SNR |
16.4.8 Quick Lookup Table (Section B.2)
| Linear Ratio | Power dB (10 log) | Voltage dB (20 log) |
|---|---|---|
| 0.5x (half) | -3 dB | -6 dB |
| 2x (double) | +3 dB | +6 dB |
| 10x | +10 dB | +20 dB |
| 100x | +20 dB | +40 dB |
| 1000x | +30 dB | +60 dB |
Memory trick: Voltage uses 20 log because power depends on voltage SQUARED (the 2 becomes a multiplier in the log).
16.4.9 Practical IoT Example: Link Budget Calculation
Given: LoRa transmitter outputs 14 dBm (25 mW), path loss is 120 dB, receiver sensitivity is -137 dBm.
Correct calculation:
Receiver needs -137 dBm minimum, received signal is -106 dBm:
In this simplified link budget, the link has 31 dB margin (1,259x power above minimum); verify fading and interference before claiming reliable field operation.
Common mistake: Student adds voltage gain (in dBV) to power budget (in dBm) - units must match!
16.4.10 Rule Summary
Step 1 — Power quantities (W, mW, dBm): Use Step 2 — Voltage quantities (V, dBV): Use Step 3 — Always label units (dBm, dBV, dB relative to reference) Step 4 — Never mix voltage dB with power dB in same calculation
When in doubt: Check if your measurement is voltage (from ADC, oscilloscope) -> 20 log. If it’s power (from spectrum analyzer, RF meter) -> 10 log.
16.5 Knowledge Check
This section: Knowledge Check
16.6 Try It Yourself
This section: Try It Yourself
Objective: Apply integrals (energy budgeting) and exponentials (battery discharge curves) to estimate how long an ESP32 sensor will run on two AA batteries.
Given Data:
- Battery capacity: two AA alkaline = 2,000 mAh at 3V (6,000 mWh total energy)
- ESP32 power states:
- Active (Wi-Fi transmit): 160 mA for 2 seconds
- Light sleep: 0.8 mA for 58 seconds
- Measurement interval: Every 60 seconds
Step 1: Calculate Average Current (from Section A.2, Integrals)
Using the duty cycle formula from Quick Reference:
Where D = duty cycle (fraction of time):
- (3.3% of time)
- (96.7% of time)
Step 2: Calculate Battery Life
Step 3: Account for Battery Discharge Curve (Section B.1, Exponentials)
Alkaline terminal voltage changes during discharge; its usable capacity depends on load, temperature, and the device cutoff voltage. Assume usable capacity is ~80% at a 1.1V cutoff:
Challenge Extension:
- What if you reduce transmit time to 1 second (faster Wi-Fi)? Recalculate .
- What if you switch to lithium AA (2,500 mAh, flatter discharge curve = 90% usable)? New battery life?
- Use Section B.1 RC time constant: If ESP32 has 100uF decoupling cap, how long to charge from sleep voltage?
Answer: With 1s transmit, drops to 3.44 mA -> 19.3 days (alkaline) or 27 days (lithium).
Why This Matters: Battery life estimation is the #1 requirement for field-deployed IoT. This exercise applies integrals (averaging), exponentials (discharge curves), and real-world engineering judgment (efficiency factors).
16.7 Concept Relationships
This section: Concept Relationships
Calculus -> Signal Processing:
Derivatives detect rapid changes (anomaly detection: sudden temperature spike) Integrals smooth noisy data (moving average filter = discrete integral) Fourier Transform (Section F.2) decomposes signals into frequency components for filtering
Exponentials + Logarithms -> Wireless Communication:
Exponential decay models signal attenuation: Logarithms (dB scale) compress 100,000:1 power ranges into manageable numbers Shannon Capacity links SNR (exponential in linear scale) to data rate via logarithm
Linear Algebra -> Sensor Fusion:
Vectors represent multi-axis sensor data (accelerometer: ) Matrices transform coordinate frames (rotate sensor orientation) Kalman Filter (Section C.2) uses matrix multiplication to fuse GPS + IMU
Probability -> Reliability & Quality:
Gaussian distribution models sensor noise (Section D.2) Expected value predicts component failure rates Sensor fusion weights measurements by inverse variance (trust precise sensors more)
Modular Arithmetic -> Security:
Diffie-Hellman key exchange (Section E.3) uses “easy forward, hard reverse” property Public-key cryptography relies on discrete logarithm difficulty Hash functions (checksums, message authentication) use modular arithmetic
The Integration: A GPS-IMU tracker uses ALL these: calculus (integrate acceleration -> velocity -> position), logarithms (dB for signal strength), linear algebra (Kalman filter matrices), probability (sensor noise models), and modular arithmetic (encrypted data transmission).
16.8 See Also
This section: See Also
Within This Module:
Glossary A-F - Definitions for technical terms (dB, Shannon Capacity, Kalman Filter) Reference Appendix - Visual conventions and quick-reference material for mathematical diagrams
Applied Mathematics (Cross-Module):
Signal Processing Essentials - Fourier transforms, filtering, Nyquist theorem in practice Kalman Filtering for Sensor Fusion - Step-by-step implementation of matrix-based sensor fusion Cryptography Fundamentals - Modular arithmetic in RSA, Diffie-Hellman, elliptic curves Energy-Aware Design - Battery life calculations using integrals and exponentials
Interactive Tools:
Power Budget Calculator - Interactive tool applying the integral-based battery life formulas from this chapter dB Conversion Tool - Practice logarithmic conversions between mW and dBm Kalman Filter Visualizer - See matrix operations in real-time sensor fusion
Reference Materials:
Quick Reference Card (Section H) - Copy-paste formulas for IoT calculations Worked Example: Kalman Filter (Section D.3) - Full GPS-accelerometer fusion walkthrough Decision Framework: Sampling Rates (Section A.1) - Nyquist theorem application guide
16.9 What’s Next
This section: What’s Next
| If you want to… | Read this |
|---|---|
| Apply calculus concepts to PID control system design | Process Control and PID |
| Use probability theory in sensor fusion and Kalman filtering | Sensor Fusion Fundamentals |
| Apply logarithms (dB) to wireless signal budget calculations | Wireless Sensor Network Fundamentals |
| Apply statistical analysis to time-series IoT data | Time-Series Queries |
| Access reference materials and supplementary content | Appendix |
16.11 Continue Your Route
This section: Continue Your Route — This is the last part of this chapter.
This is the last part of this chapter. Return to IoT Mathematics: Linear Algebra and Probability or continue from the capstone module index.
Find help
3 reviewed answers.
Where should I start in a module?
Open the module page from the sidebar to see its chapters in order. Use the module map to return to a topic you need.
Modules and pathsReviewed
What can I try when a project does not work?
Check the symptom, then work through the diagnostic steps. Keep the error message and the smallest example that reproduces it.
When you are stuckReviewed
How do interactive examples work?
Use the interactive guide to check how examples and simulations work before changing your project.
Interactive examples guideReviewed
