forked from pimoroni/enviroplus-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
🔬 Sensor Calibration, Accuracy Validation & Compensation Algorithms
Problem
Raw sensor readings from the Enviro+ hat have known biases and limitations:
- BME280 temperature reads ~5-8°C high due to CPU/board heat proximity
- MICS-6814 gas readings are in resistance (kΩ), not calibrated to concentration (ppm)
- PMS5003 accuracy degrades over time without cleaning/verification
- ICS-43432 noise dB values need reference calibration against a certified meter
- No cross-validation against external reference stations
Goal
Implement software compensation algorithms and establish calibration protocols to maximize measurement accuracy for industrial-grade environmental monitoring.
Proposed Improvements
BME280 Temperature Compensation
- CPU heat offset — measure delta between BME280 and reference thermometer, apply linear correction
- Dynamic compensation — factor based on CPU temperature (higher CPU = more offset)
- Running average — smooth temperature readings over 30-second window
- Humidity correction — BME280 humidity accuracy degrades above 80% RH
# Temperature compensation formula
# Measured offset: ~5.5°C at idle, ~7.2°C under load
def compensate_temperature(raw_temp, cpu_temp):
# Factor derived from empirical measurement
factor = max(0, (cpu_temp - 40) * 0.05)
offset = 5.5 + factor
return raw_temp - offsetMICS-6814 Gas Calibration
- Baseline resistance — measure clean-air reference values after 48h burn-in
- Rs/Ro ratio calculation — convert kΩ to ratio against clean-air baseline
- Approximate ppm estimation — use datasheet sensitivity curves for NO2, CO, NH3
- Temperature/humidity correction — gas sensor sensitivity varies with ambient conditions
- Document limitations — MICS-6814 is qualitative, not certified for regulatory compliance
| Gas | Clean Air (Ro) | Alarm Ratio | Approximate ppm |
|---|---|---|---|
| NO2 (oxidising) | ~2-20 kΩ | Rs/Ro > 2.0 | ~0.5 ppm |
| CO (reducing) | ~100-500 kΩ | Rs/Ro < 0.3 | ~50 ppm |
| NH3 | ~200-800 kΩ | Rs/Ro > 2.5 | ~25 ppm |
PMS5003 Accuracy Maintenance
- Periodic zero-check — cover intake, verify readings drop to 0-2 µg/m³
- Cross-reference — compare with nearby government AQI stations (SIMA Monterrey)
- Sensor aging log — track baseline drift over months
- Cleaning schedule — compressed air every 6 months per Plantower recommendation
- Humidity correction — PM readings inflate above 85% RH (hygroscopic growth)
# Humidity correction for PM readings (EPA recommendation)
def correct_pm_humidity(pm_raw, humidity):
if humidity > 85:
# Reduce by estimated hygroscopic factor
correction = 1.0 + 0.25 * ((humidity - 85) / 15)
return pm_raw / correction
return pm_rawICS-43432 Noise Calibration
- Reference calibration — compare against certified SPL meter at 3 points (40, 70, 94 dB)
- A-weighting filter — apply frequency weighting curve for human-relevant dB(A)
- Frequency band validation — verify low/mid/high split accuracy
- Background noise floor — characterize minimum detectable level
Cross-Validation with External Data
- SIMA Monterrey API — fetch government air quality data for Monterrey metro
- OpenWeatherMap comparison — cross-check temperature, humidity, pressure
- Automated drift detection — alert if readings consistently deviate >15% from references
- Calibration dashboard page — show sensor health and accuracy metrics
Calibration Protocol Document
Create docs/CALIBRATION.md with:
- Step-by-step calibration procedure for each sensor
- Required equipment (reference thermometer, SPL meter, clean air environment)
- Calibration schedule (monthly temperature, quarterly PM, annual gas)
- Data recording templates for calibration sessions
- Compensation formula documentation with derivation notes
Implementation Priority
- BME280 temperature offset (immediate — biggest impact, simplest fix)
- PMS5003 humidity correction (quick win for rainy season accuracy)
- MICS-6814 baseline + ratio (moderate effort, significant data quality improvement)
- Noise reference calibration (requires physical calibration session)
- External cross-validation (API integration, ongoing monitoring)
Monterrey-Specific Considerations
- High summer temperatures (35-42°C) — CPU heat compensation critical
- Rainy season humidity (70-95% RH) — PM humidity correction essential
- Industrial zone proximity — gas baseline may be elevated vs rural clean air
- Altitude ~540m — pressure readings need no sea-level correction for local use
Ref: #1 Roadmap — Data Quality & Calibration
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels