DHT11 sensor displays temperature correctly in the serial console, but does not

turn on relay.

I am trying to use the DHT11 temperature and humidity sensor to turn on a fan, through a relay, when the temperature goes above 35 C. I believe everything is wired properly, since I triple-checked all the connections. I used a hairdryer to heat the sensor up to 50 C, but the relay does not turn on. What should I do? By the way, sorry if this is wrong forum.

#include <DHT.h>
DHT dht;

void setup()
{
  pinMode(2,OUTPUT);
  digitalWrite(2,HIGH);
  //used for an extra 5V pin
  
  dht.setup(4);
  Serial.begin(9600);
}

void loop()
{
  delay(dht.getMinimumSamplingPeriod());
  int temp = dht.getTemperature();
  if(temp > 35)
  {
    digitalWrite(3,HIGH); //turns on relay
  }
  Serial.print(temp); Serial.print(" C"); Serial.print("\n");
}

When you step thru the code or watch it as its running are you seeing valid values? I had a similar issue when i was setting up the temperature sensor and it was all because the values were not as i expected.

    digitalWrite(3,HIGH); //turns on relay

Does it really? Most relays are turned on by setting the pin LOW.

DHT are usually declared Float as it returns 2 decimal places.