electronics:components:sensors
Table of Contents
Electronics Reference: Sensors & Breakout Modules
SENSOR INTEGRATION MANDATE: Electronic sensors convert physical phenomena (temperature, acceleration, pressure, light, magnetic fields, distance) into measurable electrical signals. Always verify operating voltage (`3.3 V` vs. `5.0 V`), interface type (Analog, Digital GPIO, I2C, SPI, UART), warm-up/settling times, and environmental calibration requirements before integrating a module into a circuit or embedded system.
1. Sensor Signal Output Types
Before wiring any sensor to a microcontroller (`Arduino`, `ESP32`, `STM32`, `Raspberry Pi`), identify how it outputs measurement data:
| Output Type | Signal Characteristics | Microcontroller Pin Required | Design Considerations |
|---|
| Analog Voltage | Continuous DC voltage proportional to the measured physical quantity (e.g., `0 V – 3.3 V`) | ADC Pin (Analog-to-Digital Converter) | Susceptible to wire noise and ground bounce; keep wires short and filter with a small RC low-pass network |
| Ratiometric Analog | Output voltage scales proportionally with the sensor's supply voltage ($V_{CC}$) | ADC Pin (referenced to the same $V_{CC}$) | Power the sensor from the exact same `VREF` / `3.3 V` rail as the MCU's ADC so supply fluctuations cancel out |
| Digital Logic / Threshold | Binary `HIGH` (`1`) or `LOW` (`0`) state triggered when a preset threshold is crossed | Standard Digital GPIO (or External Interrupt) | Often uses an onboard comparator (`LM393`) and potentiometer; check whether output is active-HIGH or open-drain |
| PWM / Pulse-Width | Square wave where duty cycle or pulse duration encodes the measurement (e.g., `HC-SR04` Echo) | Digital GPIO with hardware timer / `pulseIn()` | Ensure pulse voltage matches MCU logic level (`5.0 V` echo pins require a resistor divider on `3.3 V` MCUs) |
| Serial Digital Bus | Calibrated digital registers transmitted over I2C, SPI, or UART | Hardware `SDA/SCL`, `MOSI/MISO/SCLK`, or `TX/RX` | Highest noise immunity and precision; verify whether breakout board includes onboard level shifters and pull-ups |
2. Common Sensor Families & Breakout Modules
2.1 Motion, Inertial & Orientation Sensors (IMUs)
- Accelerometers (3-Axis): Measure linear acceleration and static gravity tilt (`±2g` to `±16g`) using microscopic capacitive MEMS structures.
- Gyroscopes (3-Axis): Measure angular rotation rate (`°/sec`) via the Coriolis effect. Prone to slow zero-rate bias drift over time and temperature.
- Magnetometers (3-Axis Compass): Measure ambient magnetic flux density (`µT` or `Gauss`) to determine magnetic heading. Highly sensitive to Hard-Iron (permanent magnets, steel screws) and Soft-Iron (power traces, battery currents) distortion.
- 6-DoF & 9-DoF IMUs: Combine accelerometer + gyroscope (`6-DoF`, e.g., `MPU6050`, `ICM-42688-P`, `BMI270`) or add a magnetometer (`9-DoF`, e.g., `BNO085`, `ICM-20948`) to compute roll, pitch, and yaw via sensor fusion.
2.2 Environmental & Atmospheric Sensors
- Temperature Sensors:
- NTC Thermistors: Non-linear resistive sensors; inexpensive, require a voltage divider and Steinhart-Hart equation / lookup table.
- Digital One-Wire / I2C (`DS18B20`, `TMP117`): Factory-calibrated digital output (`±0.1°C` to `±0.5°C` accuracy); `DS18B20` requires a `4.7 kΩ` pull-up resistor on the data line.
- Thermocouples (`Type-K` + `MAX31855`): Measure extreme temperatures (`-200°C to +1350°C`) via the Seebeck effect; require a dedicated cold-junction compensation amplifier IC.
- Barometric Pressure & Altitude (`BMP280`, `BME280`, `MS5611`): Measure atmospheric pressure (`hPa` / `mbar`) to calculate relative altitude within ±10–50 cm. Keep away from direct airflow/prop-wash and sunlight, which cause false pressure/temperature spikes.
- Relative Humidity (`BME280`, `SHT31`, `DHT22`): Capacitive polymer sensors measuring `0%–100% RH`. Avoid exposing to condensing water or chemical vapors, which saturate the sensing element.
2.3 Distance, Proximity & Optical Sensors
- Ultrasonic Rangers (`HC-SR04`, `JSN-SR04T`): Emit a `40 kHz` acoustic pulse and measure echo time-of-flight (`2 cm – 400 cm`). Affected by ambient air temperature (speed of sound varies with temperature) and soft/angled sound-absorbing surfaces.
- Infrared Time-of-Flight (`VL53L0X`, `VL53L1X`, `TFmini-S`): Measure photon travel time using an eye-safe `850 nm / 940 nm` VCSEL laser (`3 cm – 12 m`). Unaffected by object color/reflectivity compared to basic IR intensity sensors, though bright direct sunlight reduces maximum outdoor range.
- Hall-Effect Sensors (`A3144`, `SS49E`): Detect magnetic fields without physical contact. Used for brushless motor commutation, wheel/propeller RPM tachometers, and non-contact limit switches.
2.4 Current, Voltage & Gas Sensors
- Shunt Current Monitors (`INA219`, `INA226`): Measure tiny voltage drop across a low-ohm precision shunt resistor (`0.1 Ω` or `2 mΩ`) to calculate bus voltage, current (`A`), and power (`W`) over I2C.
- Hall-Effect Current Sensors (`ACS712`, `ACS758`): Provide galvanic isolation between high-current DC/AC conductors (`5 A – 200 A`) and low-voltage microcontroller logic.
- Gas & Air Quality (`MQ-Series`, `SGP30`, `BME680`): Metal-oxide (MOX) heated sensors require a burn-in / warm-up period (`1–5 minutes` per power-up, or `24–48 hours` initial burn-in) before readings stabilize.
3. Breakout Module Hardware Pitfalls
Commercial hobbyist and industrial breakout boards (e.g., Adafruit, SparkFun, Waveshare, generic GY-series) often include onboard support circuitry that affects circuit integration:
- Onboard `3.3 V` LDO Regulators: Many breakout modules feature a tiny `3.3 V` regulator (`662K` / `XC6206`) on the `VIN` pin so they can be powered from `5.0 V`. If you supply `3.3 V` into `VIN`, the LDO drops ~`0.1 V – 0.3 V`, leaving the sensor undervolted at `3.0 V`. Check whether the board provides a dedicated `3V3` bypass pin.
- Duplicate I2C Pull-Up Resistors: Most I2C breakout boards include onboard `4.7 kΩ` or `10 kΩ` pull-up resistors to `3.3 V`. Connecting 4 or more breakout modules to the same I2C bus places all pull-ups in parallel, lowering total resistance below `1 kΩ` and preventing weak sensors from pulling `SDA`/`SCL` `LOW`. Desolder pull-up jumpers on extra boards when chaining multiple modules.
- Counterfeit / Cloned Sensor Chips: Low-cost generic modules (especially `BMP280` vs. `BME280` or `MPU6050`) frequently substitute remarked dies with different I2C `WHO_AM_I` device IDs or missing humidity sensors. Verify the `WHO_AM_I` register value during firmware initialization.
4. Signal Conditioning, Filtering & Calibration
4.1 Hardware & Software Noise Filtering
- RC Low-Pass Filter (Analog Sensors): Place a series resistor ($R$) and shunt ceramic capacitor ($C$) right at the microcontroller's ADC input pin to strip high-frequency motor/PWM noise ($f_c = \frac{1}{2\pi RC}$, e.g., `1 kΩ` + `100 nF` gives $f_c \approx 1.6\text{ kHz}$).
- Decoupling Capacitor (`0.1 µF`): Place a `0.1 µF` ceramic capacitor across $V_{CC}$ and `GND` directly at the sensor connector to absorb digital switching transients.
- Software Filtering: Apply an Exponential Moving Average (EMA), Median Filter (ideal for rejecting single-sample ultrasonic/LiDAR glitches), or Kalman Filter (for fusing IMU + barometer/GPS streams).
4.2 Sensor Calibration Procedures
- Two-Point Linear Calibration (Gain + Offset): Measure sensor output at two known physical reference points (e.g., `0°C` ice bath and `100°C` boiling water, or two known weights on a load cell) to compute exact slope ($m$) and offset ($b$) in $y = mx + b$.
- Gyroscope Zero-Rate Bias: Keep the sensor completely motionless for 2–3 seconds at boot while averaging 200–500 raw samples; subtract these mean offsets from all subsequent readings.
- Magnetometer Hard/Soft-Iron Calibration: Rotate the assembled device through all 3D orientations (figure-8 motion) away from metal objects to map the min/max ellipsoid sphere and center offsets (`X_offset`, `Y_offset`, `Z_offset`).
5. Sensor Integration & Bench Debugging Checklist
- [ ] Verify Supply & Logic Levels: Confirm whether sensor `VCC` and `SDA/SCL/TX/RX` pins are `3.3 V` or `5.0 V` tolerant before applying power.
- [ ] Check Pinout Order: Double-check silkscreen labels (`VCC`, `GND`, `SCL`, `SDA` vs. `GND`, `VCC`, `SCL`, `SDA`—pin order varies across manufacturers and reversing power destroys MEMS sensors instantly).
- [ ] Run Bus / Register ID Check: Verify I2C `ACK` address (`0x68`, `0x76`, etc.) and read the sensor's `WHO_AM_I` / `CHIP_ID` register before attempting to read data registers.
- [ ] Confirm Physical Axis Alignment: Tilt or move the sensor along known X, Y, and Z directions and verify the sign (`+` vs. `-`) of each axis matches your coordinate frame (NED vs. ENU).
- [ ] Isolate Mechanical Vibration & Heat: Mount IMUs and barometers away from hot voltage regulators, cooling fans, and vibrating motors (use open-cell foam over barometer ports to prevent wind/light pressure spikes).
Electronics Reference: 1. Diodes & Transistors | 2. Integrated Circuits (ICs) | 3. Communication Buses (UART, SPI & I2C) | 4. Voltage Regulators & Power Supply Design | 5. Operational Amplifiers (Op-Amps) | 6. Sensors & Breakout Modules
electronics/components/sensors.txt · Last modified: by Jon
