Thermostat with slider

Hi there !

I have a scoui while trying to make a thermostat. The relay does not start despite the order sent to the pine. I have to add a bouto attached to Digital Pin 16 to work.
Lorceque I stand the button my ESP8266 restarts.

I can see in the serial that everything works on the side of the code.

Can anyone help me solve this problem?


       #define BLYNK_PRINT Serial

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

BlynkTimer timer;
WidgetTerminal terminal(V100);

char auth[] = "xx";
char ssid[] = "xx";
char pass[] = "xx";

WidgetLED ledV1(V2);
WidgetLED ledV2(V3);

int relaisOn = 16; //relaisD0 - On/Off
int relaisV = 5;  //relaisD1 - Vitesse 1/2
int hysteresis = 2;
int TempSom;
float Thermostat = 0;

  TempSom = param.asInt();

  Thermostat = param.asFloat();

void setup()
  Blynk.begin(auth, ssid, pass, IPAddress(10, 3, 141, 1), 8080);
  timer.setInterval(1000L, relaisAlim);
  terminal.print("Controleur Extracteur Allumé");


void loop()

void relaisAlim()   //boucle temperature//relais 1

  Serial.print("Temperature : ");
  Serial.print("Thermostat : ");

  if (TempSom >= (Thermostat + hysteresis))

    digitalWrite(relaisOn, HIGH);
    Blynk.virtualWrite(V2, 255);
    Serial.println("relais allumé ");

  else if (TempSom <= (Thermostat - hysteresis))
    digitalWrite(relaisOn, LOW);
    Blynk.virtualWrite(V2, 0);
    Serial.println("relais eteind ");

You should add

pinMode(relaisOn, OUTPUT);

to your void setup.

1 Like

2° d’hystérésis c’est énorme !

And it’s actually 4° when you use it like this!


1 Like

Yes -2 +2 :joy:

1 Like

Haha non tout depends de l’application que tu en as ! Ce sont de gros extracteur, si je mets pas 4°C ils s’allument et s’eteigne constament et j’ai pas envie de les coller !

Ok, it seems to work ! Thanks for your help !

I know, that’s what I want

1 Like

Ah j’ai cru que c’était un thermostat pour la chaudière !

1 Like

Hi there !

I found a small fault in my system, when the esp8266 restarts the thermostats are not taken into account. I have to move the slider and set it back to the desired temperature.

Would there be a way to fix that?