Automate the opening of a window whi ESP 32

Good morning
I want to automate the window opening of a greenhouse with an electric actuator controlled by an ESP32 and a temperature probe.
I wish the program could be automatic
or switch to manual.
And therefore manually open on demand and stop the automation.

I use a Dallas temperature probe. So the Dallas library.
An actuator (cylinder) connected to a relay
(DUBEUYEW L298N Double H-Bridge Motor Drive Controller Board Module)

The automatic program works quite well.
However, I cannot write the program to retrieve a virtual entry (Vpin)
in Void loop.
Is there a Charitable soul to help me?
Thanks in advance

I would like to point out that I am very new to EPS 32 and programming.
And French. So Thanks Google Translate

Here is the program

As I did a lot of testing, the code must not be clean

#define BLYNK_TEMPLATE_ID "????????"
#define BLYNK_TEMPLATE_NAME "New Template"
#define BLYNK_AUTH_TOKEN "???????
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 5

#define ENA_PIN 13  // The ESP32 pin GPIO27 connected to the EN1 pin L298N
#define IN1_PIN 12  // The ESP32 pin GPIO26 connected to the IN1 pin L298N
#define IN2_PIN 4   // The ESP32 pin GPIO25 connected to the IN2 pin L298N

#define BLYNK_PRINT Serial


OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char ssid [] = "MACHIN";
char pass[] = "TRUC";

BlynkTimer timer;


BLYNK_CONNECTED() 
{
  Blynk.setProperty(V3, "offImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
  Blynk.setProperty(V3, "onImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
  Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
  Blynk.syncVirtual(V7);
}

BLYNK_WRITE(V7) 
{
 
  int BoutonV7Valeur = param.asInt();

  if (param.asInt() == 1) 
  {
     digitalWrite(IN1_PIN, LOW);
     digitalWrite(IN2_PIN, HIGH);
     Serial.print("ACTION OUVRIR DEPUIS WEB    ");
     Serial.println(BoutonV7Valeur);
  } 
  
  else 
  {
     digitalWrite(IN1_PIN, HIGH);
     digitalWrite(IN2_PIN, LOW);
     Serial.print("ACTION FERMER DEPUIS WEB   ");
     Blynk.virtualWrite(V9,0);
  }
}

BLYNK_WRITE(V8) 
{
  int BoutonV8Valeur = param.asInt();
       Serial.print(BoutonV8Valeur);
}

void myTimerEvent() 
{
  Blynk.virtualWrite(V2, millis() / 60000);
}

void setup() 
{
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.println("Dallas Temperature IC Control Library Demo");

  pinMode(ENA_PIN, OUTPUT);
  pinMode(IN1_PIN, OUTPUT);
  pinMode(IN2_PIN, OUTPUT);
  digitalWrite(ENA_PIN, HIGH);


  // Debug console
  Serial.begin(115200);
  sensors.begin();

  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
  timer.setInterval(60000L, myTimerEvent);

}

void loop() 
{
  Blynk.run();
  timer.run();
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)

  Blynk.syncVirtual(V7);
 if{ Blynk.syncVirtual(V7) ==ACTION FERMER DEPUIS WEB
   // call sensors.requestTemperatures() to issue a global temperature
   // request to all devices on the bus
   Serial.print("Requesting temperatures...");
   sensors.requestTemperatures();  // Send the command to get temperatures
   Serial.println("DONE");
   // After we got the temperatures, we can print them here.
   // We use the function ByIndex, and as an example get the temperature from the first sensor only.
   float tempC = sensors.getTempCByIndex(0);


   // Check if reading was successful
   if (tempC != DEVICE_DISCONNECTED_C) 
   {
     Serial.print("La température est de :   ");
     Serial.println(tempC);
     delay(10000);
   } 
   else 
   {
     Serial.println("Error: Could not read temperature data");
     Serial.println("Error: Could not read temperature data");
   }
{
   if (tempC > 25  )

    {
     Serial.print("+ de 25 ouverture automatique ");
     digitalWrite(IN1_PIN, LOW);
     digitalWrite(IN2_PIN, HIGH);
     Blynk.virtualWrite(V8,0);
    }

   if (tempC < 25 )

   {
     Serial.print("- de 25 fermerture automatique ");
     digitalWrite(IN1_PIN, HIGH);
     digitalWrite(IN2_PIN, LOW);
     Blynk.virtualWrite(V8,2);

   }
   }
}
  Blynk.virtualWrite(V6,tempC);
}

Thanks
MERCI

Please start by reading this…

You are incorrectly using Blynk.syncVirtual. Please don’t call this function in this way.

You need to add a function (not in your void loop) that will be called each time that the value of the V7 datastream changes.
This function will be called BLYNK_WRITE(V7)

For information about how to use this function and obtain the current value from the datastream please read this…

To force the server to send the current value of the V7 datastream to your device when it starts-up, add this code (once again, NOT in your void loop)…

BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V7);
}

Pete.

Hello Pete
Ok
It’s Just for Try It
My code is note clean …

In my code BLYNK CONNECT () is present
and I have the value of V7

But i want use it after the Loop

Because automation work evry time
And the V7value is read just one


...
BLYNK_CONNECTED() 
{
  // Change Web Link Button message to "Congratulations!"
  Blynk.setProperty(V3, "offImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
  Blynk.setProperty(V3, "onImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
  Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
  Blynk.syncVirtual(V7);
}

BLYNK_WRITE(V7) 
{
 
  int BoutonV7Valeur = param.asInt();

  if (param.asInt() == 1) 
  {
     digitalWrite(IN1_PIN, LOW);
     digitalWrite(IN2_PIN, HIGH);
     Serial.print("ACTION OUVRIR DEPUIS WEB    ");
     Serial.println(BoutonV7Valeur);
     
  } 
  
  else 
  {
     digitalWrite(IN1_PIN, HIGH);
     digitalWrite(IN2_PIN, LOW);
     Serial.print("ACTION FERMER DEPUIS WEB   ");
     Blynk.virtualWrite(V9,0);
     
  }

}....

Posting snippets of code doesn’t help.

If you want to know the value of the V7 datastream when you are executing a timed function then you need to assign the value obtained by param.asInt() to a global variable so that you can reference it later.

Reading this might help…

Pete.