BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

Store a variable

Goodnight
First of all sorry for my ignorance.
Esp8266 board.
My project sends temperature and humidity data to two virtual pins.
all right. What I intend to count cold hours based on the temperature parameter. The cold hours are counted when the temperature is less than 30 degrees. The temperature reading is done every 5 minutes. I have a switch, if it is one, it activates the hour counter. I call the functions after Blynk.begin. The only part of the code that doesn’t work is this. Where is the problem ? Thank you

int contarsi;
int contador;
float  horafrio;

BLYNK_WRITE(V4) 
{
  contador = param.asInt();
}

BLYNK_WRITE(V3)
{
  contarsi = param.asInt();
}

void hour(void) {

  if (contarsi = 1){

    if (T >= 30)  {
      contador += 1;
      horafrio = (contador * 5) / 60;
      Blynk.virtualWrite(V5, horafrio);
      Blynk.virtualWrite(V4, contador);
   
    }

  }
}

Send the complete code

Physical, or a Blynk widget?
What is this switch attached to? (Which physical or virtual pins?).

Is this done using a BlynkTimer? Where is this code?

What functions, how are they called, are they called from within void setup?

What type of widgets are attached to pins V3 and V4, and why are you attempting to retrieve data from them using the BLYNK_WRITE(vPin) callbacks. Is this part of your BLYNK_CONNECTED/Blynk.syncVirtual functionality that you’ve omitted?

Pete.

1 Like

good morning
Thank you for your time, I have already solved it.
A question. Is there a widget app to launch an automation?
Thank you

Not specifically, but you can trigger a Device State automation by using a button widget (or other widget type if you prefer) to change a datastream value.

Pete.

1 Like

The button activates an automation that sends me a notification to my mobile when the temperature is less than 0.5 degrees.