Keep getting Push notifications every 5 seconds or so

Hello all. My issue is that am trying to get Push notifications every time it sense movement And i do get the push notification on my phone the only problem i have is that it wont stop sending notifications every 3-5 seconds for about 3 minutes than it will stop and if i walk again in front of it it will get trigger again and start sending notification non-stop i only want it to send me 1 or notifications every time i gets trigger.

i dont know if is the app on my phone or the code but i leave the code down below to see if anybody can help me out, i tried the solution on the link https://community.blynk.cc/t/solved-emails-notifications-repeating/10480/22 but no luck it also send me e-mails non-stop

i have a:
wemos d1 mini
PIR sensor

i tried to change 1000L to 30000L but still nothing.

int pirPin = 13;
#define BLYNK_PRINT Serial


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

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "1800";

/* WiFi credentials */
char ssid[] = "user";
char pass[] = "pass";

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

  Blynk.begin(auth, ssid, pass);
  pinMode (pirPin, INPUT);
}

void loop()
{
  Blynk.run();
  int pirValue = digitalRead(pirPin);
if(pirValue==HIGH){
Blynk.notify("motion High"); 

}
if(pirValue==LOW) {
 Blynk.notify("motion Low");
delay(1000);
   }
timer.setInterval(30000L, sendSensor);
}

First of all, you seem to be missing some code, as you have a timer that calls a function called “sendSensor”, but no function called void sendSensor().

Secondly, the structure of your code makes no sense. You really want to respond to ANY trigger of your PIR. The way to do this isn’t to poll your sensor every so often, it’s to attach an interrupt to your pirPin. An interrupt will call a specified function every time the PIR detects movement.

Thirdly, you should only have Blynk.run and (if you’re using timers) timer.run in your void loop.

Using the interrupt approach will mean that you get one motificatiin per trigger of your PIR. If you wanted to limit the maximum number of notifications over a specific period then you’d probably use a timer and a flag to keep track of the fact that a notification has been sent.

Pete.

Thanks for the reply , i still dont get it :grin: , all i need to know is what code i need to remove or add so blynk can stop sending me Push Notifications every 5 seconds for about 2-3 minutes after the PIR sense movement when it should send only one Notification, you know one movement/sense = one notification.

Everything to change has already been suggested… if you don’t understand that much, what more can be done? We don’t write your code for you.

That is not how those PIR sensors work… they can detect many signals in a small fraction of time… or nothing when you think they should.

You need to have the PIR send a signal each and every time (via interrupt pin - Google that if unsure) and then have logic code to determine if the signal is relevant in time to justify a notification… this is not just a simple command, but potentially a lot of flags, timers and if() processing, depending on your needs.

Aside from the fact that most of this should NOT be in the void loop()… you are missing the timer.run() command… thus your timer wouldn’t work anyhow, even if properly coded for. Not to mention the delay() command… bad code, bad :stuck_out_tongue_winking_eye:

http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/keep-your-void-loop-clean

Walk before running… read up on a few documents and try out a few examples to understand how Blynk works and how to create proper code functions…

http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/how-to-display-any-sensor-data-in-blynk-app

Also, look at what others have done and how…

https://community.blynk.cc/search?q=PIR%20notification

1 Like