DHT code won't compile: two DHT libraries
- DHT11
- DHT22
You may see
Why it happens
- The sketch uses one library and the other is installed.
- The Adafruit library needs the Adafruit Unified Sensor library too.
How to fix it
- Look at the first lines.
#include <DHT.h>needs DHT sensor library by Adafruit and Adafruit Unified Sensor. #include <dht.h>needs DHTlib by Rob Tillaart.- Install the one your lesson uses. Don't mix commands from both:
dht.readTemperature()is Adafruit,DHT.read11(pin)is DHTlib.
It worked if: Verify passes.
Tutorials where it can happen
- DHT11 Temperature and Humidity Sensor with Arduino
- Air Quality and HVAC Control with Arduino, DHT11 and MQ-135
- Arduino Greenhouse: Temperature and Humidity Control with LCD
- ESP32 DHT11 Web Server: Show Temperature and Humidity
- Log DHT11 Data to Firebase Realtime Database: the Code
- Mini Weather Station with Arduino, DHT11 and 16x2 LCD
From the official documentation. Both libraries compiled here with Arduino CLI; the missing-file lines came from real runs, the other two are typical compiler wording. Sources: Adafruit DHT library, DHTlib.
Didn't help? Search another error or ask us.

