Back to Sensors & Actuators Series

Part 3: Sensor Categories

July 14, 2025 Wasil Zafar 65 min read

A comprehensive survey of 15 sensor families — temperature, pressure, proximity, motion, light, environmental, position, biomedical, magnetic (Hall effect), capacitive touch, current/voltage, color, sound, and RFID/NFC — with working principles, interfacing, and code examples.

Table of Contents

  1. Temperature Sensors
  2. Pressure Sensors
  3. Proximity Sensors
  4. Motion & Inertial Sensors
  5. Light & Optical Sensors
  6. Environmental Sensors
  7. Position & Displacement
  8. Biomedical Sensors
  9. Magnetic Sensors (Hall Effect)
  10. Touch & Capacitive Sensors
  11. Current & Voltage Sensors
  12. Color Sensors
  13. Sound Sensors
  14. RFID & NFC Sensors
  15. Conclusion & Next Steps
Sensor Category Overview
graph LR
    S["🔍 Sensor Categories"] --> G1["Environmental"]
    S --> G2["Motion & Position"]
    S --> G3["Electrical"]
    S --> G4["Biomedical"]
    S --> G5["Identification"]
    G1 --> T1["🌡️ Temperature"]
    G1 --> T2["💨 Pressure"]
    G1 --> T3["💡 Light"]
    G1 --> T4["🌿 Environmental"]
    G1 --> T5["🔊 Sound"]
    G2 --> T6["📍 Proximity"]
    G2 --> T7["🏃 Motion"]
    G2 --> T8["📐 Position"]
    G2 --> T9["🧲 Magnetic"]
    G3 --> T10["⚡ Current/Voltage"]
    G3 --> T11["🎨 Color"]
    G4 --> T12["❤️ Biomedical"]
    G4 --> T13["👆 Touch/Force"]
    G5 --> T14["📶 RFID/NFC"]
    G5 --> T15["📸 Image"]
    style S fill:#3B9797,stroke:#3B9797,color:#fff
    style G1 fill:#e8f4f4,stroke:#3B9797,color:#132440
    style G2 fill:#f0f4f8,stroke:#16476A,color:#132440
    style G3 fill:#e8f4f4,stroke:#3B9797,color:#132440
    style G4 fill:#f0f4f8,stroke:#16476A,color:#132440
    style G5 fill:#e8f4f4,stroke:#3B9797,color:#132440
                            

Temperature Sensors

Temperature is the most commonly measured physical quantity. Each sensor technology offers different trade-offs in range, accuracy, cost, and response time.

Thermistors (NTC/PTC)

Thermistor Comparison

Temperature Resistive
PropertyNTC (Negative Temp Coeff)PTC (Positive Temp Coeff)
BehaviorResistance decreases with temperatureResistance increases with temperature
Range-55°C to +300°C-55°C to +150°C
Accuracy±0.1°C to ±1°C±1°C to ±5°C
ResponseFast (0.5–5 seconds)Moderate (1–10 seconds)
LinearityNon-linear (needs Steinhart-Hart)Highly non-linear, sharp transition
Use CasesPrecision measurement, battery packsOvercurrent protection, self-regulating heaters
#!/usr/bin/env python3
"""NTC Thermistor reading with Steinhart-Hart equation"""

import math

# Steinhart-Hart coefficients for 10k NTC (Murata NCP18XH103F03RB)
A = 1.009249e-3
B = 2.378405e-4
C = 2.019202e-7

def ntc_resistance_to_temp(resistance_ohms):
    """Convert NTC resistance to temperature using Steinhart-Hart"""
    ln_r = math.log(resistance_ohms)
    t_kelvin = 1.0 / (A + B * ln_r + C * ln_r**3)
    return t_kelvin - 273.15

# Simulate voltage divider readings
V_REF = 3.3
R_FIXED = 10000  # 10k pullup resistor

adc_readings = [2048, 2500, 3000, 3500, 3800]  # 12-bit ADC values
for raw in adc_readings:
    voltage = raw * (V_REF / 4095)
    r_ntc = R_FIXED * (V_REF / voltage - 1.0)
    temp = ntc_resistance_to_temp(r_ntc)
    print(f"ADC={raw:4d}, V={voltage:.3f}V, R={r_ntc:.0f}Ω, T={temp:.1f}°C")

Thermocouples

