22  Sensor Selection Process

22.1 Learning Objectives

By the end of this chapter, you will be able to:

  • Define application requirements: Translate project needs into measurable sensor specifications
  • Compare components systematically: Create comparison tables for objective evaluation
  • Calculate power consumption: Compute average current with duty cycling for battery life estimation

Key Concepts

  • Weighted Scoring Matrix: A decision tool that assigns weights to selection criteria (accuracy, power, cost, interface) and scores each candidate against each criterion; produces an objective composite score
  • Application Requirements: The performance, physical, environmental, and interface constraints that a sensor must satisfy; derived from system-level specifications, not component capabilities
  • Shortlisting: The process of eliminating candidates that fail mandatory requirements before detailed scoring; saves time by focusing evaluation on feasible options
  • Data Rate vs Accuracy Trade-off: Many sensors offer programmable data rate and resolution settings; lower data rate typically provides better averaging and lower noise but higher latency
  • I2C Address Conflicts: I2C sensors have fixed or limited-range addresses; when multiple sensors of the same type are needed, verify address programmability or consider SPI alternatives
  • Breakout Board Evaluation: Using a commercial breakout board with the target sensor to validate real-world performance before designing it into a custom PCB
  • Total Cost of Ownership (TCO): Including not just component unit cost but also qualification time, integration complexity, and support lifetime when comparing sensor candidates
In 60 Seconds

Systematic IoT sensor selection uses a weighted scoring matrix to compare candidate components across five dimensions — accuracy, power consumption, interface compatibility, environmental range, and cost — turning a subjective “best sensor” judgment into a defensible, data-driven engineering decision.

  • Perform weighted ranking: Score and rank components based on prioritized criteria
  • Understand specification trade-offs: Balance range vs sensitivity, accuracy vs power, analog vs digital

Design methodology gives you a structured, proven process for creating IoT systems from initial concept to finished product. Think of it like following a recipe when cooking a complex meal – the methodology tells you what to do first, how to handle each step, and how to bring everything together into a successful final result.

“Choosing a sensor is like choosing a pair of shoes,” said Sammy the Sensor. “You need to know: What is it for? What size fits? What is the budget? Running shoes for a marathon are very different from rain boots for puddle jumping!”

Max the Microcontroller explained the process: “First, list your requirements – what do you need to measure, how accurate, how fast, and what temperature range? Then, find three to five candidates and make a comparison table. Score each one on accuracy, power consumption, cost, ease of use, and availability. The highest score wins!”

“But watch out for trade-offs,” warned Lila the LED. “A super-accurate sensor usually costs more and uses more power. A cheap sensor saves money but might not be accurate enough. There is no perfect sensor – just the best one for YOUR specific project.” Bella the Battery added a critical check: “Always verify current consumption! A sensor that uses 10 milliamps might sound fine, but multiply that by 24 hours, 365 days, and suddenly you need a much bigger battery than planned.”

22.2 Prerequisites

Before diving into this chapter, you should be familiar with:

22.3 Common Misconception: “Typical” Specifications

“Typical” Specifications are NOT Guaranteed Performance

The Misconception: Many developers assume “Typical” values in datasheets represent guaranteed performance across all devices. This leads to designs that work with some units but fail with others.

The Reality (Quantified): Datasheets use three specifications with very different meanings:

Specification Type What It Means Example (Temperature Sensor) Guarantee Level
Typical (Typ) Median or average value from production testing Accuracy: +/-0.5C (typ) 0% guarantee - Marketing value only
Minimum/Maximum Worst-case limits at specified conditions Accuracy: +/-2.0C (max) 100% guarantee - Every unit meets this
Conditions Test environment At 25C, 3.3V supply Only valid under these conditions

Real-World Impact:

Example 1: Temperature Sensor Selection

  • Datasheet shows: “Accuracy: +/-0.5C (typ), +/-2.0C (max)”
  • Developer designs for +/-0.5C requirement
  • Result: 50% of production units exceed +/-0.5C error
  • Cost: $25,000 product recall for 5,000 units

