0

My code isn't working and shows up with this error message. "no matching function for call to 'SimpleDHT11::read(byte*, byte*, NULL)'"

How do i fix this? This is my complete code.

#include <SimpleDHT.h>

int pinDHT11 = 2;
SimpleDHT11 dht11;

void setup()
{
    Serial.begin(9600);
    pinMode(9, OUTPUT);
    int err = SimpleDHTErrSuccess;
}

void loop()
{
    // start working...
    Serial.println("=================================");
    Serial.println("Sample DHT11...");

    // read without samples
 
    byte temperature = 0;
    byte humidity = 0;
    
    int err = SimpleDHTErrSuccess;
    if ((err = dht11.read(&temperature, &humidity, NULL)
       != SimpleDHTErrSuccess)
    {
        Serial.print("Read DHT11 failed, err=");
        Serial.println(err);
        delay(1000);
        return;
    }
    Serial.print("Sample OK: ");
    Serial.print((int)temperature);
    Serial.print(" *C, ");
    Serial.print((int)humidity);
    Serial.println(" *H, ");

    if (humidity > 70 )
    {
        Serial.println("Humidity is above 70%");
        digitalWrite(9, HIGH);
    }
    else
    {
        Serial.println("Humidity is below 70%");
    }
    // DHT11 sampling rate is 1HZ.
    delay(1500);
}


5
  • I recommend you using the DHT library from Adafruit. See the full instruction in Arduino DHT sensor tutoria. – Rozona Zoro Dec 3 '20 at 4:14
  • You forgot a parenthesis ! if ((err = dht11.read(&temperature, &humidity, NULL) ... should be like if ((err = dht11.read(&temperature, &humidity, NULL)) ... – Peter Paul Kiefer Dec 3 '20 at 10:39
  • It might be because you have another DHT library installed. If this is the case go to your sketches folder, then libraries - delete other library, which contains same DHT.h file, and try again. Also as Peter mentioned one of the parenthesis is missing after NULL statement. – Erdem Dec 3 '20 at 13:17
  • Besides your missing parenthesis, your code compiles fine for a UNO under AVR Core 1.8.3 and SimpleDHT 1.0.12 from Winlin <winlin@vip.126.com> – timemage Dec 3 '20 at 21:39
  • Is there any new information you have to add or did you solve your problem? – timemage Dec 6 '20 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.