9  Sensor Classifications

In 60 Seconds

Sensors are classified by measurement type (environmental, motion, chemical), output type (analog, digital, I2C, SPI, UART, 1-Wire), and power requirement (active vs passive). Use analog for simple low-cost sensors, I2C when sharing a bus with multiple devices, SPI for high-speed data, and UART for smart sensors with built-in processing. Passive sensors consume far less power than active sensors, making them ideal for battery-powered IoT deployments.

Key Concepts
  • Active vs. Passive Sensor: Active sensors require external power to operate (thermistors, LDRs, strain gauges); passive sensors generate their own electrical output from the measured phenomenon (thermocouples, piezoelectric sensors)
  • Contact vs. Non-Contact Sensor: Contact sensors must physically touch the measured object (thermistors, strain gauges); non-contact sensors measure from a distance (IR thermometers, ultrasonic range finders, capacitive proximity sensors)
  • Absolute vs. Relative Sensor: Absolute sensors reference to a fixed standard (GPS coordinates, absolute barometric pressure); relative sensors reference to a condition (differential pressure, incremental encoder position)
  • Analog vs. Digital Output: Analog sensors produce a continuous voltage or current proportional to the measured quantity; digital sensors produce discrete values through I2C, SPI, UART, or PWM protocols
  • Scalar vs. Vector Sensor: Scalar sensors measure a single-value quantity (temperature, pressure, distance); vector sensors measure magnitude and direction (3-axis accelerometers, 3-axis magnetometers)
  • Intrinsic vs. Extrinsic Optical Fiber Sensor: In intrinsic sensors the fiber itself is the sensing element (fiber Bragg gratings); in extrinsic sensors the fiber only carries light to and from an external sensing element
  • Primary vs. Derived Measurement: A primary measurement directly senses the physical quantity (RTD measures resistance); a derived measurement computes the quantity from other measurements (wind speed from anemometer pulse frequency)
  • Self-Calibrating Sensor: Sensors with internal reference elements or automatic compensation circuits that adjust for temperature drift and aging without user intervention; reduces maintenance burden in deployed IoT systems

Learning Objectives

After completing this chapter, you will be able to:

  • Classify sensors by measurement type (environmental, motion/position, chemical/gas)
  • Compare output types (analog, digital, I2C, SPI, UART, 1-Wire) and their trade-offs
  • Differentiate between active and passive sensors based on power and energy emission characteristics
  • Select appropriate sensor interfaces for a given IoT project based on GPIO, cost, and noise constraints

Just like animals can be classified into mammals, birds, and fish, sensors can be grouped by what they measure (temperature, motion, light) and how they communicate with a microcontroller (analog voltage, digital pulses, or data protocols like I2C). Understanding these categories helps you quickly narrow down which sensor to use for your project, rather than being overwhelmed by the thousands of options available.

9.1 Prerequisites

9.2 By Measurement Type

~15 min | Intermediate | P06.C08.U03

How It Works: Sensor Classification Framework

Sensor classification follows a hierarchical approach:

  1. Identify measurement domain - What physical property needs sensing? (temperature, motion, chemical concentration)
  2. Determine signal path - How does the signal reach your microcontroller? (analog voltage, digital protocol, frequency modulation)
  3. Assess power source - Does the sensor emit energy (active) or detect existing energy (passive)?
  4. Match to application - Cross-reference requirements with sensor categories to narrow choices

Example flow: “I need to measure room occupancy” → Motion sensing → Passive IR detection → PIR sensor (detects existing thermal radiation, no emitted energy) → Digital output (HIGH/LOW) → Battery-friendly (50μA standby)

The first question when selecting a sensor is: “What physical quantity do I need to measure?” Sensors fall into three broad families, each targeting different aspects of the physical world. This classification matters because it determines not only the sensor technology but also the signal conditioning, calibration procedures, and maintenance requirements for your IoT deployment.

9.2.1 Environmental Sensors

Environmental sensors are the workhorses of IoT – they monitor the ambient conditions that affect human comfort, crop growth, equipment health, and building efficiency. Most IoT projects start here because environmental data is easy to collect, immediately useful, and the sensors are mature and inexpensive.