Thermocouples exploit the Seebeck effect: when two dissimilar metals are joined and exposed to a temperature gradient, a voltage is generated proportional to the temperature difference. They cover the widest range of any temperature sensor.

Common Thermocouple Types

TypeMaterialsRangeSensitivityApplication
KChromel-Alumel-200 to +1260°C~41 µV/°CGeneral purpose (most common)
JIron-Constantan-200 to +760°C~52 µV/°CNon-oxidizing environments
TCopper-Constantan-200 to +370°C~43 µV/°CCryogenics, food processing
SPt-Rh / Pt0 to +1600°C~7 µV/°CHigh-temp precision, furnaces
Cold Junction Compensation: Thermocouples measure the difference between the hot junction (measurement point) and the cold junction (where wires connect to the circuit). The cold junction temperature must be measured independently (e.g., with a thermistor on the MAX31855 breakout) and compensated in software.

RTDs & IC Temperature Sensors

RTDs (Resistance Temperature Detectors) use the predictable change in metal resistance with temperature. Platinum RTDs (Pt100, Pt1000) are the gold standard for industrial precision.

IC Temperature Sensors integrate the sensing element and signal conditioning on one chip:
  • LM35: 10 mV/°C analog output, 0–100°C, ±0.5°C accuracy
  • DS18B20: Digital 1-Wire protocol, -55 to +125°C, ±0.5°C, 12-bit
  • TMP36: Analog, -40 to +125°C, 750 mV at 25°C baseline
  • BME280: Combo sensor (temp + humidity + pressure), I2C/SPI, ±1°C

Pressure Sensors

Gauge, Absolute & Differential

Pressure Measurement Types

TypeReferenceMeasuresExample
GaugeAtmospheric pressurePressure relative to ambientTire pressure sensor
AbsolutePerfect vacuumTotal pressure including atmosphericAltimeter (BMP280)
DifferentialAnother pressure portDifference between two pressuresAirflow measurement (Pitot tube)

Sensing Technologies

Pressure Sensing Technologies:
  • Piezoresistive (MEMS): Strain gauges on silicon diaphragm — most common in embedded (BMP280, MPX5010)
  • Capacitive: Diaphragm deflection changes capacitance — high accuracy, corrosion resistant
  • Piezoelectric: Dynamic pressure only (vibration, blast waves) — cannot measure static pressure
  • Optical: Fiber Bragg gratings, Fabry-Pérot — immune to EMI, explosive environments
#!/usr/bin/env python3
"""Read BMP280 pressure/altitude sensor via I2C"""

import smbus2
import time

BMP280_ADDR = 0x76
bus = smbus2.SMBus(1)

# Read calibration data (trimming parameters)
cal = bus.read_i2c_block_data(BMP280_ADDR, 0x88, 26)
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

# Configure: normal mode, 16x oversampling
bus.write_byte_data(BMP280_ADDR, 0xF4, 0x57)  # osrs_t=2, osrs_p=5, mode=3
bus.write_byte_data(BMP280_ADDR, 0xF5, 0x00)  # Filter off, standby 0.5ms

time.sleep(0.1)

# Read raw temperature
data = bus.read_i2c_block_data(BMP280_ADDR, 0xFA, 3)
raw_temp = (data[0] << 12) | (data[1] << 4) | (data[2] >> 4)

# Compensate temperature (from BMP280 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
print(f"Temperature: {temp_c:.2f}°C")

bus.close()

Proximity Sensors

Ultrasonic (HC-SR04)

The HC-SR04 emits 40 kHz ultrasonic pulses and measures the time for the echo to return. Distance is calculated from the speed of sound (~343 m/s at 20°C).

// Ultrasonic HC-SR04 distance measurement (STM32)
#include "stm32f4xx.h"

#define TRIG_PIN  GPIO_PIN_0   // PA0
#define ECHO_PIN  GPIO_PIN_1   // PA1

void ultrasonic_init(void) {
    RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;

    // PA0 (Trigger) = output
    GPIOA->MODER &= ~(3U << 0);
    GPIOA->MODER |=  (1U << 0);

    // PA1 (Echo) = input
    GPIOA->MODER &= ~(3U << 2);
}