Example 2: Current Consumption Miscalculation

  • Sensor spec: “Sleep current: 2 uA (typ), 10 uA (max)”
  • Battery life calculation uses 2 uA
  • Result: Battery life is 5x shorter than predicted (10 uA / 2 uA)
  • Expected 5 years -> Actual 1 year
  • Cost: Customer dissatisfaction, warranty claims

Example 3: ADC Resolution Reality

  • ADC spec: “INL: +/-1 LSB (typ), +/-4 LSB (max)”
  • Developer assumes 1 LSB effective resolution
  • Result: 20% of units have 4x worse linearity error
  • 12-bit ADC (4096 codes) effectively becomes 10-bit (1024 codes) in worst case

The Fix:

  1. Always design for “Max” specifications, not “Typ”
  2. Add margin: Use 80% of “Max” limit for safety
  3. Request distribution data: Ask manufacturer for +/-1 sigma, +/-2 sigma, +/-3 sigma specifications
  4. Test early: Validate with multiple production units, not just samples

Quantified Best Practice:

  • Safety margin = 20% beyond worst-case spec
  • Example: Max current = 10 uA -> Design for 12 uA (10 x 1.2)
  • This accounts for temperature derating, aging, and manufacturing spread

Remember: “Typical” is marketing. “Maximum” is engineering. Design for maximum.

22.4 Sensor Selection Process

Selecting the right sensor requires a systematic approach that balances multiple competing factors—accuracy, power consumption, cost, and compatibility. The following five-step process provides a repeatable framework for making objective component decisions.

22.4.1 Step 1: Define Requirements

Before comparing sensors, you must establish clear, measurable requirements. Vague goals like “low power” or “good accuracy” lead to endless debates and poor decisions. Instead, specify exact thresholds: “sleep current < 5 µA” or “accuracy ±1% full scale.”

Sequential workflow diagram with eight steps for component selection requirements definition: measurement type identification at top, flowing down through range specification, accuracy tolerance definition, power budget establishment, environmental conditions consideration, interface protocol selection, unit cost constraint setting, and concluding with candidate component filtering based on all requirements for datasheet comparison

Requirements definition workflow showing sequential steps from measurement type through filtering candidate components
Figure 22.1: Component selection requirements definition workflow with eight sequential criteria: identifying measurement type, specifying required range limits, defining acceptable accuracy tolerance, establishing power consumption budget for target battery life, considering environmental operating conditions, selecting compatible communication interface protocol, setting maximum unit cost constraint, and finally filtering candidate components matching all requirements for datasheet comparison.

Requirements Checklist:

Requirement Category Questions to Answer
Measurement What physical quantity? What range? What accuracy?
Power Battery or mains? Target battery life? Duty cycle possible?
Interface What microcontroller interfaces available? I2C, SPI, Analog?
Environment Temperature range? Humidity? Vibration?
Physical Size constraints? Weight limits? Mounting method?
Cost Target unit cost? Volume pricing considerations?

22.4.2 Step 2: Compare Specifications

Once requirements are defined, identify 3-5 candidate sensors that meet your baseline criteria. Too few candidates limits your options; too many creates analysis paralysis. Extract key specifications from datasheets and organize them in a structured comparison table.

Key Comparison Criteria:

Criteria Category What to Compare Why It Matters
Range Measurement min/max Must cover expected values
Accuracy +/-% error Determines measurement quality
Power Active/sleep current Battery life impact
Interface Analog, I2C, SPI, UART microcontroller compatibility
Temperature Operating range Environmental suitability
Package Size, pin count PCB footprint
Cost Unit price Total system cost

Example: Comparing Three Accelerometers

Specification ADXL335 MMA8452Q LIS3DH
Manufacturer Analog Devices NXP STMicroelectronics
Range +/-3g +/-2g +/-2g
Interface Analog I2C (digital) I2C (digital)
Accuracy +/-2.0% +/-1.5% +/-1.0%
Active Current 350 uA 165 uA 11 uA
Sleep Current 0.1 uA 2 uA 0.5 uA
Resolution Depends on ADC 12-bit 12-bit
Noise Density 150 ug/sqrt(Hz) 99 ug/sqrt(Hz) 100 ug/sqrt(Hz)
Max Sample Rate 1600 Hz 800 Hz 5376 Hz
Package LGA (3x3x1 mm) QFN (3x3x1 mm) LGA (3x3x1 mm)
Price $3.50 $2.20 $1.80

