DHT11 returns nan after ac dimmer begin statement

Hi everyone,
I have recently started programming my arduino again and stumbled upon a problem that i don't really understand.
I am writing a program that uses a dht11 to detect air humidity and above a certain value i want it to turn on an ac fan by using an AC dimmer.
however, my dht11 returns nan except when i put the dimmer.begin statement from the setup in comments. Then it just gives the correct value.

i am using an arduino uno but also tried it on my nano with the same result.
the libraries i'm using are the ADAFruit DHT sensor library and the RoboDyn RBDDimmer
i've added the outputs of my serial monitor as images below. the one is with the dimmer.begin in comments that shows that my dht is working fine and the other is without the comments where it returns nan

#include "DHT.h"
#include <RBDdimmer.h>
#define dhtPin 12         //dht datapin on d12
#define dhtType DHT11
DHT dht(dhtPin, dhtType);
float humidityVal;       //air humidity
int relaisPin = 11;
//#define zeroCross 2
dimmerLamp dimmer(relaisPin);
void setup() {
  pinMode(relaisPin, OUTPUT);
  pinMode(dhtPin, INPUT);
  Serial.println("dimmer started");
void loop() {
    Serial.println();           //add empty line
void readDHT(){
  humidityVal = dht.readHumidity();         //read humidity value
   if (isnan(humidityVal)){
    Serial.println("FAILED to read DHT SENSOR!");
  } else {
    Serial.print("humidity: ");
void setDimmer(){
    if (humidityVal>60){
      Serial.println("dimmer set to 85");
    } else {
      Serial.println("dimmer set to 0");

Adafruit DHT examples don't do this:

  pinMode(dhtPin, INPUT);

someone on another forum also said this and i deleted that statement, but the result stayed the same