float measure_distance_cm(void) {
    // Send 10us trigger pulse
    GPIOA->BSRR = (1U << 0);          // PA0 HIGH
    for (volatile int i = 0; i < 168; i++);  // ~10us at 168 MHz
    GPIOA->BSRR = (1U << 16);         // PA0 LOW

    // Wait for echo to go HIGH
    while (!(GPIOA->IDR & (1U << 1)));
    uint32_t start = DWT->CYCCNT;

    // Wait for echo to go LOW
    while (GPIOA->IDR & (1U << 1));
    uint32_t end = DWT->CYCCNT;

    // Calculate distance
    float pulse_us = (float)(end - start) / 168.0f;  // 168 MHz clock
    float distance_cm = (pulse_us * 0.0343f) / 2.0f;
    return distance_cm;
}

Infrared Proximity

IR Proximity Sensors:
  • SHARP GP2Y0A21YK: Analog output, 10–80 cm range, triangulation method
  • VCNL4010: I2C digital, 0–20 cm, includes ambient light sensor
  • VL53L0X: Time-of-Flight (ToF) laser, 0–200 cm, ±3% accuracy, I2C
  • VL53L1X: Extended range ToF, up to 400 cm, multi-zone detection

Capacitive & Inductive

Capacitive proximity sensors detect any material (metal, plastic, liquid, human body) by measuring changes in capacitance. Inductive sensors detect only metal objects by monitoring eddy current changes in an oscillating magnetic field.

Motion & Inertial Sensors

Accelerometers

MEMS accelerometers measure acceleration along one or more axes using a proof mass suspended by spring-like structures. When acceleration occurs, the proof mass deflects, changing the capacitance between fixed and movable electrodes.

Common Accelerometer ICs

PartAxesRangeInterfaceFeatures
ADXL3453±2/4/8/16gI2C/SPITap detection, free-fall, low power
LIS3DH3±2/4/8/16gI2C/SPIFIFO buffer, click detection, aux ADC
MPU60503 accel + 3 gyro±2/4/8/16gI2C6-DOF IMU, DMP, temperature
ICM-209483+3+3±2/4/8/16gI2C/SPI9-DOF, magnetometer, DMP

Gyroscopes

MEMS gyroscopes measure angular velocity (rate of rotation) using the Coriolis effect. A vibrating proof mass experiences a perpendicular force when rotated, which is detected as a capacitance change.

IMU (6/9-DOF)

#!/usr/bin/env python3
"""Read MPU6050 6-DOF IMU via I2C"""

import smbus2
import time
import math

MPU6050_ADDR = 0x68
bus = smbus2.SMBus(1)

# Wake up MPU6050 (clear sleep bit)
bus.write_byte_data(MPU6050_ADDR, 0x6B, 0x00)

# Configure: ±2g accel, ±250°/s gyro
bus.write_byte_data(MPU6050_ADDR, 0x1C, 0x00)  # Accel ±2g
bus.write_byte_data(MPU6050_ADDR, 0x1B, 0x00)  # Gyro ±250°/s

def read_raw(addr):
    """Read signed 16-bit value from two consecutive registers"""
    high = bus.read_byte_data(MPU6050_ADDR, addr)
    low = bus.read_byte_data(MPU6050_ADDR, addr + 1)
    value = (high << 8) | low
    return value - 65536 if value > 32767 else value

# Read 10 samples
for i in range(10):
    # Read accelerometer (registers 0x3B-0x40)
    ax = read_raw(0x3B) / 16384.0  # ±2g scale: 16384 LSB/g
    ay = read_raw(0x3D) / 16384.0
    az = read_raw(0x3F) / 16384.0

    # Read gyroscope (registers 0x43-0x48)
    gx = read_raw(0x43) / 131.0    # ±250°/s scale: 131 LSB/°/s
    gy = read_raw(0x45) / 131.0
    gz = read_raw(0x47) / 131.0

    # Calculate tilt angles from accelerometer
    roll  = math.atan2(ay, az) * 180.0 / math.pi
    pitch = math.atan2(-ax, math.sqrt(ay*ay + az*az)) * 180.0 / math.pi

    print(f"Accel: ({ax:.2f}, {ay:.2f}, {az:.2f})g  "
          f"Gyro: ({gx:.1f}, {gy:.1f}, {gz:.1f})°/s  "
          f"Roll: {roll:.1f}° Pitch: {pitch:.1f}°")
    time.sleep(0.5)

bus.close()

Light & Optical Sensors

Photodiodes & Phototransistors