Best in category marked with star: LIS3DH wins on accuracy, active current, sample rate, and price.

22.4.3 Step 3: Calculate Power Consumption

Raw specifications don’t tell the whole story. A sensor with 100 µA active current sounds power-hungry, but if it only operates 0.1% of the time, it may outperform a 10 µA sensor that never sleeps. You must calculate average current based on your application’s duty cycle.

Power Consumption Calculation Example:

For a sensor sampling once per second with 1% duty cycle (10ms active, 990ms sleep):

Average Current = (Active Current x Duty Cycle) + (Sleep Current x (1 - Duty Cycle))

LIS3DH Example:
  Active: 11 uA x 0.01 = 0.11 uA
  Sleep:  0.5 uA x 0.99 = 0.495 uA
  Total: 0.605 uA average

Battery Life (CR2032 = 220 mAh):
  Lifetime = 220,000 uAh / 0.605 uA = 363,636 hours = 41 years
  (Note: Practical life limited by self-discharge ~10 years)

Why does a 1% duty cycle NOT result in 1% of active current? The math reveals a critical insight:

\[I_{\text{avg}} = I_{\text{active}} \times D + I_{\text{sleep}} \times (1-D)\]

For LIS3DH: \(I_{\text{avg}} = 11\,\mu\text{A} \times 0.01 + 0.5\,\mu\text{A} \times 0.99 = 0.11 + 0.495 = 0.605\,\mu\text{A}\)

Notice that sleep current dominates (82% of total)! This is why ultra-low sleep current matters: improving from 0.5µA to 0.1µA saves \(0.396\,\mu\text{A}\) average—extending battery life from 41 years to 68 years.

Key Insight: Even at % duty cycle, sleep current accounts for % of total power consumption. This demonstrates why optimizing sleep current is critical for battery-powered IoT devices.

22.4.4 Step 4: Score and Rank

With power calculations complete, you need a method to combine multiple criteria—accuracy, power, cost, availability—into a single decision. Weighted scoring provides an objective framework: assign importance weights to each criterion, score each sensor on a consistent scale, and calculate weighted totals.

Sensor Ranking Decision Tree:

Decision tree diagram for accelerometer selection showing three sensor options: ADXL335 with analog interface suitable for simple ADC applications, MMA8452Q offering balanced accuracy and power for standard I2C designs, and LIS3DH as the recommended winner with superior 1 percent accuracy specification, ultra-low 11 microamp power consumption that is 15 times better than competitors, and lowest unit cost at 1.80 dollars, making it the optimal choice for battery-powered IoT applications

Decision tree comparing three accelerometer sensors with evaluation criteria and final recommendation
Figure 22.2: Accelerometer selection decision tree comparing three sensors: ADXL335 analog interface for simple ADC applications, MMA8452Q with good accuracy-power balance for standard I2C designs, and LIS3DH winner for battery-powered IoT with superior 1 percent accuracy, 11 microamp ultra-low power consumption 15 times better than alternatives, and lowest cost at 1.80 dollars making it optimal choice.

Weighted Scoring Example:

Criteria Weight ADXL335 MMA8452Q LIS3DH
Accuracy 30% 6 8 10
Power 30% 5 7 10
Cost 25% 5 8 10
Interface 15% 7 9 9
Weighted Total 100% 5.6 7.8 9.85

Winner: LIS3DH - Best overall score across prioritized criteria.

Try adjusting the weights to see how different priorities change the optimal sensor choice. For example, if power consumption becomes more critical (40-50% weight), does the ranking change?

22.5 Accelerometer Measurement Calculations

Understanding how sensors convert physical measurements to electrical signals is critical for interface design and ADC configuration. This section demonstrates the key calculations for analog accelerometers, showing how sensitivity, supply voltage, and ADC resolution determine measurement precision.

For an analog accelerometer with these specs:

  • Sensitivity: 800 mV/g
  • Supply: 3.0V
  • ADC: 10-bit (0-1023)

Key Formulas:

