Picking a measurement interval
I wanted a quick way to tell when opening the window might help. I put an SCD41 sensor and an ESP32 in a vented enclosure, then logged a sample every 30 seconds. That was enough to follow changes across a morning without filling the log with near-identical readings.
The first enclosure had the sensor sitting directly above the voltage regulator. Moving the sensor closer to the vents and away from the regulator reduced the temperature drift I saw after powering up the board.
Handling interrupted samples
The dashboard reads timestamped measurements from a local log. I kept the parser small enough to check by eye and let it skip an incomplete final line if power is cut while the board is writing.
function parseSample(line: string) {
const [timestamp, reading] = line.trim().split(",", 2);
if (!timestamp || !reading?.trim()) return null;
const recordedAt = Date.parse(timestamp);
const ppm = Number(reading);
if (!Number.isFinite(recordedAt) || !Number.isFinite(ppm) || ppm <= 0) {
return null;
}
return { recordedAt, ppm };
}
What I would change
The USB cable made the whole enclosure move whenever I plugged it in. For the next revision I’d add a slot for cable strain relief before printing the lid again.
Comments
Share a thought about this project. Comments appear after approval.
Loading comments…