Hi.
I've interfaced a LM393 Sound Detection Sensor with my NodeMCU, for push notifications through Blynk.
I have it placed in my garage. While I could use a PIR sensor, the sound sensor would send a notification even if someone unsuccessfully tried to enter the garage.
I have attached the code I originally ran, but it pushes notifications several times per seconds. Is there some way to stop after first interrupt, delay for X seconds, then check for interrupt again?
I've tried with "delay(15000L)" and SimpleTimer, but it still gets multiple inputs for the period of time it is active.
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
char auth[] = "d6bf4xxxxx4";
char ssid[] = “XXXXXX";
char pass[] = “xxxxxxtx";
void notifyOnButtonPress()
{
// Invert state, since button is "Active LOW"
int isButtonPressed = !digitalRead(5);
if (isButtonPressed==1) {
Serial.println("Lyd oppdaget i garasje!");
Blynk.notify("Lyd oppdaget i garasje!");
}
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(5, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(5), notifyOnButtonPress, CHANGE);
}
void loop()
{
Blynk.run();
}