Sensor Type What It Measures Common Models Typical Accuracy
Temperature Thermal energy DHT22, DS18B20, BME280 ±0.5°C
Humidity Moisture in air DHT22, SHT31, BME280 ±2-3% RH
Pressure Atmospheric pressure BMP280, MS5611 ±1 hPa
Light Ambient illumination BH1750, TSL2561 ±5% lux
Air Quality CO2, VOCs, particulates MQ-135, BME680, PMS5003 Varies

9.2.2 Motion and Position Sensors

Motion sensors answer the question “Where is it, and how is it moving?” These sensors are essential for wearables, robotics, asset tracking, and any IoT system that needs spatial awareness. A key design decision is whether you need absolute position (GPS gives latitude/longitude) or relative motion (accelerometers detect changes in velocity). Many applications combine both – a fitness tracker uses GPS for outdoor routes and accelerometers for indoor step counting where GPS signals cannot penetrate.

Sensor Type What It Measures Common Models Applications
Accelerometer Linear acceleration ADXL345, MPU6050 Step counting, tilt
Gyroscope Angular velocity MPU6050, L3GD20 Rotation, orientation
Magnetometer Magnetic field QMC5883L, LIS3MDL Compass, heading
GPS Geographic position NEO-6M, NEO-M8N Location tracking
Proximity Object presence HC-SR04, VL53L0X Distance, presence

9.2.3 Chemical and Gas Sensors

Chemical sensors detect the invisible – gases, compounds, and chemical concentrations that human senses cannot reliably measure. These sensors are critical for safety (detecting carbon monoxide or gas leaks), environmental monitoring (measuring air quality in cities), and industrial process control (ensuring food production stays within safe pH ranges). A distinctive characteristic of many chemical sensors is the “burn-in” period: metal-oxide gas sensors like the MQ series need 24-48 hours of initial heating before their readings stabilize. Plan for this during deployment – a freshly powered sensor gives unreliable readings.

Sensor Type What It Detects Common Models Notes
CO2 Carbon dioxide MH-Z19, SCD30 NDIR or electrochemical
VOC Volatile organics BME680, SGP30 Air quality index
Smoke/Gas Combustible gases MQ-2, MQ-5 Requires 24-48h burn-in
pH Acidity/alkalinity pH probe + ADC Needs regular calibration

Some sensors appear in multiple categories because their classification depends on application context. For example, the MQ-135 (listed under Environmental > Air Quality) is technically a metal-oxide gas sensor in the same family as the MQ-2 and MQ-5 (listed under Chemical/Gas). Similarly, the BME680 combines environmental measurements (temperature, humidity, pressure) with a VOC gas sensor. When you encounter a sensor that fits multiple categories, classify it based on its primary role in your specific application – air quality monitoring is “Environmental,” while detecting specific gas leaks is “Chemical.”

9.3 By Output Type

The output type determines how a sensor communicates with your microcontroller, and this choice has cascading effects on wiring complexity, power consumption, noise immunity, and how many sensors you can connect to a single board. Choosing the wrong interface can mean running out of GPIO pins, introducing noise into sensitive measurements, or making your PCB layout unnecessarily complex.

Output Type Description Interface Example Sensors
Analog Continuous voltage/current signal ADC required LM35 (temp), LDR (light), Flex sensor
Digital Discrete HIGH/LOW states GPIO PIR motion, reed switch, IR obstacle
PWM Pulse width modulated signal Timer/counter Some ultrasonic range sensors, fan tachometers
I2C Two-wire serial protocol I2C bus BMP280, MPU6050, Si7021
SPI Four-wire serial protocol SPI bus MAX31855, LSM9DS1
UART Serial asynchronous communication UART/Serial GPS modules, PM2.5 sensors
1-Wire Single data wire + ground protocol 1-Wire interface DS18B20 temperature

9.3.1 Choosing the Right Interface

Interface Selection Guide

Use Analog when:

  • Simple, low-cost sensors (photoresistors, thermistors)
  • Need custom signal conditioning
  • Only one or few sensors

Use I2C when:

  • Multiple sensors sharing a bus
  • Need built-in calibration
  • Standard breakout boards

Use SPI when:

  • High-speed data transfer needed
  • Multiple sensors with chip-select
  • Signal integrity critical

Use UART when:

  • Smart sensors with built-in processing
  • GPS modules, particulate sensors
  • Long-distance communication needed