Calculation Formula Example (+/-2g sensor)
Zero-g Output Vdd / 2 3.0V / 2 = 1.5V
Output at +1g (Vdd/2) + (Sensitivity x g) 1.5V + (0.8V x 1) = 2.3V
Output at -1g (Vdd/2) - (Sensitivity x g) 1.5V - (0.8V x 1) = 0.7V
ADC Value (Vout / Vdd) x 1023 (2.3V / 3.0V) x 1023 = 784
Resolution (Vdd / 1023) / Sensitivity (3.0V / 1023) / 0.8 = 3.66 mg/LSB

Example Measurement Table:

Acceleration Output Voltage ADC Value (10-bit) Notes
0g (rest) 1.5V 512 Center/zero point
+0.5g 1.9V 648 Gentle tilt
+1.0g (vertical) 2.3V 784 Standing upright
+2.0g (max) 3.1V 1023 (clipped!) Maximum range
-1.0g 0.7V 239 Upside down
-2.0g (min) -0.1V 0 (clipped!) Minimum range

Hands-on Lab: Spec Sheet Analysis

22.5.1 Objective

Practice reading and interpreting sensor datasheets to select appropriate components for a wearable fitness tracker.

22.5.2 Scenario

You are designing a wearable fitness tracker with the following features:

  1. Activity Recognition: Detect walking, running, cycling
  2. Step Counting: Count steps accurately
  3. Heart Rate Monitoring: Measure heart rate
  4. Battery Life: Must last 7+ days on single charge

22.5.3 Requirements

System Requirements:

Aspect Requirement
Sensors Needed Accelerometer, gyroscope, heart rate (PPG)
Accelerometer Range +/-8g (for running impacts)
Gyroscope Range +/-2000 dps (degrees per second)
Heart Rate 40-220 BPM
Sample Rate 100 Hz (accelerometer), 25 Hz (HR)
Power Budget < 2 mA average (3.7V, 150mAh battery)
Size Must fit in 20mm x 15mm x 3mm package
Temperature 0C to 50C (wearable)
Cost Target < $5 total for sensors

22.5.4 Task

Follow this systematic approach to select sensors:

Step 1: Create Comparison Table

Research 3-4 accelerometer datasheets and extract these specifications:

Spec Sensor A Sensor B Sensor C Your Requirement
Range +/-__g +/-__g +/-__g +/-8g
Accuracy +/-__% +/-__% +/-__% < +/-2%
Active Current __ uA __ uA __ uA Low as possible
Sleep Current __ uA __ uA __ uA < 5 uA
Interface __ __ __ I2C preferred
Sample Rate __ Hz __ Hz __ Hz >= 100 Hz
Package Size __ mm __ mm __ mm < 20x15 mm
Price $__ $__ $__ < $5

Step 2: Calculate Power Consumption

For each sensor, calculate average current with 1% duty cycle (100 Hz sampling = 10ms active per second). Refer to Step 3: Calculate Power Consumption for the detailed formula and interactive calculator.

Average Current = (I_active x 0.01) + (I_sleep x 0.99)

Example:
  Sensor: 150 uA active, 2 uA sleep
  Avg = (150 x 0.01) + (2 x 0.99) = 1.5 + 1.98 = 3.48 uA

Step 3: Estimate Battery Life

With 150 mAh battery at 3.7V:

Battery Life (hours) = Battery Capacity / Average Current
                     = 150,000 uAh / 3.48 uA
                     = 43,103 hours = 1,796 days = 4.9 years

Step 4: Score and Rank

Assign weights and score each sensor (0-10 scale):

Criteria Weight Sensor A Score Sensor B Score Sensor C Score
Accuracy 30% __ __ __
Power 30% __ __ __
Cost 40% __ __ __
Total 100% **__** **__** **__**

22.5.5 Expected Deliverable

A one-page report that includes:

  1. Comparison Table: All candidate sensors with key specs
  2. Power Analysis: Average current and battery life calculations for each
  3. Ranking: Weighted scores showing trade-offs
  4. Recommendation: Final sensor choice with justification (2-3 sentences)

