538 Common IoT Sensors and MEMS Technology
Learning Objectives
After completing this chapter, you will be able to:
- Identify common IoT sensors and their specifications
- Understand MEMS (Micro-Electro-Mechanical Systems) technology
- Choose between sensor options for temperature, motion, distance, and environmental sensing
- Apply knowledge of sensor physics to troubleshooting
538.1 Prerequisites
- Sensor Specifications: Understanding accuracy, resolution
- Reading Datasheets: How to read sensor specifications
538.2 Common IoT Sensors
538.3 Common IoT Sensor Comparison
This comprehensive comparison table helps you select the right sensor for your specific IoT application.
| Sensor Type | Measures | Range | Power | Cost | Common Uses |
|---|---|---|---|---|---|
| Temperature (DHT22) | Temp, Humidity | -40 to 80C | Low | $3-5 | HVAC, weather |
| Temperature (DS18B20) | Temperature | -55 to 125C | Very Low | $2-3 | Industrial, water |
| Motion (PIR) | Infrared motion | 3-7m | Low | $1-3 | Security, lighting |
| Motion (Radar) | Doppler motion | 5-10m | Medium | $5-15 | Presence detection |
| Distance (Ultrasonic) | Distance | 2cm-4m | Medium | $2-5 | Parking, level |
| Distance (ToF) | Distance | 0-2m | Low | $5-15 | Robotics, gesture |
| Light (LDR) | Ambient light | 0-1000 lux | Very Low | $0.50 | Day/night sensing |
| Light (TSL2561) | Lux, IR | 0-40k lux | Low | $3-6 | Smart lighting |
| Accelerometer | Motion, tilt | +/-2-16g | Low | $2-8 | Wearables, impact |
| Air Quality (MQ-x) | Gas, smoke | Varies | High | $3-10 | Safety, pollution |
Consider these factors: 1. Accuracy - How precise does measurement need to be? 2. Power - Battery-powered or mains? 3. Environment - Indoor, outdoor, harsh conditions? 4. Cost - Per-unit budget for deployment scale? 5. Interface - Analog, digital (I2C, SPI, UART)?
538.4 Temperature Sensors
538.4.1 DHT22 (Temperature + Humidity)
Specifications: - Temperature: -40 to 80C, +/-0.5C accuracy - Humidity: 0-100% RH, +/-2-3% accuracy - Interface: Single-wire digital - Sampling rate: Max 0.5 Hz (1 reading per 2 seconds) - Price: $3-5
Best for: Indoor environmental monitoring, smart home
Limitations: Slow (2s between readings), no I2C option
538.4.2 DS18B20 (1-Wire Temperature)
Specifications: - Temperature: -55 to 125C, +/-0.5C accuracy - Interface: 1-Wire (multiple sensors on one pin) - Resolution: 9-12 bit configurable - Price: $2-3
Best for: Multi-point temperature monitoring, waterproof applications
Unique feature: Multiple sensors share one GPIO pin (1-Wire bus)
538.4.3 BME280 (Temp + Humidity + Pressure)
Specifications: - Temperature: -40 to 85C, +/-1C accuracy - Humidity: 0-100% RH, +/-3% accuracy - Pressure: 300-1100 hPa, +/-1 hPa accuracy - Interface: I2C or SPI - Price: $5-10
Best for: Weather stations, altitude sensing, indoor air quality
538.5 How MEMS Accelerometers Actually Work
Understanding how sensors work internally helps you choose the right one and interpret data correctly. Most IoT motion sensors are MEMS (Micro-Electro-Mechanical Systems) accelerometers.
538.5.1 The Harmonic Oscillator Model
Many sensors can be modeled as mechanical harmonic oscillatorsโa mass on a spring:
How It Works: 1. Proof mass (m): A tiny mass (~nanograms to micrograms) suspended by microscopic springs 2. Acceleration causes displacement: When the chip accelerates, the proof mass lags behind 3. Measure displacement: The springโs displacement reveals the acceleration 4. Calculate acceleration: a = k*delta_z/m (where k is the spring constant)
Maximum Frequency (Bandwidth):
The highest frequency an accelerometer can measure is determined by its resonant frequency:
\[f_{max} = \frac{1}{2\pi}\sqrt{\frac{k}{m}}\]
- Stiffer springs (higher k) -> higher frequency response but lower sensitivity
- Lighter proof mass (lower m) -> higher frequency response
- Trade-off: High-bandwidth accelerometers are less sensitive to small accelerations
538.5.2 Capacitive Displacement Measurement
MEMS accelerometers typically use capacitive sensing:
\[C = \frac{\epsilon_0 \cdot A}{d}\]
As the proof mass moves, d changes, changing capacitance. Electronics measure this capacitance change and calculate displacement.
538.6 Motion Sensors
538.6.1 PIR (Passive Infrared)
Specifications: - Detection range: 3-7m, 120 degree angle - Output: Digital HIGH/LOW - Response time: ~0.5-1 second - Power: 50uA standby - Price: $1-3
Best for: Security, lighting automation, occupancy
How it works: Detects changes in infrared radiation (body heat)
538.6.2 MPU6050 (6-axis IMU)
Specifications: - Accelerometer: +/-2/4/8/16g selectable - Gyroscope: +/-250/500/1000/2000 degrees/sec - Interface: I2C - Sample rate: Up to 1kHz - Price: $3-8
Best for: Motion tracking, orientation sensing, wearables
538.6.3 VL53L0X (Time-of-Flight Distance)
Specifications: - Range: 30mm to 2000mm - Accuracy: +/-3% at 2m - Interface: I2C - Update rate: Up to 50 Hz - Price: $5-15
Best for: Gesture sensing, robotics, precise distance measurement
538.7 Environmental Sensors
538.7.1 MQ-135 (Air Quality)
Specifications: - Detects: NH3, NOx, alcohol, benzene, smoke, CO2 - Range: 10-300 ppm (NH3), 10-1000 ppm (benzene) - Interface: Analog voltage - Power: 150mA (5V) - continuous heating required - Price: $3-8
Critical: Requires 24-48 hour burn-in before accurate readings!
538.7.2 BME680 (Environmental Gas)
Specifications: - Temperature, humidity, pressure + gas resistance - VOC sensing for indoor air quality - Interface: I2C/SPI - Price: $10-15
Best for: Indoor air quality monitoring, smart home
538.8 Lab Setup Guide
538.8.1 Setting Up Your Sensor Lab Environment
For hands-on sensor work, you need:
Hardware: - ESP32 or Arduino board - Breadboard and jumper wires - USB cable for programming - Multimeter (for debugging) - Sensors (DHT22, BMP280, etc.)
Software: - Arduino IDE or PlatformIO - Sensor libraries (installed via Library Manager) - Serial monitor for debugging
Common Connections:
| Sensor | VCC | GND | Data/SDA | CLK/SCL | Notes |
|---|---|---|---|---|---|
| DHT22 | 3.3V | GND | GPIO4 | - | 10k pull-up on data |
| BMP280 | 3.3V | GND | GPIO21 | GPIO22 | I2C address 0x76/0x77 |
| DS18B20 | 3.3V | GND | GPIO5 | - | 4.7k pull-up on data |
| MPU6050 | 3.3V | GND | GPIO21 | GPIO22 | I2C address 0x68 |
538.9 Summary
Key common sensor takeaways:
- Temperature: DHT22 for simple, DS18B20 for multi-point, BME280 for multi-parameter
- Motion: PIR for presence, accelerometer for movement/tilt
- Distance: Ultrasonic for long range, ToF for precision
- Environmental: MQ series needs burn-in, BME680 for comprehensive monitoring
- MEMS sensors: Tiny mechanical systems with capacitive readout
538.10 Whatโs Next
Now that you know common sensors:
- To practice hands-on: Hands-On Labs - Build real sensor projects
- To select the best option: Selection Guide - Decision tools
- To avoid mistakes: Common Mistakes - Top 10 pitfalls