Blynk notification limit issue

Hi, I have some issues with notification, hope someone can help me.
I’m building a temperature controller that sends a notification if the temperature is greater than a threshold, everything works but after 20 or so notifications, Blynk stops recording the event and sending notification.
I know the free plan allow to send 100 notifications so what could be the issue.
Here is the function that control the notification:

#include <Arduino.h>

//Temperature libraries
#include <OneWire.h>
#include <DallasTemperature.h>

//Blynk connection libraries
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

//Wifi Manager libraries
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h> 

//Blynk ID
#define BLYNK_TEMPLATE_ID ""
#define BLYNK_TEMPLATE_NAME ""
#define BLYNK_AUTH_TOKEN ""
#define BLYNK_FIRMWARE_VERSION "0.1.0"

#define BLYNK_PRINT Serial




BlynkTimer timer;               
#define INTERVAL 5000l     /*BlynkTimer timer interval*/
#define MY_INTERVAL 60000

void tempRequest();       /*temperature reading and output*/
int myTimer(unsigned long timer1);

unsigned long current_time, time_diff;

#define TEMP_PIN 12   /*temperature sensor signal pin*/
#define MIN_TEMP 0    /*min temperature threshold*/
#define MAX_TEMP 100  /*max temperature threshold*/

OneWire oneWire(TEMP_PIN);
DallasTemperature temp(&oneWire);

float temp_C;     /*temperature in celsius*/
int threshold;
bool FIRST = true;



void setup() {

  Serial.begin(9600);
  //BEGIN WIFI MANAGER CONFIG
  WiFiManager wifiManager;
  wifiManager.setTimeout(120);

  if (!wifiManager.autoConnect("WiFi Temperature", "password")) 
  {
    Serial.println("failed to connect, we should reset as see if it connects");
    delay(3000);
    ESP.reset();
    delay(5000);
  }
  else
  {
   Serial.println("connected ");
  }

//BLINK SETUP AND CONNECTION
  Blynk.begin(BLYNK_AUTH_TOKEN, WiFi.SSID().c_str(), WiFi.psk().c_str());
  Blynk.syncAll();
  timer.setInterval(INTERVAL, tempRequest);

  temp.begin();
}

void loop() {

  Blynk.run();
  timer.run(); 
}

 
void tempRequest() 
{
 temp.requestTemperatures();
  temp_C = temp.getTempCByIndex(0);

  Serial.print("Temperature is: ");
  Serial.print(temp_C, 1);
  Serial.println(" C");
  Serial.println("  ");
  Serial.println(time_diff);
  Serial.println("  ");

  Blynk.virtualWrite (V0, temp_C);   /*send temperature value to blynk*/

/*Warning notification*/
  if (temp_C > threshold)            
    {

      if ((myTimer(MY_INTERVAL)) || FIRST)
      {
        Blynk.logEvent("max_temp"); /*send push notification to app*/

        Serial.println("  "); 
        Serial.println ("TEMPERATURE IS TOO HIGH");
        Serial.println("  ");

        FIRST = false;
      }
    }
    else
    {
      FIRST = true;
      current_time = millis() + 5000; /*Set timer to 0*/
    }
  } 


int myTimer(unsigned long timer1)
{

  int ret = 0;
  time_diff = millis() - current_time;
  
  if (time_diff >= timer1) /*&& RUN)*/
  {
    current_time = millis();
    ret = 1; 
  }
  /*---------------------------------------------*/
  /*debug prints*/
  Serial.print("Timer value: ");
  Serial.println(timer1);
  
  Serial.print("Current time: ");
  Serial.println(current_time);
  
  Serial.print("Millis value: ");
  Serial.println(millis());
  
  Serial.print("Time difference: ");
  Serial.println(time_diff);

  Serial.print("Return value: ");
  Serial.println(ret);
  Serial.println("  ");
  /*----------------------------------------------*/
  return ret; /*function return value*/
}

/*INCREMENT*/
BLYNK_WRITE (V1)
{
  int pinData = param.asInt();

  if (pinData == 1){
    if (threshold == MAX_TEMP)
    {
      threshold = MAX_TEMP;
    }
    else
    {
      threshold ++;
    }

  Blynk.virtualWrite (V3, threshold);
  }
}

/*DECREMENT*/
BLYNK_WRITE (V2)
{
  int pinData = param.asInt();

  if (pinData == 1){
    if (threshold == MIN_TEMP)
    {
      threshold = MIN_TEMP;
    }
    else
    {
      threshold --;
    }

  Blynk.virtualWrite (V3, threshold);
  }
}

/*SYNC THRESHOLD*/
  BLYNK_WRITE(V3)
  {
    threshold = param.asInt();
  }

Hello, server does not count the number of events, but counts the number of logEvent commands sent

I know, but the code send only 1 logEvent per minute using a timer so how is possible I reach the max amount of notifications?

@UserPH 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.

I’d also suggest that you post your entire sketch (with sensitive information redacted of course).

Pete.

Hi @UserPH,

If you receive a notification every 1min, doesn’t say that the script is sending it once every minute (what is a lot actually).
At default alerts are only send every 1 minute, you can change this of course but just to point out that it can be that multiple LogEvents are being ‘fired’ within that minute.

Please check your loops/timers, because now it is hard to read for me and i am missing some variables to fully determine where things are going wrong.

Please edit your post as @PeteKnight said before and post your full script. :slight_smile:

I did it , it’s ok like that?

Yes, that’s correct.

TBH, you’re sketch is a bit of a mess, and the way that you’re trying to limit the way that notifications are sent is very ugly.

There are variables within the event setup screen in the web console that affect how frequently notifications are sent, but which do nothing to prevent the logEvent limit being exceeded.

Have you read this?…

Pete.

I know is not is not that clean, I’m learning so I can improve it.
I read FAQ and I will try to implement the code like the example, thanks a lot for the fast answer , I will come back if the issue persist.
Have a nice day.

It’s not just about the code, it’s about the options in the Event and Notification tabs.

It seems that your code started life as an Edgent sketch, and still has some Edgent code remnants left over.
Maybe starting with a clean non-Edgent example and sticking to the structure (the 3 lines of firmware at the top) would be a good idea.

Pete.

Thank you so much for the advice, I will try to do it.