Example Justification: > “Selected the LIS3DH accelerometer due to ultra-low 11 uA active current (15x lower than competitors), providing 4+ year battery life on a single charge. Despite being the cheapest option at $1.80, it offers the best +/-1.0% accuracy. The I2C interface simplifies microcontroller integration and the 5376 Hz max sample rate exceeds our 100 Hz requirement with plenty of headroom.”

22.6 Spec Sheet Analysis Framework

A spec sheet analysis framework for IoT helps systematically compare and select sensors based on electrical characteristics, performance specifications, mechanical constraints, and environmental requirements.

22.6.1 Framework Components

1. Specification Data Structures:

  • ElectricalCharacteristics: Supply voltage, current consumption (active/sleep/shutdown)
  • PerformanceSpecifications: Range, sensitivity, resolution, accuracy, bandwidth
  • MechanicalSpecifications: Package dimensions, pin count, footprint
  • EnvironmentalSpecifications: Temperature range, humidity, shock/vibration ratings

2. Key Calculations:

Calculation Formula Use
LSB Value Vref / (2^bits) ADC resolution
Measurement Resolution LSB / Sensitivity Minimum detectable change
Dynamic Range 6.02 x bits + 1.76 dB Signal range
Average Power P_active x duty + P_sleep x (1 - duty) Battery life

3. Battery Life Estimation:

Lifetime = (Capacity x Efficiency) / Average Current

Where:
  Capacity = Battery mAh
  Efficiency = ~85% (typical)
  Average Current = Weighted sum of modes

4. Component Ranking:

  • Weighted scoring across multiple criteria
  • Normalized values (0-1 scale)
  • Configurable weights for power, resolution, accuracy, cost, size
  • Sorted rankings (highest score wins)

22.7 Knowledge Check

Requirements:

  • Measure: CO2 concentration (400-5000 ppm range)
  • Accuracy: ±50 ppm ±3% of reading
  • Power: Battery-powered, 2-year life on 2× AAA (2000 mAh at 3V)
  • Sampling: Every 5 minutes
  • Environment: Indoor office (15-30°C)
  • Budget: <$30 per unit (1000 qty)

Candidate Sensors:

Spec SCD30 (Sensirion) MH-Z19C (Winsen) CCS811 (AMS)
Technology NDIR (true CO2) NDIR (true CO2) MOX (eCO2 estimate)
Range 400-10,000 ppm 400-5,000 ppm 400-8192 ppm (eCO2)
Accuracy ±30 ppm ±3% ±50 ppm ±5% ±10% (correlation-based)
Supply Voltage 3.3-5.5V 4.5-5.5V 1.8-3.6V
Active Current 19 mA 150 mA 30 mA
Sleep Current - (no sleep) 0.5 mA 0.15 μA
Measurement Time 2 seconds 30 seconds 1 second (estimated)
Interface I2C, UART UART, PWM I2C
Calibration Auto (ASC) Manual required Auto (baseline)
Price (1k qty) $48 $22 $7

Step 1: Eliminate Non-Qualifiers

CCS811: Uses MOX technology (metal oxide sensor) that estimates eCO2 from VOC levels, not true CO2 measurement. Accuracy is ±10% (±500 ppm at 5000 ppm) vs requirement ±50 ppm ±3%. ELIMINATED.

Step 2: Power Calculation

SCD30:

Reading cycle (5 min):
  Active: 19 mA × 2 s = 38 mAs = 0.0106 mAh
  Idle: 19 mA × 298 s = 5,662 mAs = 1.573 mAh
  Total per cycle: 1.583 mAh

Per day: 288 readings × 1.583 mAh = 456 mAh/day
Battery life: 2000 mAh / 456 mAh = 4.4 days

FAILS 2-year requirement (need 730 days)!

MH-Z19C:

Reading cycle (5 min):
  Measurement (30s): 150 mA × 30 s = 4,500 mAs = 1.25 mAh
  Sleep (270s): 0.5 mA × 270 s = 135 mAs = 0.0375 mAh
  Total per cycle: 1.29 mAh

Per day: 288 readings × 1.29 mAh = 371 mAh/day
Battery life: 2000 mAh / 371 mAh = 5.4 days

FAILS 2-year requirement!

Both sensors fail power budget! Need alternative approach.