Photosensor Types:
  • LDR (Photoresistor): Resistance decreases with light intensity. Simple, cheap, slow (10–100ms). Good for day/night detection
  • Photodiode: Generates current proportional to light. Fast response (<1µs). Two modes: photovoltaic (no bias) and photoconductive (reverse biased)
  • Phototransistor: Photodiode + transistor amplification. Higher sensitivity but slower than photodiode
  • Photoelectric: Through-beam, retroreflective, or diffuse. Used in industrial object detection

Ambient Light & Color Sensors

Digital ambient light sensors like the BH1750 (I2C, 1–65535 lux) and TSL2561 (I2C, 0.1–40000 lux, IR + visible channels) provide calibrated lux readings. Color sensors like the TCS34725 measure RGBC (Red, Green, Blue, Clear) channels for color detection and white balance correction.

#!/usr/bin/env python3
"""Read BH1750 ambient light sensor via I2C"""

import smbus2
import time

BH1750_ADDR = 0x23
bus = smbus2.SMBus(1)

# Power on the sensor
bus.write_byte(BH1750_ADDR, 0x01)
time.sleep(0.01)

# Set continuous high-resolution mode (1 lux resolution)
bus.write_byte(BH1750_ADDR, 0x10)
time.sleep(0.2)  # Measurement time: 120ms

# Read 2 bytes of light data
data = bus.read_i2c_block_data(BH1750_ADDR, 0x10, 2)
lux = (data[0] << 8 | data[1]) / 1.2
print(f"Light intensity: {lux:.1f} lux")

# Categorize light level
if lux < 10:
    print("Darkness / Night")
elif lux < 100:
    print("Dim lighting / Twilight")
elif lux < 1000:
    print("Indoor lighting")
elif lux < 10000:
    print("Overcast daylight")
else:
    print("Direct sunlight")

bus.close()

Environmental Sensors

Humidity Sensors

Capacitive humidity sensors (most common) use a hygroscopic polymer that absorbs water vapor, changing the dielectric constant and thus capacitance. Resistive types measure conductivity changes in a hygroscopic salt layer.

Popular Humidity Sensors

SensorInterfaceRH RangeAccuracyFeatures
DHT111-Wire (custom)20–80%±5%Cheapest, 1Hz sampling
DHT221-Wire (custom)0–100%±2–5%Better range and accuracy
BME280I2C/SPI0–100%±3%Combo (T + H + P)
SHT31I2C0–100%±2%High accuracy, alert output

Gas & Air Quality Sensors

Gas Sensor Technologies:
  • MQ Series (MQ-2, MQ-7, MQ-135): Metal-oxide semiconductor (MOS). Analog output. Requires 24-48hr burn-in. Detects CO, CH4, alcohol, smoke, NH3
  • CCS811: I2C, eCO2 (400–8192 ppm) and TVOC (0–1187 ppb). Factory-calibrated
  • SGP30: I2C, eCO2 + TVOC. On-chip humidity compensation
  • BME688: AI-enabled gas sensor (T+H+P+Gas). Pattern recognition for VOC classification

Position & Displacement Sensors

Rotary Encoders

Incremental encoders output quadrature pulse trains (A and B channels 90° out of phase) that indicate direction and speed. Absolute encoders output a unique digital code for each angular position using Gray code or binary patterns.

// Quadrature encoder reading with STM32 timer
#include "stm32f4xx.h"

void encoder_init(void) {
    // Enable clocks
    RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
    RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;

    // PA0 = TIM2_CH1, PA1 = TIM2_CH2 (AF1)
    GPIOA->MODER  |= (2U << 0) | (2U << 2);
    GPIOA->AFR[0] |= (1U << 0) | (1U << 4);

    // Configure TIM2 as quadrature encoder
    TIM2->SMCR = TIM_SMCR_SMS_0 | TIM_SMCR_SMS_1;  // Encoder mode 3
    TIM2->CCMR1 = TIM_CCMR1_CC1S_0 | TIM_CCMR1_CC2S_0;
    TIM2->CCER  = 0;                        // Rising edges
    TIM2->ARR   = 0xFFFFFFFF;               // Full range
    TIM2->CNT   = 0x80000000;               // Start at midpoint

    TIM2->CR1 |= TIM_CR1_CEN;               // Start counter
}

int32_t encoder_get_count(void) {
    return (int32_t)TIM2->CNT - 0x80000000;
}

float encoder_get_angle(int pulses_per_rev) {
    int32_t count = encoder_get_count();
    return (float)count * 360.0f / (float)(pulses_per_rev * 4);
}

