Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.
Compile error · C++

Fix “no matching function for call to 'DHT::DHT()'”

The DHT object was created without its pin and sensor type. The Adafruit library needs both: DHT dht(4, DHT22); — the same rule applies to most sensor classes.

All boardsUpdated 3 Nov 2026

Community draft — report a mistake

What you see

OutputOutput
RoomMonitor.ino:2:5: error: no matching function for call to 'DHT::DHT()'
 DHT dht;
     ^~~
In file included from RoomMonitor.ino:1:0:
libraries\DHT_sensor_library\DHT.h:65:3: note: candidate: DHT::DHT(uint8_t, uint8_t, uint8_t)
   DHT(uint8_t pin, uint8_t type, uint8_t count = 6);
   ^~~
libraries\DHT_sensor_library\DHT.h:65:3: note:   candidate expects 3 arguments, 0 provided
exit status 1

Compilation error: no matching function for call to 'DHT::DHT()'

C++ objects are built by a constructor. The Adafruit DHT class has only one useful constructor, and it needs to know which pin and which sensor type to use. DHT dht; asks for a constructor with no arguments, which doesn’t exist.

#include <DHT.h>
DHT dht(4, DHT22);   // data pin, sensor type (DHT11 / DHT22)

void setup() {
  dht.begin();
}

Quick fix — try in order

  1. 1

    Pass the pin and the type

    DHT dht(4, DHT22); — 4 is the data GPIO, DHT22 or DHT11 is the sensor. The third argument (count) has a default; leave it out.

  2. 2

    Read the “candidate” lines

    Under the error, the compiler lists the versions that do exist: DHT(uint8_t pin, uint8_t type, …) with “expects 3 arguments, 0 provided”. That is the recipe.

  3. 3

    Check the argument types

    no matching function for call to 'X::begin(String&)' means the call exists but wants a different type — e.g. const char*. Convert with .c_str().

  4. 4

    Check the library version

    Old tutorials use older APIs. If the candidate list doesn’t match the tutorial at all, you have a different library with the same header name.

Why it happens

What does “no matching function” mean in general?

A function or constructor with that name exists, but none of its versions accepts the arguments you gave (count or types). The notes after the error list every version the compiler considered.

Same error for LiquidCrystal_I2C::begin()

That’s a library version mismatch — see no matching function for call to 'LiquidCrystal_I2C::begin()'.

Same error for min() / max() on ESP32

Different cause: the two arguments have different types. See no matching function for call to 'min'.

Board-specific notes

ESP32: Use a GPIO number (e.g. 4), not a D-label. Full wiring on DHT22 with ESP32.

Arduino Uno: See DHT22 with Arduino Uno for a tested sketch.

↑↓ to move · Enter to open