The bench
Every lesson is one Uno with the lesson's sensors wired straight to its pins: the 1-Wire and DHT parts on pin 2, the I2C modules on SDA and SCL, the PMS5003 on SoftwareSerial (pins 2 and 3, SET on 4), and a red lamp on pin 8. Drag a sensor's sliders to change the air it sees.
The course goes past Sensors and measurement, which covers a thermistor's physics, bridges, light and current, into the digital parts people build with. Take it at /learn/path/environmental-sensors on /learn.
The lessons
- DS18B20 vs the thermistor. Two probes on one wire, their 64-bit ROM codes and CRCs, resolution against conversion time (750 ms at 12 bits, 94 at 9), below freezing in two's complement, and when a thermistor is the better part.
- DHT22 timing. No library: the start pulse, the first-second rule, forty bits told apart at 50 us, the checksum, the sign bit, and a start pulse too short to answer.
- SHT31 and AHT20 on one bus. A bus scan, raw words, Sensirion's CRC-8, the AHT20's packed 20-bit numbers, the dew point, and two sensors that disagree.
- BME680 and SGP30: pressure and gas. Pressure into altitude, the hot plate against a clean-air baseline, the SGP30's warm-up, TVOC, and why CO2eq is not CO2.
- Real CO2 with an SCD41. Photoacoustic NDIR, the data-ready flag, ventilation bands, a lamp at 1000 ppm, the 5000 ppm workplace limit, and self-calibration.
- Particles with a PMS5003. The 32-byte frame and its checksum, a running average, the US EPA's 2024 AQI bands, the WHO's 2021 guideline, and sleep on the SET pin.
- Boss: a space station cabin air monitor. CO2, humidity and particles graded OK, WARN or ALARM; the worst grade on an LCD, a lamp and a buzzer.
What each sketch does
| Sketch | What it does |
|---|---|
evtemp |
Two DS18B20s on pin 2 and a thermistor on A0, with ROM codes and conversion times. |
evdht |
Reads a DHT22 by timing its pulses, with no library. |
evhumid |
An SHT31 and an AHT20 read with Wire, with CRCs and a dew point. |
evgas |
A BME680's pressure, altitude and gas, and an SGP30's TVOC and CO2eq. |
evco2 |
An SCD41's CO2 sorted into ventilation bands, with a lamp above 1000 ppm. |
evdust |
A PMS5003's frames by hand, a running PM2.5 average and the AQI bands. |
evcabin |
The cabin air monitor: SCD41, SHT31 and PMS5003 with an LCD, a lamp and a buzzer. |
The health numbers
- CO2: outdoor air is about 420 ppm. 1000 ppm is the usual sign a room needs more fresh air, and some schools aim for 800. The US workplace limit (OSHA) is 5000 ppm averaged over 8 hours.
- PM2.5: the US EPA's AQI bands (2024) for a 24-hour average are Good up to 9.0 ug/m3, Moderate to 35.4, Unhealthy for sensitive groups to 55.4, Unhealthy to 125.4, Very unhealthy to 225.4, and Hazardous above. The WHO's 2021 guidelines are 15 ug/m3 over 24 hours and 5 over a year.
- Humidity: the US EPA suggests keeping indoor humidity under 60 %, ideally 30 to 50 %, to keep mold away.
These are learning projects, not certified monitors. A room that may be dangerous needs a certified alarm.
Honest limits
- The simulated sensors report exactly what their sliders say. A real part adds its stated error (plus or minus 0.5 C for the DS18B20 and DHT22, about 2 %RH for the SHT31 and AHT20, about 50 ppm plus 5 % for the SCD41), drift over years, and the seconds it takes to follow a change.
- The BME680's and SGP30's gas readings are set directly; the real chemistry, the baseline algorithm and humidity's effect on the plates are not modeled. The SGP30's 15 s warm-up is.
- The SCD41's self-calibration and altitude compensation are explained, not modeled. The PMS5003's 30 s settling time after waking is not modeled, and its particle counts are worked out from the masses.
- The DHT22's pulse widths wobble by about 10 us because the simulated Uno samples pins every 10 us and micros() counts in 4 us steps.
Related
Light, color, UV and gesture sensors, the other Intermediate sensor course on the Uno.