LVDT & Potentiometers

An LVDT (Linear Variable Differential Transformer) measures linear displacement with virtually infinite resolution and no contact friction. It uses three coils (one primary, two secondary) — as the ferromagnetic core moves, the voltage difference between secondaries varies linearly with position.

Linear potentiometers are simpler — a resistive strip with a slider provides an analog voltage proportional to position. They have limited lifespan due to mechanical wear.

Biomedical Sensors

Biomedical Sensor Categories

Medical Wearable
SensorMeasuresTechnologyExample IC
Pulse OximeterSpO2, heart ratePhotoplethysmography (PPG)MAX30102
ECGHeart electrical activityBiopotential electrodesAD8232
EMGMuscle electrical signalsSurface electrodesMyoWare 2.0
TemperatureBody temperatureIR thermopileMLX90614
GSRSkin conductance (stress)Resistance measurementGrove GSR
Force/PressureTouch, weight, gaitFSR (Force Sensitive Resistor)Interlink FSR 402
FingerprintBiometric identityOptical/capacitive imagingR305

Magnetic Sensors (Hall Effect)

Hall effect sensors detect magnetic fields and convert them into a voltage proportional to field strength. They exploit the Lorentz force on charge carriers in a semiconductor — when a magnetic field perpendicular to current flow deflects electrons, a measurable Hall voltage appears across the sensor.

Hall Effect Sensor Comparison

Magnetic Position
SensorTypeOutputSensitivityUse Cases
A3144Unipolar switchDigital (open-drain)Latches at ∼10 mTDoor/window sensors, motor speed, bicycle speedometers
SS49ELinear (analog)Analog voltage∼1.4 mV/GaussJoystick position, current measurement, precision displacement
DRV5055Linear (ratiometric)Analog voltage21–100 mV/mTMotor commutation, BLDC position feedback
AH3503LinearAnalog voltage∼1.3 mV/GaussProximity detection, gauss meters
Switch vs. Linear: Digital (switch) Hall sensors like the A3144 output HIGH/LOW when a magnet is near — ideal for RPM counting and presence detection. Linear Hall sensors like the SS49E output a voltage proportional to field strength — useful for measuring exact distance or current.
// A3144 Hall Effect switch — detect magnet proximity on STM32
#include "stm32f4xx.h"
#include <stdio.h>

// A3144 wiring: VCC → 3.3V, GND → GND, OUT → PA0 (with 10k pull-up)
void hall_init(void) {
    RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
    GPIOA->MODER &= ~(3U << 0);       // PA0 input mode
    GPIOA->PUPDR |= (1U << 0);        // Pull-up (A3144 is open-drain)
}

int hall_is_magnet_present(void) {
    // A3144 pulls output LOW when south-pole magnet detected
    return !(GPIOA->IDR & (1U << 0));
}

int main(void) {
    hall_init();
    while (1) {
        if (hall_is_magnet_present()) {
            printf("Magnet detected!\n");
        } else {
            printf("No magnet\n");
        }
        for (volatile int i = 0; i < 500000; i++);
    }
}

Touch & Capacitive Sensors

Capacitive touch sensors detect the presence of a finger by measuring changes in capacitance. The human body acts as a conductive plate — when a finger approaches the sensor electrode, parasitic capacitance increases by 5–20 pF, which a charge-transfer or sigma-delta circuit can reliably detect.

Touch Sensor Modules

Touch Capacitive
ModuleChannelsInterfaceFeaturesUse Cases
TTP2231Digital outputToggle/momentary mode, adjustable sensitivityTouch buttons, lamp switches
MPR12112I2CProximity detection, auto-calibrationTouch keypads, interactive panels
CAP11888I2C/SPILED driver built-in, multi-touchControl panels, consumer electronics
AT42QT10101Digital outputSelf-calibration, moisture rejectionIndustrial touch buttons
// TTP223 capacitive touch — simple digital read on Arduino
#include <Arduino.h>

#define TOUCH_PIN  2   // TTP223 SIG → Digital pin 2
#define LED_PIN   13   // On-board LED

void setup() {
    Serial.begin(115200);
    pinMode(TOUCH_PIN, INPUT);
    pinMode(LED_PIN, OUTPUT);
    Serial.println("TTP223 Touch Sensor Ready");
}

void loop() {
    int touched = digitalRead(TOUCH_PIN);
    digitalWrite(LED_PIN, touched);

    if (touched) {
        Serial.println("Touch detected!");
    }
    delay(100);  // Simple debounce
}