Step 3: Design Revision

Reduce sampling to every 30 minutes (not 5 minutes):

MH-Z19C at 30-min intervals:

Per day: 48 readings × 1.29 mAh = 62 mAh/day
Battery life: 2000 mAh / 62 mAh = 32 days (still only 1 month!)

Still inadequate. Try external power or larger battery pack.

Decision: Use MH-Z19C with USB power supply instead of battery.

Alternative: Use 4× D-cell batteries (20,000 mAh) for 322-day life (close to 1 year).

Step 4: Final Recommendation

Winner: MH-Z19C with 5V USB power adapter

  • Meets accuracy requirement: ±50 ppm ±5% (at 1000 ppm = ±50 ppm ±50 ppm = ±100 ppm worst case, acceptable)
  • Range: 400-5,000 ppm perfect match
  • Price: $22 vs $48 (54% cheaper)
  • Tradeoff: Requires mains power, cannot use batteries for 2 years

Lessons Learned:

  1. NDIR CO2 sensors are power-hungry (19-150 mA active)
  2. Battery-powered CO2 monitoring requires large battery packs or AC power
  3. Requirements may need revision when physics constraints are discovered

Use this framework to objectively score and rank sensor candidates when multiple factors compete.

Step 1: Define Criteria and Weights

Criterion Weight (%) Justification
Accuracy 30% Core requirement—bad data is useless
Power Consumption 25% Battery-powered devices
Cost 20% Budget constraints
Availability 15% Supply chain reliability
Ease of Integration 10% Development time

Adjust weights based on YOUR project priorities.

Step 2: Score Each Sensor (0-10 scale)

Criterion Sensor A Sensor B Sensor C
Accuracy ±0.5°C → 10 pts ±1.0°C → 7 pts ±2.0°C → 4 pts
Power 5 μA sleep → 10 pts 50 μA sleep → 7 pts 500 μA sleep → 3 pts
Cost $2 → 10 pts $5 → 6 pts $8 → 4 pts
Availability In stock → 10 pts 8-week lead → 5 pts Obsolete → 0 pts
Integration I2C library → 10 pts Analog + calibration → 6 pts Custom protocol → 3 pts

Scoring Guidelines:

  • 10 points: Exceeds requirements significantly
  • 7-9 points: Meets requirements well
  • 4-6 points: Barely meets requirements
  • 1-3 points: Does not meet requirements (but not disqualifying)
  • 0 points: Completely unacceptable

Step 3: Calculate Weighted Scores

Criterion Weight Sensor A Sensor B Sensor C
Accuracy 30% 10 × 0.30 = 3.0 7 × 0.30 = 2.1 4 × 0.30 = 1.2
Power 25% 10 × 0.25 = 2.5 7 × 0.25 = 1.75 3 × 0.25 = 0.75
Cost 20% 10 × 0.20 = 2.0 6 × 0.20 = 1.2 4 × 0.20 = 0.8
Availability 15% 10 × 0.15 = 1.5 5 × 0.15 = 0.75 0 × 0.15 = 0
Integration 10% 10 × 0.10 = 1.0 6 × 0.10 = 0.6 3 × 0.10 = 0.3
TOTAL 100% 10.0 6.4 3.05

Winner: Sensor A (10.0/10)

Step 4: Sensitivity Analysis

What if power consumption matters LESS (cost-sensitive consumer product)?

Adjust weights: - Accuracy: 35% (increased) - Power: 15% (decreased) - Cost: 30% (increased)

Recalculate:

Sensor New Weighted Score
Sensor A 9.0
Sensor B 6.2
Sensor C 2.7

Sensor A still wins, but margin narrowed. Robust choice!

Step 5: Break Ties

If two sensors score identically, use tiebreakers: 1. Proven track record (deployed in similar products) 2. Second-source availability (multiple vendors) 3. Development ecosystem (eval kits, documentation, forum support) 4. Company stability (avoid startups for critical components)

Real-World Example:

Selecting Accelerometer for Fitness Tracker:

