Event dont trigger

Hy,
I have a problem in my project. I have a temperature monitoring system. When the temperature drops below a certain value, I want a critical event to be triggered. I set the temperature from the Blynk application, but it doesn’t happen. I don’t want to deal with automation. I didn’t even exceed the limit of 100 events/day. In a single day, the events worked.

I also attach part of my code, I’m making a mistake somewhere but I can’t find the problem.

Thank you in advance


int setTemperaturaLow01;
int setTemperaturaHigh01;
int setTemperaturaLow02;
int setTemperaturaHigh02;
int setTemperaturaLow03;
int setTemperaturaHigh03;

void checkNetwork()
{
if ( radio.available(&pip) )
    {

      // Fetch the payload, and see if this was the last one.
      pload_width_now = radio.getDynamicPayloadSize();

      // If a corrupt dynamic payload is received, it will be flushed
      if(!pload_width_now){
        
      }
        else
        {
       
      radio.read( rx_buf, pload_width_now );

     newdata=1;

      // Spew it
      Serial.print(F("Data on pip= "));
      Serial.print(pip);
      Serial.print(F(" Got data size="));
      Serial.print(pload_width_now);
      Serial.print(F(" data="));
      for(byte i=0; i<pload_width_now; i++)
      {
          Serial.print(" ");
          Serial.print(rx_buf[i]);                              // print rx_buf
      }
      Serial.print(" ");
      }
    }
   if(newdata==1)
  {
  newdata=0;

if(pip==1&&pload_width_now==sizeof(transmitter1_data))
  {
   memcpy(&transmitter1_data, rx_buf, sizeof(transmitter1_data)); 
     
            Blynk.virtualWrite(13, transmitter1_data.A);
            Blynk.virtualWrite(14, transmitter1_data.B);
            Blynk.virtualWrite(15, transmitter1_data.C);
            Blynk.virtualWrite(16, transmitter1_data.D);
            Serial.print("transmitter1_data.temp1 = ");
            Serial.println(transmitter1_data.A);
            Serial.print("transmitter1_data.umid1 = ");
            Serial.println(transmitter1_data.B);
            Serial.print("transmitter1_data.volt1 = ");
            Serial.println(transmitter1_data.C);
            Serial.print("transmitter1_data.batPercent1 = ");
            Serial.println(transmitter1_data.D);
            //Blynk.virtualWrite(V24,time);
            int temp1;
            temp1 = transmitter1_data.A;
            if (temp1 < setTemperaturaLow03)
{
  Blynk.logEvent("temperatura_joasa03", String("Temperatura mica detectata! Tº: ") + temp1);
}
            if (temp1 > setTemperaturaHigh03)
{
  Blynk.logEvent("temperatura_ridicata03", String("Temperatura mare detectata! Tº: ") + temp1);
}
            
   
   }
}
BLYNK_CONNECTED() {
Blynk.syncAll();
}

BLYNK_WRITE(V9)
{
    int setTemperaturaLow01 = param.asInt();
}

BLYNK_WRITE(V10)
{
    int setTemperaturaHigh01 = param.asInt();
}

Well, there’s a problem with the snippet of code that you’ve posed, because the checkNetwork() function has a mismatched number of curly brackets.

You also don’t have any flag variables to prevent multiple events being logged, and the way your code is written an event will be logged every time checkNetwork() is called and either temp1 < setTemperaturaLow03 or temp1 > setTemperaturaHigh03 so the only situation where an event won’t be triggered is if temp1 is exactly equal to setTemperaturaHigh03

Without details of exactly how you’ve configured each of your events and the corresponding notifications tabs, and how the Notifications settings in the device view (three dots in the web console next to the device name) are configured, then its difficult to say.

Pete.

Thanks Pete for fast response. I will put some printscreen.

void loop() {
  
  BlynkEdgent.run();
  timer.run();
  checkNetwork();
}

You haven’t addressed this issue…

or this…

and this snippet of code…

tells me that you will very quickly have all events and notifications blocked, because checkNetwork() is being called hundreds of times per second from your void loop.

I can’t help father until you stop posting small snippets of code and until you fix the issues I’ve pointed-out already.

Pete.

No you didn’t, you’re still calling checkNetwork() from your void loop.

It would really help the readability of your code if you used indents in a sensible way, so that your nested if statements are easy to follow.

Pete.