Chapter 7 — The Sensor Dictionary: DHT, MLX, and What to Buy First
There are hundreds of sensor types. These are the ones that appear repeatedly in real IoT projects — cheap, well-documented, and reliably supported by MicroPython and Arduino libraries.
Temperature and Humidity
DHT22 (also called AM2302): the workhorse. Measures temperature (-40 to +80°C) and relative humidity (0–100%). Single-wire protocol. One sensor, three pins (VCC, GND, DATA). Accuracy: ±0.5°C temperature, ±2–5% humidity. Update interval: minimum 2 seconds.
DHT11: cheaper, less accurate (±2°C, ±5% humidity), narrower range (0–50°C). Use it for learning and non-critical monitoring. Use the DHT22 for anything you care about.
Both sensors are susceptible to condensation. Don’t use them in environments where humidity regularly hits 100% — the readings will drift and eventually the sensor will fail.
Infrared (Non-Contact) Temperature
MLX90614: measures surface temperature remotely, without contact. Useful for measuring the temperature of leaves (plants), water surfaces, radiators, or human skin. I2C interface. Range: -70 to +380°C. Accuracy: ±0.5°C in the 0–50°C range.
For plant monitoring, the MLX90614 complements the DHT22: the DHT22 measures air temperature and humidity, the MLX90614 measures leaf surface temperature. The difference between the two is an input to VPD (Vapour Pressure Deficit) calculations — covered in Chapter 13.


Soil Moisture
Capacitive soil moisture sensors (generic, ~€2 each) measure the dielectric constant of soil, which correlates with moisture content. They don’t corrode like resistive sensors. They need calibration: take a reading in bone-dry soil (0% moisture baseline) and in fully saturated soil (100% baseline). Everything in between is interpolated.
CO2 and Air Quality
MH-Z19 (CO2, UART or PWM): measures actual CO2 concentration in ppm. Accurate, self-calibrating, ~€20. Useful for indoor air quality monitoring.
SGP30 (TVOC and eCO2, I2C): measures volatile organic compounds and estimated CO2. Less accurate than the MH-Z19 for CO2, but adds TVOC measurement. Cheaper (~€8).
The Bill of Materials for a Starting Kit
If you’re building your first IoT setup and want to cover the most common projects:
| Sensor | Qty | Price (approx.) | Use |
|---|---|---|---|
| DHT22 | 3 | €5 total | Temperature + humidity, multiple rooms |
| MLX90614 | 1 | €8 | Non-contact surface temperature |
| Capacitive moisture | 3 | €6 total | Soil monitoring |
| Tapo P110 | 2 | €30 total | Power monitoring + smart switching |
| ESP32 (38-pin) | 2 | €10 total | Sensor nodes |
| Pico W | 2 | €12 total | Sensor nodes |
| 5W solar panel | 1 | €8 | Power for outdoor node |
| TP4056 module | 2 | €3 total | Battery charging |
| 18650 battery | 2 | €6 total | Energy storage |
Total: ~€88. Enough hardware for 5–6 meaningful projects.
How Sensors Talk: The Four Interfaces
Every sensor above uses one of four interfaces. The interface decides how many pins you spend, how many sensors share a bus, and what can go wrong.
| Interface | Wires | Sensors in this chapter | What to watch |
|---|---|---|---|
| Single-wire digital | 1 data (+ power) | DHT22, DHT11 | Strict timing; respect the 2-second minimum between reads |
| Analog | 1 signal (+ power) | Capacitive soil moisture | Needs an ADC pin and calibration; readings drift with supply voltage |
| I2C | 2 (SDA, SCL) | MLX90614, SGP30 | Many sensors on one bus, as long as their addresses differ |
| UART / SPI | 2–4 | MH-Z19 (UART) | Fast and robust, but every device costs more pins |
Two practical consequences:
- Analog on the Pico W vs ESP32: both have ADCs, but neither is precise enough to trust raw values. Always calibrate against known dry/wet points, as above. Chapter 5 compares the two boards.
- I2C scales best: a node with an MLX90614 and an SGP30 still uses only two GPIO pins. Run an I2C scan first; a sensor that doesn’t show up is usually wiring, not code.
Reading a Datasheet: What Matters
Before buying a sensor you haven’t used, check these lines on its datasheet:
- Accuracy and range at the conditions you’ll actually measure (accuracy is often specified for a narrower band than the full range, like the MLX90614’s ±0.5°C only for 0–50°C).
- Minimum sampling interval and response time.
- Operating temperature and humidity: the DHT22’s condensation problem is exactly the kind of limit that’s easy to miss.
- Supply voltage and logic level: 3.3V boards (ESP32, Pico W) and 5V sensors need a level shifter or a different sensor.
- Current draw, active and idle: this is what sets battery life on a solar node (Chapter 8).
- Interface and address, from the table above.
Takeaway: DHT22 for air. MLX90614 for surfaces. Capacitive sensors for soil. Add a solar panel and TP4056 for any outdoor node.