How to handle a fan through the temperature.

Hello, Am designing my domotic home and I’m asking for help on a part …
For example: Ago 30 °C and want my house to this constantly at 25 °C, Run a fan and the temperature drops to 25°.
This is the code I’m working:

#include <dht11.h>

dht11 DHT11;

void setup() 

void getdata(int iPuerto)
  int chk =;

  Serial.print("Sensor ");
  Serial.print(" ");
  switch (chk)
    case 0:   
      Serial.print((float)DHT11.humidity, 2);
      Serial.print(" % ");
      Serial.print((float)DHT11.temperature, 2);
      Serial.println(" o C");
    case -1: Serial.println(" Checksum error"); break;
    case -2: Serial.println(" Time out error"); break;
    default: Serial.println(" Unknown error"); break;


void loop() 

I'm going to provide "too much" information because PID controllers are a complex subject. You can oar down the concept and adapt it to your needs.!topic/diy-pid-control/ucNXtYd7XxM

But, read thus first: To build a bit of background.