Worked Example: Interface Choice Shapes an Entire Product

A company is designing a greenhouse monitoring node with 6 sensors: temperature, humidity, soil moisture, light level, CO2, and wind speed. The ESP32-WROOM-32 has 2 I2C buses, 2 SPI buses, 3 UART ports, and 18 analog-capable GPIOs (other ESP32 variants may differ – e.g., the ESP32-S2 has only 1 I2C bus). The interface choice for each sensor has cascading effects on GPIO usage, wiring complexity, power, and cost.

Option 1: All Analog Sensors

Sensor Part Interface GPIO Pins Used Unit Cost
Temperature NTC thermistor + voltage divider Analog 1 ADC $0.30
Humidity HR202 resistive + 555 timer circuit Analog 1 ADC $0.80
Soil moisture Capacitive probe (raw voltage) Analog 1 ADC $1.50
Light LDR + resistor divider Analog 1 ADC $0.15
CO2 MG-811 electrochemical Analog 1 ADC + 1 heater GPIO $18.00
Wind speed Anemometer pulse output → RC filter → analog Analog 1 ADC $12.00
Totals 6 analog + 1 digital 7 GPIOs $32.75

Problems: Each analog sensor needs individual signal conditioning (resistor dividers, amplifiers, RC filters). The MG-811 CO2 sensor requires a 6V heater drawing 200 mA – a separate voltage regulator and MOSFET driver circuit. Thermistor accuracy is +/-2C without calibration lookup table. Total wiring: 14 individual wires to the ESP32 (power + signal per sensor), plus 6 signal conditioning circuits on the PCB. Firmware needs 6 separate ADC calibration routines.

Option 2: Digital Bus Sensors (I2C + UART)

Sensor Part Interface GPIO Pins Used Unit Cost
Temperature + humidity SHT41 I2C (0x44) Shared SDA/SCL $2.80
Soil moisture Stemma soil sensor I2C (0x36) Shared SDA/SCL $6.00
Light BH1750 I2C (0x23) Shared SDA/SCL $1.20
CO2 SCD41 (photoacoustic NDIR, no heater needed) I2C (0x62) Shared SDA/SCL $28.00
Wind speed Ultrasonic anemometer module UART TX + RX $35.00
Totals 4 I2C + 1 UART 4 GPIOs $73.00

Advantages: All I2C sensors share just 2 wires (SDA + SCL). No signal conditioning circuits needed – each sensor has built-in ADC, calibration, and digital output. SHT41 replaces two separate sensors (temperature + humidity) in one package. SCD41 uses photoacoustic NDIR sensing instead of electrochemical, eliminating the 200 mA heater (the infrared-based approach detects CO2 without a high-temperature heating element). Total unique signal lines to ESP32: 4 GPIOs (2 I2C + 2 UART), with power distributed via a shared 3.3V/GND bus rail – compared to 7 signal wires plus 6 conditioning circuits for the analog option. Zero analog calibration code.

Quantified Comparison:

Factor Option 1 (All Analog) Option 2 (Digital Bus) Impact
Sensor BOM $32.75 $73.00 +$40.25 per unit
Signal conditioning BOM ~$8.00 (resistors, caps, op-amps) $0 -$8.00 per unit
PCB complexity 6 conditioning circuits, larger board Minimal, smaller board PCB cost: $2.50 vs $1.20
GPIO pins consumed 7 4 3 freed GPIOs for expansion
Wiring labor (assembly) 14 wires, 45 min 4 signal + shared bus, 15 min 30 min saved per unit
Temperature accuracy ±2°C (uncalibrated thermistor) ±0.2°C (factory-calibrated SHT41) 10x better accuracy
Power draw (CO2 sensor) 200 mA (MG-811 heater) 40 mA avg (SCD41 periodic) 5x less power
Firmware complexity 6 ADC drivers + calibration tables 5 I2C register reads ~60% less code
Hardware subtotal $32.75 sensor + $8.00 conditioning + $2.50 PCB = $43.25 $73.00 sensor + $0 conditioning + $1.20 PCB = $74.20 +$30.95 digital premium
Total cost at 1 unit $43.25 + $18.75 labor = $62.00 $74.20 + $6.25 labor = $80.45 Analog cheaper
Total cost at 500 units $43.25 + $18.75 labor = $62.00/unit = $31,000 total $74.20 + $6.25 labor = $80.45/unit = $40,225 total Analog $9,225 cheaper

