Low-cost particulate sensors made projects like Vayu possible. They also produce numbers that can be badly wrong if you take them at face value. Calibration is the difference between a toy and a dataset.
Why the raw numbers drift
Most low-cost PM sensors are optical particle counters: a laser scatters off particles and a photodiode counts the flashes. Then firmware converts counts into mass concentration using assumptions about particle density and shape.
Problems:
- Humidity. Particles absorb water and swell. Above roughly 70–80% relative humidity, readings can rise sharply. Reference monitors typically dry the sample first.
- Particle type. Dust, smoke, and traffic particles scatter light differently. The firmware's assumptions fit some better than others.
- Unit-to-unit variation. Two sensors of the same model can disagree.
- Ageing. Optics get dirty and fans slow down.
Step 1: Co-locate
Put your sensors next to a reference-grade or equivalent-method monitor, typically run by a government agency or research institution. Same height, same air.
Record at least:
- Your sensor's PM2.5 (raw)
- Temperature and relative humidity (from your own sensor)
- The reference PM2.5
- Timestamps, aligned to the same averaging period (often hourly)
Step 2: Fit a correction
Start simple. A multiple linear regression often does most of the work:
PM_corrected = a × PM_raw + b × RH + c
The US EPA developed a widely used correction of this form for PurpleAir sensors, published in the research literature. It's a good reference point for the approach.
import pandas as pd from sklearn.linear_model import LinearRegression df = pd.read_csv("colocation_hourly.csv").dropna() X = df[["pm25_raw", "rh"]] y = df["pm25_reference"] model = LinearRegression().fit(X, y) print(model.coef_, model.intercept_)
If linear isn't enough (strong non-linearity at high humidity), try:
- Adding a non-linear humidity term (e.g. based on hygroscopic growth)
- Gradient boosting with PM, RH, and temperature as features
Keep it as simple as works. Complex models overfit short co-location periods.
Step 3: Validate honestly
- Hold out time, not random rows. Train on the first weeks, test on later weeks.
- Report R², RMSE, and mean bias, not just R².
- Check performance by humidity band and by pollution level. A model can look good on average and fail on the worst days, which are the days that matter.
Step 4: Deploy and re-check
- Store raw and corrected values separately. You'll want to recalibrate later.
- Re-co-locate periodically, or rotate one sensor back to the reference site.
- Flag readings taken at very high humidity as lower confidence.
Communicating uncertainty
On the public dashboard, say plainly that these are low-cost sensors with calibration. Show categories as well as exact numbers. Trust grows when you're honest about limits.