Current & Voltage Sensors

Measuring electrical current and voltage is critical for power monitoring, battery management, motor control, and energy metering. Two main approaches exist: shunt-based (resistive) and Hall-effect (non-contact).

Current & Voltage Sensor Modules

Power Monitoring
SensorMeasuresRangeOutputNotes
ACS712 (5A)AC/DC Current±5AAnalog (185 mV/A)Hall-effect, galvanic isolation, bidirectional
ACS712 (20A)AC/DC Current±20AAnalog (100 mV/A)Ideal for motor monitoring
ACS712 (30A)AC/DC Current±30AAnalog (66 mV/A)High-power applications
INA219Current + Voltage0–26V, ±3.2AI2C (digital)High-side shunt, 12-bit ADC
ZMPT101BAC Voltage0–250V ACAnalogVoltage transformer, galvanic isolation
// ACS712 current sensor — read AC/DC current on Arduino
#include <Arduino.h>

#define ACS712_PIN    A0
#define SENSITIVITY   0.185   // 185 mV/A for 5A variant
#define V_REF         5.0
#define ADC_MAX       1023.0
#define V_OFFSET      2.5     // Zero-current output = VCC/2

void setup() {
    Serial.begin(115200);
    Serial.println("ACS712 Current Sensor Ready");
}

void loop() {
    // Average multiple samples to reduce noise
    float sum = 0;
    for (int i = 0; i < 100; i++) {
        sum += analogRead(ACS712_PIN);
        delayMicroseconds(200);
    }
    float avg_raw = sum / 100.0;

    float voltage = avg_raw * (V_REF / ADC_MAX);
    float current = (voltage - V_OFFSET) / SENSITIVITY;

    Serial.print("Voltage: "); Serial.print(voltage, 3); Serial.print(" V, ");
    Serial.print("Current: "); Serial.print(current, 3); Serial.println(" A");
    delay(500);
}

Color Sensors

Color sensors measure the spectral composition of reflected or transmitted light using arrays of photodiodes with color filters (red, green, blue, and sometimes clear/IR). They enable automated quality control, color matching, and sorting in industrial and consumer applications.

Color Sensor Modules

Color Optical
SensorInterfaceChannelsFeaturesUse Cases
TCS3200Frequency outputRGB + Clear8×8 photodiode array, selectable filterColor sorting, display calibration
TCS34725I2CRGBC (16-bit)IR blocking filter, gain control, built-in LEDAmbient light color, product inspection
VEML6040I2CRGBW16-bit, low power (0.2 mA)Wearable light monitoring
// TCS3200 color sensor — read RGB frequency on Arduino
#include <Arduino.h>

#define S0  4   // Frequency scaling
#define S1  5
#define S2  6   // Filter selection
#define S3  7
#define OUT 8   // Frequency output

void setup() {
    Serial.begin(115200);
    pinMode(S0, OUTPUT); pinMode(S1, OUTPUT);
    pinMode(S2, OUTPUT); pinMode(S3, OUTPUT);
    pinMode(OUT, INPUT);

    // Set frequency scaling to 20%
    digitalWrite(S0, HIGH);
    digitalWrite(S1, LOW);
    Serial.println("TCS3200 Color Sensor Ready");
}

unsigned long readColor(int s2_val, int s3_val) {
    digitalWrite(S2, s2_val);
    digitalWrite(S3, s3_val);
    delay(20);  // Allow filter to settle
    return pulseIn(OUT, LOW);  // Lower period = more light
}

void loop() {
    unsigned long red   = readColor(LOW,  LOW);   // Red filter
    unsigned long green = readColor(HIGH, HIGH);   // Green filter
    unsigned long blue  = readColor(LOW,  HIGH);   // Blue filter

    Serial.print("R="); Serial.print(red);
    Serial.print(" G="); Serial.print(green);
    Serial.print(" B="); Serial.println(blue);
    delay(500);
}

Sound Sensors

Sound sensors convert acoustic pressure waves into electrical signals using MEMS microphones or electret condenser capsules. Common in voice recognition, noise monitoring, and event-triggered applications (clap switches, alarms).

Sound Sensor Modules