Total cost of ownership reveals when digital sensors become cost-effective. At 500 units:

\[C_{analog} = 500 \times (\$43.25 + 0.75\text{h} \times \$25/\text{h}) = 500 \times (\$43.25 + \$18.75) = 500 \times \$62.00 = \$31{,}000\]

\[C_{digital} = 500 \times (\$74.20 + 0.25\text{h} \times \$25/\text{h}) = 500 \times (\$74.20 + \$6.25) = 500 \times \$80.45 = \$40{,}225\]

In this scenario, analog remains cheaper even at production scale because the sensor cost premium ($74.20 - $43.25 = $30.95) is larger than the labor savings ($18.75 - $6.25 = $12.50). Digital only wins when sensor prices drop or when the accuracy, power efficiency, and reduced maintenance justify the higher upfront cost.

Interactive Cost Calculator:

Decision: At prototype and production scale, analog sensors have lower upfront cost ($31,000 vs $40,225 at 500 units). However, the greenhouse company chose Option 2 (digital) despite the higher initial cost because: (1) factory-calibrated sensors eliminate $5,000+ in field calibration visits over 3 years, (2) 10x better temperature accuracy (±0.2°C vs ±2°C) prevents crop loss, (3) 5x lower power draw (40 mA vs 200 mA for CO2) extends battery life significantly in solar installations, and (4) simplified firmware reduces engineering time by 40 hours ($4,000 saved). Total 3-year TCO favors digital by $15,000+ when accounting for operational costs.

Key lesson: Interface choice is not just a technical decision – it determines PCB size, assembly time, calibration requirements, and total cost of ownership. Cheap analog sensors can become expensive at scale due to their wiring and calibration burden.

9.4 By Power Requirement

The active/passive distinction is one of the most important for battery-powered IoT deployments. An active sensor emits energy into the environment and measures what comes back (like sonar sending out sound waves), while a passive sensor detects energy that already exists (like a thermometer reading ambient heat). This difference can mean orders of magnitude in power consumption – a typical passive PIR motion sensor draws roughly 50 microamps in standby, while an active radar sensor draws around 50 milliamps – roughly a 1,000x difference that translates directly to battery life.

Type Characteristics Examples Use Cases
Active Sensors Require external power, emit energy Radar, ultrasonic, active RFID Distance measurement, object detection
Passive Sensors Detect existing energy, low power Thermistors, LDR, passive IR Battery-powered applications

Interactive Battery Life Calculator:

Tradeoff: Wired vs Wireless Sensors

The wired vs wireless choice is closely tied to power requirements: wireless sensors must carry their own batteries (making the active/passive distinction even more critical), while wired sensors can draw power continuously from the cable.

Wired Sensors (Ethernet, RS-485, 4-20mA):

  • Reliable, no interference
  • No battery replacement
  • Higher installation cost
  • Fixed location

Wireless Sensors (Wi-Fi, LoRa, Zigbee, BLE):

  • Flexible placement
  • Lower installation cost
  • Battery replacement required
  • Potential interference

Choose wired for: Industrial environments, critical measurements, permanent installations

Choose wireless for: Retrofits, temporary installations, hard-to-wire locations

9.5 Sensor Types by Application Domain

The three classification dimensions – measurement type, output interface, and power requirement – converge when selecting sensors for a specific application domain. Each domain has its own priorities:

Domain Common Sensors Key Requirements
Smart Home Temperature, humidity, motion, door/window Low power, easy setup
Industrial IoT Vibration, temperature, pressure, current Rugged, accurate, reliable
Agriculture Soil moisture, temperature, light, weather Outdoor-rated, long battery
Healthcare Heart rate, SpO2, temperature, glucose Medical-grade accuracy
Automotive Accelerometer, gyroscope, GPS, radar Fast response, safety-critical

9.6 Practical Implementation: I2C Multi-Sensor Bus

With classification concepts in hand, let us see how sensor interfaces work in practice. I2C is the most common bus protocol in IoT because multiple devices share just two wires. Here is how to scan and read from multiple sensors on the same bus using an ESP32:

