Thermostat slider Blynk

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 button attached to Digital Pin 16 to work.
When 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?

Thanks

       #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;


BLYNK_WRITE(V1) {
  TempSom = param.asInt();
}

BLYNK_WRITE(V4) {
  Thermostat = param.asFloat();
}

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass, IPAddress(10, 3, 141, 1), 8080);
 
  timer.setInterval(1000L, relaisAlim);
  
  
  //BLYNK TERMINAL
  terminal.clear();
  terminal.print("Controleur Extracteur Allumé");
  terminal.println("---------------------------");
  terminal.flush();

}

void loop()
{
  Blynk.run();
  timer.run();
}

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

{
  Serial.print("Temperature : ");
  Serial.print(TempSom);
  Serial.println("°C");
  Serial.print("Thermostat : ");
  Serial.println(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 ");
  }
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.