Audio Acoustic
ModuleTypeOutputFeaturesUse Cases
MAX9814Electret + AGC amplifierAnalogAuto gain control (40/50/60 dB), low noiseVoice recording, audio capture
MAX4466Electret + ampAnalogAdjustable gain (25–125×)Sound level metering
INMP441MEMS (digital)I2S24-bit, 61 dB SNRDigital audio, speech recognition
KY-037Electret + comparatorDigital + AnalogThreshold-triggered digital outputClap switches, noise detection
// MAX9814 sound level meter — read peak amplitude on Arduino
#include <Arduino.h>

#define MIC_PIN  A0
#define SAMPLE_WINDOW 50  // 50ms sample window

void setup() {
    Serial.begin(115200);
    Serial.println("MAX9814 Sound Level Meter");
}

void loop() {
    unsigned long start = millis();
    int peak_to_peak = 0;
    int sig_max = 0;
    int sig_min = 1023;

    // Collect samples over the window
    while (millis() - start < SAMPLE_WINDOW) {
        int sample = analogRead(MIC_PIN);
        if (sample > sig_max) sig_max = sample;
        if (sample < sig_min) sig_min = sample;
    }

    peak_to_peak = sig_max - sig_min;
    float voltage = peak_to_peak * (3.3 / 1023.0);

    Serial.print("Peak-to-Peak: ");
    Serial.print(voltage, 3);
    Serial.println(" V");
    delay(100);
}

RFID & NFC Sensors

Radio-Frequency Identification (RFID) and Near-Field Communication (NFC) use electromagnetic coupling to read data from passive tags. RFID operates at 125 kHz (LF) or 13.56 MHz (HF), while NFC is a subset of HF RFID with peer-to-peer capability.

RFID & NFC Modules

Wireless Identification
ModuleFrequencyInterfaceRangeUse Cases
RC522 (MFRC522)13.56 MHz (RFID)SPI~5 cmAccess control, attendance systems, inventory
PN53213.56 MHz (NFC+RFID)I2C/SPI/UART~10 cmPayment systems, NFC tag read/write, phone pairing
RDM6300125 kHz (LF RFID)UART~5 cmAnimal tracking, simple access cards
// MFRC522 (RC522) RFID reader — read tag UID on Arduino
#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN   10  // SDA/CS
#define RST_PIN   9  // Reset

MFRC522 rfid(SS_PIN, RST_PIN);

void setup() {
    Serial.begin(115200);
    SPI.begin();
    rfid.PCD_Init();
    Serial.println("RC522 RFID Reader Ready — present a tag");
}

void loop() {
    // Check for new card
    if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) {
        return;
    }

    // Print UID
    Serial.print("Tag UID: ");
    for (byte i = 0; i < rfid.uid.size; i++) {
        if (rfid.uid.uidByte[i] < 0x10) Serial.print("0");
        Serial.print(rfid.uid.uidByte[i], HEX);
        Serial.print(" ");
    }
    Serial.println();

    // Print tag type
    MFRC522::PICC_Type type = rfid.PICC_GetType(rfid.uid.sak);
    Serial.print("Tag type: ");
    Serial.println(rfid.PICC_GetTypeName(type));

    rfid.PICC_HaltA();
    rfid.PCD_StopCrypto1();
    delay(1000);
}

Conclusion & Next Steps

This survey covered the major sensor families used in embedded systems — from simple thermistors to complex IMUs, biomedical sensors, Hall effect switches, capacitive touch, current/voltage monitors, color detectors, sound sensors, and RFID/NFC modules. The key to selecting the right sensor is matching its characteristics (range, accuracy, response time, interface) to your application requirements.

Key Takeaways:
  • Temperature sensors range from cheap NTC thermistors to precision RTDs and thermocouples
  • Pressure sensors come in gauge, absolute, and differential variants
  • MEMS accelerometers and gyroscopes enable motion sensing in compact packages
  • Environmental sensors now integrate temperature, humidity, pressure, and gas in single chips
  • Biomedical sensors enable wearable health monitoring with PPG, ECG, and SpO2
  • Hall effect sensors provide non-contact magnetic field detection for speed and position
  • Capacitive touch sensors like TTP223 enable button-free user interfaces
  • Current/voltage sensors (ACS712, ZMPT101B) enable power monitoring and battery management
  • RFID (RC522) and NFC (PN532) enable wireless identification and payment systems

In Part 4, we explore Signal Conditioning & Data Acquisition — op-amp circuits, filters, ADC architectures, and digital communication protocols (I2C, SPI, UART, CAN).