Connect between temp and relay to create thermostat

Hello,
i manage to set 3 diff 18ds20 sensors on my locak blynk + turn on and off a relay on my GP13

the only matter now that i want to create a thermostat from one of the temp that will open and close my relay so the water
heater in the fish tank will turn on and off.
does anybody have an idea how to implement a thermostat ? ive looked everywhere and found some jobs but without any code or guide.

here is the code ,

thank you very much


#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "certificate auth for blynk";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "wifi ssid";
char pass[] = "wifi password";


/* TIMER */
#include <SimpleTimer.h>
SimpleTimer timer;

/* DS18B20 Temperature Sensor */
#include <OneWire.h>
#include<DallasTemperature.h> 
#define ONE_WIRE_BUS 2 // DS18B20 on arduino pin2 corresponds to D4 on physical board
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
float temp;

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  DS18B20.begin();
  timer.setInterval(1000L, getSendData);
}

void loop()
{
  timer.run(); // Initiates SimpleTimer
  Blynk.run();
}

/***************************************************
 * Send Sensor data to Blynk
 **************************************************/
void getSendData()
{
  DS18B20.requestTemperatures(); 
  temp = DS18B20.getTempCByIndex(0);
  Serial.println(temp);
  Blynk.virtualWrite(10, temp); //virtual pin V10

  
  temp = DS18B20.getTempCByIndex(1);
  Serial.println(temp);
  Blynk.virtualWrite(11, temp); //virtual pin V11

  temp = DS18B20.getTempCByIndex(2);
  Serial.println(temp);
  Blynk.virtualWrite(12, temp); //virtual pin V12

  

}

You’ll need to modify this a little to suit your needs,as the “temp” used to activate the relay has not been assigned to it. Once those details are added, this code should work fine.

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "certificate auth for blynk";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "wifi ssid";
char pass[] = "wifi password";


/* TIMER */
#include <SimpleTimer.h>
SimpleTimer timer;

/* DS18B20 Temperature Sensor */
#include <OneWire.h>
#include<DallasTemperature.h>
#define ONE_WIRE_BUS 2 // DS18B20 on arduino pin2 corresponds to D4 on physical board
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
float temp;
int relayPin = 13;
int desiredTemp = 0;// set this to your desired temp
int tempDiff = 1;// this variable provides a small +/- temp differential that will prevent constant relay switching.

/***************************************************
   Send Sensor data to Blynk
 **************************************************/
void getSendData()
{
  DS18B20.requestTemperatures();
  temp = DS18B20.getTempCByIndex(0);
  Serial.println(temp);
  Blynk.virtualWrite(10, temp); //virtual pin V10


  temp = DS18B20.getTempCByIndex(1);
  Serial.println(temp);
  Blynk.virtualWrite(11, temp); //virtual pin V11

  temp = DS18B20.getTempCByIndex(2);
  Serial.println(temp);
  Blynk.virtualWrite(12, temp); //virtual pin V12
}

void Heater() {
  if (temp  <= desiredTemp - tempDiff ); {
    digitalWrite(relayPin, HIGH);
  }
  if (temp >= desiredTemp );
  digitalWrite(relayPin, LOW);
}
void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  DS18B20.begin();
  pinMode(relayPin, OUTPUT); // set your GPIO pin to OUTPUT
  digitalWrite(relayPin, LOW); // set the pin LOW or HIGH for OFF, depending on your relay's wiring.

  timer.setInterval(1000L, getSendData);
  timer.setInterval(10000L, Heater);
}

void loop()
{
  timer.run(); // Initiates SimpleTimer
  Blynk.run();
}

Have you managed to get the relay for heater to work?