Criterion Weight LIS3DH ADXL345 MMA8452Q
Accuracy 20% 8 7 9
Power (sleep) 30% 10 (0.5 μA) 6 (2.5 μA) 7 (2 μA)
Power (active) 20% 10 (11 μA) 5 (140 μA) 8 (165 μA)
Cost 15% 10 ($1.80) 7 ($3.20) 8 ($2.20)
Availability 10% 10 10 10
Ecosystem 5% 9 10 7
TOTAL 100% 9.3 7.0 8.4

Decision: LIS3DH wins on ultra-low power (critical for wearables) and cost, despite slightly worse ecosystem support than ADXL345.

Common Mistake: Overlooking Interface Compatibility

The Mistake: A developer selects a sensor with the best accuracy and power specs, orders 1,000 units, then discovers their ESP32 firmware uses I2C but the sensor only supports SPI. Panic ensues.

Why It Happens:

Interface compatibility seems like a “minor detail” compared to headline specs (accuracy, range, power). But interface mismatches can: - Make the sensor unusable (no compatible communication) - Require hardware redesign (add I2C-to-SPI bridge IC) - Waste weeks debugging protocol issues

Common Interface Pitfalls:

1. Voltage Level Mismatch:

microcontroller Sensor Problem Solution
ESP32 (3.3V I/O) Sensor (5V I/O) ESP32 damaged by 5V! Use level shifter (BSS138, TXS0108E)
Arduino Uno (5V I/O) Sensor (3.3V I/O) Sensor may tolerate 5V… or die Check datasheet “absolute maximum ratings”

2. Protocol Variant Incompatibility:

I2C Address Conflict:

  • Sensor A: Fixed I2C address 0x76
  • Sensor B: Fixed I2C address 0x76
  • Cannot use both on same I2C bus!

Solution: Choose sensor with programmable address or use I2C multiplexer (TCA9548A).

SPI Mode Mismatch:

// Sensor requires SPI Mode 3 (CPOL=1, CPHA=1)
// But your code uses Mode 0 (CPOL=0, CPHA=0)
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE3));  // Must match sensor

3. Missing Pull-Up Resistors (I2C):

I2C requires external pull-up resistors (typically 4.7kΩ to 10kΩ). Many beginners connect sensor directly:

ESP32 (SDA) ------ Sensor (SDA)    ❌ DOES NOT WORK!

Correct:

ESP32 (SDA) ----+---- Sensor (SDA)
                |
               4.7kΩ
                |
               3.3V

4. Baud Rate Limitations:

Sensor datasheet says “UART: 9600 baud”—but your code assumes 115200 baud. Zero communication!

// WRONG
Serial2.begin(115200);  // Mismatch!

// CORRECT
Serial2.begin(9600);    // Must match sensor default

5. Analog vs. Digital Output:

  • Analog sensors (e.g., TMP36): Output voltage, require ADC pin
  • Digital sensors (e.g., DHT22): Output digital data, require GPIO

Can’t connect analog sensor to digital GPIO—won’t read anything meaningful!

Pre-Selection Checklist:

Before finalizing sensor choice, verify:

Real-World Horror Story:

Team selected BMP388 pressure sensor (I2C/SPI) for altitude tracking. PCB designed with SPI interface (4 wires). After manufacturing 500 boards, discovered firmware team only had I2C library working (SPI library had critical bug). Options: 1. Redesign PCB (8-week delay, $15,000 cost) 2. Write SPI driver from scratch (4-week delay, risky) 3. Use bit-banging I2C on SPI pins (hacky but worked)

Lesson: Verify BOTH hardware AND firmware interface compatibility before committing to production.

22.8 Summary

Key Takeaways:

  1. Define requirements first - Clear criteria enable objective comparison

    • Measurement type, range, accuracy
    • Power budget and battery life target
    • Interface compatibility
    • Environmental conditions
    • Cost constraints
  2. Create structured comparison tables - Extract key specs for all candidates

  3. Calculate power consumption accurately

    • Use duty cycling for realistic estimates
    • Account for all operating modes
    • Design for worst-case (max) values, not typical
  4. Use weighted scoring - Prioritize criteria by project importance

    • Assign weights based on application needs
    • Score objectively (0-10 scale)
    • Calculate weighted totals
  5. Document your decision - Justify selection with quantitative reasoning

