Unable to send notifications to my phone

Hello fellow Blynkers
I am doing a pulsoxymeter project to notify me when the pulse or o2 saturation is not in the safe span.
The project is working perfectly, sending data to phone and its nice, but the notification task, seem not to be working, it is defined and i can find it in my notification settings, though when i check serial monitor, so there is no evidence off sending a notification.
The hardware used is ESP32 and MAX30100 Pulseoximeter
The phone is Samsung Galaxy Z-flip3 5G
The connection is through Wifi
I hope the details are enough, looking forward to learn from you all.

My code is:

#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPLapXxeE4j"
#define BLYNK_DEVICE_NAME "Quickstart Template"
#define BLYNK_AUTH_TOKEN "-CHZFTCQ_xjySnW0mJcTU1wa1zb-uA8R"
#include <Blynk.h>
#include <BlynkSimpleEsp32.h> 
#include <WiFi.h>
#define REPORTING_PERIOD_MS 1000
 
char auth[] = "-CHZFTCQ_xjySnW0mJcTU1wa1zb-uA8R";             // You should get Auth Token in the Blynk App.
char ssid[] = "Stofa10146";                                     // Your WiFi credentials.
char pass[] = "sunde61file58";
 
// Connections : SCL PIN - D1 , SDA PIN - D2 , INT PIN - D0
PulseOximeter pox;
BlynkTimer timer; 
float BPM, SpO2;
uint32_t tsLastReport = 0;
 
 
void onBeatDetected()
{
    Serial.println("Beat Detected!");
}

void sendMsg()
{
  float h = pox.getHeartRate();
  float o = pox.getSpO2();
  if ( h >= 140)
  {
    Blynk.logEvent("Notify","Your BpM is Quite High,I am Sending Data To you Doctor ");
  }
  else if ( o<90 & o>80)
  {
    Blynk.logEvent("Notify","Your Spo2 is Quite Low,I am Sending Data To your Doctor ");
  }
  else if (h < 40)
  {
    Blynk.logEvent("Notify","Your BpM is Quite Low,I am Sending Data To you Doctor ");
  }
  else if (h == 0 & o == 0)
  {
    Blynk.logEvent("Notify","Place your finger to the sensor");
  }

}


void setup()
{
    Serial.begin(115200);
    
    pinMode(19, OUTPUT);
    Blynk.begin(auth, ssid, pass);
 
    Serial.print("Initializing Pulse Oximeter..");
 
    if (!pox.begin())
    {
         Serial.println("FAILED");
         for(;;);
    }
    else
    {
         Serial.println("SUCCESS");
         pox.setOnBeatDetectedCallback(onBeatDetected);
    }
 
    // The default current for the IR LED is 50mA and it could be changed by uncommenting the following line.
        pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
  timer.setInterval(1000, sendMsg); //runs every half a min


}
 
void loop()
{
    pox.update();
    Blynk.run();
 
    BPM = pox.getHeartRate();
    SpO2 = pox.getSpO2();
    if (millis() - tsLastReport > REPORTING_PERIOD_MS)
    {
        Serial.print("Heart rate:");
        Serial.print(BPM);
        Serial.print(" bpm / SpO2:");
        Serial.print(SpO2);
        Serial.println(" %");
 
        Blynk.virtualWrite(V3, BPM);
        Blynk.virtualWrite(V4, SpO2);
 
        tsLastReport = millis();
    }
}

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

Hello @PeteKnight
Thank you, it is edited.

Okay, there is so much wrong with this sketch that it’s difficult to know where to begin.

At this stage I’ll focus on your original issue of notifications.
Notifications are made at to alert users to unusual situations, and because of this there is a limit of 100 notifications per 24 hour period. Events, which are used to trigger notifications are also limited 8n the same way.

Looking at your code, it’s clear that you are mis-using notifications and you should instead be using a value or labelled value within the Blynk mobile app to instruct the user on what they should do, provide them with the results and also provide them with feedback about the results.

Pete.

Understandable, but still i didn’t receive any thing, shouldn’t a message that says (you have reached your limit) displays on my event screen? or does it get rejected because to many orders are send when i compile?
For that should i create different events for each case?

You’re probably using the wrong information when you try to log the event.

You shouldn’t be using events for this, and creating more events won’t help with the limits.

Stop using events for this and use Blynk.virtualWrite to a datastream that is then attached to a value widget.

Pete.

Here is a screenshot from my event details, can you specify which wrong information so i can run a doublecheck.


(I unabled notification in the second bar)

I have tried Blynk.virtualWrite without luck, and frankly i am not big fan of it because it does not notify which wipe the biggest idea at the project.
Thanks in advance

Pete.

What is the alternative in case i want a notification??

Do you want help with sending notifications, or with getting your pulse oximeter working?

Pete.

Dear Pete
My pulse oximeter works perfectly, it is the notifications where i have a problem, is there another function that passes better since events doesnt work?

If you aren’t a fan of using Blynk.virtualWrite and you wnat an alert on the front screen of your phone every 5 seconds, which is what this does…

then Blynk isn’t the platform for you.

In the world of smartphone apps, you invariably have to open the app to interact with the device you’re using rather than doing everything via notifications, and Blynk is not really any different.

Pete.

Its because one of the thing on my check-list is sending notifications when its out of normal ranges (defined as 40-140BPM and spO2 between 90 and 80)
I am willing to abandon the “Place your finger to the sensor” and get alerted once or twice only when outed of range.
Will it be better this way?

Thank you
Mohamed

I can’t understand why, when you have the app open on your phone to see the instructions and the results, you then want to send a notification alert. It makes no sense to me.
It’s the wrong use of notifications as far as I’m concerned.

Pete.

it would be sort of an alert function, to alarm users that the Bpm is too high or low

But why do that as a notification, as opposed to a message in a widget within the app, which you will have open anyway when taking a reading?

Pete.

I didn’t quite understand the difference, what should i expect incase in case i have tried the message widget, something that alarms me like a notification?? because it is the primary target for this project

Mohamed

Okay, you don’t seem to be listening to my feedback, so I’ll walk away from this conversation and leave you to come up with a solution that works for you.

There are multiple other issues with your sketch, one of which should be preventing your device from even connecting to the Blynk server correctly, but I’ll leave you and the other forum members to figure that one out.

Good luck with your project.

Pete.