# MicroPython: I2C multi-sensor scanning and reading
from machine import I2C, Pin
import time

# Initialize I2C bus
i2c = I2C(0, scl=Pin(22), sda=Pin(21), freq=400000)

# Scan for connected devices
devices = i2c.scan()
print(f"Found {len(devices)} devices:")
for addr in devices:
    print(f"  Address: 0x{addr:02X}", end=" ")
    if addr == 0x76:
        print("(BMP280 pressure sensor)")
    elif addr == 0x68:
        print("(MPU6050 accelerometer/gyroscope)")
    elif addr == 0x23:
        print("(BH1750 light sensor)")
    else:
        print("(Unknown device)")

# --- BMP280 Temperature Reading ---
# Read temperature from BMP280 (simplified)
def read_bmp280_temp(i2c, addr=0x76):  # Use 0x77 if SDO pin is connected to Vddio
    """Read raw temperature from BMP280 sensor."""
    # Read calibration data (registers 0x88-0x9F)
    cal = i2c.readfrom_mem(addr, 0x88, 6)
    dig_T1 = cal[0] | (cal[1] << 8)
    dig_T2 = cal[2] | (cal[3] << 8)
    if dig_T2 > 32767: dig_T2 -= 65536
    dig_T3 = cal[4] | (cal[5] << 8)
    if dig_T3 > 32767: dig_T3 -= 65536

    # Trigger forced measurement
    i2c.writeto_mem(addr, 0xF4, bytes([0x25]))
    time.sleep_ms(50)

    # Read raw temperature (registers 0xFA-0xFC)
    raw = i2c.readfrom_mem(addr, 0xFA, 3)
    raw_temp = (raw[0] << 12) | (raw[1] << 4) | (raw[2] >> 4)

    # Compensation formula from datasheet
    var1 = ((raw_temp / 16384.0) - (dig_T1 / 1024.0)) * dig_T2
    var2 = (((raw_temp / 131072.0) - (dig_T1 / 8192.0)) ** 2) * dig_T3
    temp_c = (var1 + var2) / 5120.0
    return round(temp_c, 2)

# Read and display
temp = read_bmp280_temp(i2c)
print(f"Temperature: {temp} C")

Key I2C design considerations:

Parameter Guideline Why It Matters
Pull-up resistors 4.7k ohm to 3.3V on SDA and SCL Required for I2C communication. Some breakout boards include them; check before adding duplicates.
Bus length < 1 meter for 400 kHz, < 3 meters for 100 kHz Longer wires increase capacitance, causing signal degradation
Max devices 112 usable addresses (128 minus 16 reserved), practically 10-20 Address conflicts and bus capacitance limit practical count
Clock speed 100 kHz (standard), 400 kHz (fast) Faster = more data, but more sensitive to noise

9.7 Signal Conditioning: From Raw Sensor to Usable Data

Raw sensor outputs are rarely ready for direct use. A strain gauge might produce only 2 millivolts of signal buried in noise, a thermistor has a non-linear resistance curve, and a 5V sensor output could damage a 3.3V microcontroller. Signal conditioning is the chain of analog circuits that transform a raw sensor signal into a clean, proportional voltage that your ADC can read accurately. Skipping or underdesigning this stage is the most common cause of unreliable sensor readings in IoT prototypes.

Stage Purpose Example
Amplification Boost weak signals Strain gauge outputs 2 mV; amplify to 0-3.3V range
Filtering Remove noise RC low-pass filter removes 50/60 Hz power line noise
Level shifting Match ADC voltage range 0-5V sensor output shifted to 0-3.3V for ESP32
Linearization Correct non-linear response Thermistor follows Steinhart-Hart equation, not linear

Thermistor linearization example:

import math

def thermistor_temp(adc_value, r_series=10000, beta=3950, r_nominal=10000):
    """Convert thermistor ADC reading to temperature.

    Uses Steinhart-Hart simplified (Beta equation):
    1/T = 1/T0 + (1/Beta) * ln(R/R0)

    Args:
        adc_value: Raw ADC reading (0-4095 for 12-bit)
        r_series: Series resistor value (ohms)
        beta: Thermistor Beta coefficient
        r_nominal: Resistance at 25C (ohms)
    """
    # Calculate thermistor resistance from voltage divider
    if adc_value <= 0 or adc_value >= 4095:
        return None  # Sensor disconnected or shorted
    resistance = r_series * (4095.0 / adc_value - 1.0)

    # Steinhart-Hart simplified equation
    t_kelvin = 1.0 / (
        (1.0 / 298.15) +           # 1/T0 (T0 = 25C = 298.15K)
        (1.0 / beta) *             # 1/Beta
        math.log(resistance / r_nominal)  # ln(R/R0)
    )

    return round(t_kelvin - 273.15, 1)  # Convert to Celsius