22.9 How It Works

The sensor selection process follows a systematic five-step workflow. Step 1 defines application requirements across measurement, power, interface, environment, physical constraints, and cost categories. Step 2 creates comparison tables extracting key specifications from 3-5 candidate sensors. Step 3 calculates power consumption using duty cycling formulas to estimate battery life realistically. Step 4 applies weighted scoring where criteria are prioritized (e.g., 30% accuracy, 30% power, 25% cost, 15% availability) and each sensor receives 0-10 scores per criterion. Step 5 ranks candidates by weighted total score, with sensitivity analysis to verify the decision under different weight distributions. This methodology ensures objective, repeatable component selection decisions.

22.10 Concept Check

Question: A battery-powered sensor samples every 60 seconds with 10ms active time. Active current: 5 mA, Sleep current: 2 μA. What’s average current?

Show Answer Duty cycle = 10ms / 60,000ms = 0.000167 (0.0167%) Average = (5 mA × 0.000167) + (0.002 mA × 0.999833) = 0.000835 + 0.002 = 2.835 μA With 220 mAh battery: Life = 220,000 μAh / 2.835 μA = 77,600 hours = 8.9 years

22.11 Concept Relationships

Prerequisites:

Builds Toward:

Complements:

  • Energy Management - Power budget optimization and battery life strategies
  • Power Management Techniques - Duty cycling and sleep mode implementation

22.12 See Also

22.13 Try It Yourself

Scenario: Designing a weather station that measures barometric pressure for altitude estimation.

Requirements:

  • Range: 300-1100 hPa (sea level to 9,000m altitude)
  • Accuracy: ±1 hPa (equivalent to ±8 meters altitude error)
  • Interface: I2C (ESP32 available pins)
  • Power: Battery-powered, 2-year life on 2× AA (3,000 mAh)
  • Sampling: Every 5 minutes
  • Budget: <$5/unit

Task: Compare three candidates: 1. BMP280 (Bosch) 2. MPL3115A2 (NXP) 3. MS5611 (TE Connectivity)

Steps:

  1. Find datasheets online
  2. Create comparison table (range, accuracy, current, interface, price)
  3. Calculate battery life for each
  4. Apply weighted scoring: Accuracy 35%, Power 30%, Cost 25%, Availability 10%
  5. Select winner

What to Observe:

  • Which sensor has lowest sleep current?
  • Does accuracy degrade outside 0-40°C?
  • Are all available from major distributors?

Expected Outcome: BMP280 typically wins on cost ($2) and power (0.1 μA sleep), though MS5611 has better accuracy. This exercise demonstrates real-world trade-offs in component selection.

Common Pitfalls

More features does not mean better fit. A sensor with 20 operating modes, programmable filters, and multi-axis output may be excellent for one application and completely wrong for another. Selection must be driven by application requirements, not component capabilities.

Application notes show the sensor performing ideally under controlled conditions. Real deployments encounter temperature variation, mechanical mounting stress, and electromagnetic interference that affect accuracy. Always validate selected sensors under actual deployment conditions before finalizing the design.

A sensor selected based on current availability may be discontinued in 3 years. For IoT products with 5–10 year lifecycles, verify the component’s stated production lifetime, identify second-source alternatives, and assess the manufacturer’s track record for lifecycle management.

Datasheet specifications describe the population of manufactured parts. Testing only one unit may encounter a part at the extreme of the distribution. Always test at least 5–10 units from the same manufacturing lot to characterize actual unit-to-unit variation before committing to a component.

22.14 What’s Next

If you want to… Read this
Apply sensor selection to safety-critical systems Automotive Applications
Optimize power consumption for battery-powered devices Energy-Aware Considerations
Implement selected sensors in circuit designs Hardware Prototyping
See a real accelerometer datasheet walkthrough Accelerometer Case Study
Test sensors in simulation before buying Simulating Hardware Programming

Continue to Automotive Sensor Applications to explore industry-specific sensor requirements for safety-critical systems including seat occupancy detection, airbag deployment, tire pressure monitoring, and adaptive cruise control.

Related Chapters:

Previous Current Next
Accelerometer Case Study Sensor Selection Automotive Applications