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

My Blynk.LogEvent is not working

For my project, I am using Blynk notifications in a function. I have have double checked the code, as well as the event code, and have looked through all my setting on the web console, but the notification still does not appear no matter what. I even deleted the event and made a new one, but still no luck. However, the function the event is running in is working, as it is printing the appropriate statements when the event should be triggered on the serial monitor. I have no idea why this is happening. Please help.

We need to see your code, and see screenshots of your event setup and the notification tab of the event too, plus the timeline screen.

But, before you do that, try working your way through this tutorial to ensure you haven’t missed a crucial step…

Pete.

my code:

    
    /*************************************************************

  This is a simple demo of sending and receiving some data.
  Be sure to check out other examples!
 *************************************************************/

// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID           "TMPL6R-gIGo6"
#define BLYNK_DEVICE_NAME           "Quickstart Device"
#define BLYNK_AUTH_TOKEN            "vPo4j3HZvMBJ5oFiFf0I_ErztF_GhkSj"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


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

char auth[] = BLYNK_AUTH_TOKEN;

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "iPhone (4)";
char pass[] = "Hasitha*88";
String temp_event = "budget_limit" ;
BlynkTimer timer;
String raad;
String watts;
String volts;
float kwH = 0;
float KwH_old = 0;
float getLim = 0;


#define VPIN_LIM          V4

// This function is called every time the Virtual Pin 0 state changes


void BringValues(){
   if (Serial.available()) {
    raad = Serial.readStringUntil('\n'); 
    if(raad.length() > 0){
    int index = raad.indexOf(',');
    watts = raad.substring(0,index);
    volts =  raad.substring(index+1,raad.length());
   }
   }

}

void SendPower(){
  if(watts.toFloat()> 5 &&  watts.toFloat()< 13 && volts.toFloat()>60 && volts.toFloat() < 123){
      
   float wAtts = watts.toFloat();

   float waTts = wAtts*100;
       
   kwH = (waTts/1000)*(0.3/3600);
   KwH_old = KwH_old + kwH;
   Blynk.virtualWrite(V8, KwH_old);

}
  
}





void SendVoltage(){
  if(watts.toFloat()> 5 &&  watts.toFloat()< 13 && volts.toFloat()>60 && volts.toFloat() < 123){

   float voLts = volts.toFloat();
   

   Blynk.virtualWrite(V0, voLts);

}
  
}




BLYNK_WRITE(VPIN_LIM)
{ 
  getLim = param.asFloat(); // assigning incoming value from pin V1 to a variable
  
}

void VoltageEvent()
{
  //int flag = 0;
 // while( flag == 1);{
     if(KwH_old >= getLim) { //LOW to HIGH
                Serial.print("value is");
                Serial.println(KwH_old);
                Serial.println("Limit Value is");
                Serial.println(getLim);
                String text = "You have Reached the limit for the month";
                Serial.println(text);
                Blynk.logEvent(temp_event, text);
                //digitalWrite(BUZZER, HIGH);
                //buzzer_state = true;
                //buzzer_timer = millis();
                //flag = 0;
  } else{
         Serial.println("youre in the safe range.");
  }

//}
}





// This function sends Arduino's uptime every second to Virtual Pin 2.
//void myTimerEvent()
//{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  //Blynk.virtualWrite(V2, millis() / 1000);
//}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  

  // Setup a function to be called every second
  timer.setInterval(1000L,SendPower);
  timer.setInterval(1000L,SendVoltage);
  timer.setInterval(1000L,VoltageEvent);
 
}

void loop()
{

  BringValues();
  SendPower();
  SendVoltage();
  Blynk.run();
  timer.run();
  VoltageEvent();
  
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

I actually referenced that guide before coming on here, but there may be something I’ve missed.

@Hello1234 Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

Pete.

done.

My guess is that you’ve probably exceeded the event limit for the 24 hour period, by having these function calls in your void loop as well as calling the functions every 1 second with timers (which try to execute at exactly the same time by the way, which isn’t possible on a single threaded device)…

You should read this…
https://docs.blynk.io/en/legacy-platform/legacy-articles/keep-your-void-loop-clean

This (especially the part about staggering timers)…

And re-read the tutorial I linked to earlier about using flag variables to limit events/notifications.

Pete.

but my notifications don’t appear on the notifications tab OR the timeline. May I ask how to check if my notifications have exceeded the regular number for the day?

Hello, just popped in to say you were right, I did reach the notification limit for the day. I will look into the flag variables.