Interactive Thermistor Calculator:

Key Takeaway

Sensor classification is the foundation of good sensor selection. Match the measurement type to your application, choose the interface that fits your hardware constraints (I2C for multi-sensor, SPI for speed, analog for simplicity), and consider whether active or passive sensing meets your power budget. Every classification decision affects cost, complexity, power consumption, and reliability.

The Sensor Squad decided to organize themselves! Max the Microcontroller made a big chart on the wall.

“First, what do you MEASURE?” Max asked. Sammy the Sensor said “Temperature!” Others shouted: “Light!” “Motion!” “Gas!” “Distance!” Max wrote them all under different categories: Environmental, Motion, Chemical, and more.

“Next, how do you TALK to me?” Max continued. Some sensors spoke “Analog” (like a dimmer switch – any value from 0 to 100). Others spoke “Digital” (just ON or OFF, like a light switch). And some spoke fancy protocols: “I2C uses two wires and gives everyone a name-tag (address),” explained one. “SPI is faster but needs four wires!” said another.

Lila the LED asked about power. “Some sensors are ACTIVE – they send out energy and listen for echoes, like ultrasonic sensors shouting sound waves,” Max explained. “Others are PASSIVE – they just listen for what is already there, like PIR sensors feeling body heat.”

Bella the Battery smiled: “I like passive sensors best – they use way less of my energy!”

## Concept Relationships

Concept Related To Connection Type
Analog Sensors ADC Resolution Analog output quality depends on ADC bit depth
I2C Interface Pull-up Resistors I2C requires 4.7kΩ pull-ups to function
Active Sensors Power Budget Active sensors draw 10-1000x more power than passive
Passive Sensors Battery Life Passive PIR (50μA) enables years of battery operation
Digital Protocols Noise Immunity Digital signals resist interference better than analog

9.8 Summary

Key classification takeaways:

  1. Match measurement type to application - Environmental, motion/position, or chemical/gas
  2. Choose interface wisely - Analog for simple, I2C/SPI for digital, UART for smart sensors
  3. Consider power requirements - Active vs passive impacts battery life
  4. Wired vs wireless - Based on installation constraints and reliability needs

9.9 See Also

Common Pitfalls

A sensor labeled ‘digital’ may mean it uses a digital communication protocol (I2C, SPI) OR that it produces a simple HIGH/LOW output. Using an I2C library for a PWM-output sensor produces completely incorrect readings. Always check the datasheet’s output type section before selecting a library.

High-precision industrial 4-20 mA transmitters achieve +-0.1% accuracy — far exceeding many digital consumer sensors. Do not dismiss analog output sensors as inferior; their precision depends on the signal conditioning and ADC resolution in the interface circuit.

Absolute pressure sensors reference a perfect vacuum; gauge pressure sensors reference ambient atmospheric pressure. Using an absolute sensor to measure tire pressure gives readings around 101 kPa + gauge pressure, not just the gauge reading. Selecting the wrong type produces values that appear correct but are practically meaningless.

3-axis accelerometers report gravity components on all three axes simultaneously. Analyzing only one axis ignores the others, producing orientation-dependent readings that change when the device tilts. Always consider the full 3D vector and compensate for static gravity offset.

9.10 What’s Next

Chapter Focus Why It Matters
Braitenberg Model Sensor-actuator relationships Explore how sensors drive reactive behavior in autonomous systems
Infrastructure Sensing Leveraging Wi-Fi, power meters Repurpose existing infrastructure as sensors without new hardware
Common IoT Sensors Popular sensors and MEMS Review specific sensor models and selection guidance for each category
Reading Datasheets Interpreting sensor specifications Verify accuracy, power, and interface claims before purchasing
Selection Guide Step-by-step sensor selection Apply classification knowledge to systematically choose sensors