Any way, I digress. I have an ESP-01 and at the moment I have it setup when GPIO0 goes high, it sends a push notification to my Blynk app, and also on GPIO2 going high it sends another message to my Blynk app. Basically, I wish to monitor when a set of remote contacts open and close. What I would love is if I could have a notification if on one GPIO only goes high and when it goes low another message - is this possible please?
the code I have is this:
#define BLYNK_PRINT Serial# include < ESP8266WiFi.h > #include < BlynkSimpleEsp8266.h >
BlynkTimer timer;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "*****************";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "***********";
char pass[] = "***********";
int flag1 = 0;
int flag2 = 0;
void notifyOnButtonPress1() {
int isButtonPressed1 = digitalRead(0);
if (isButtonPressed1 == 1 && flag1 == 0) {
// We allow 1 notification per 15 seconds for now.
Blynk.notify("Dad is up and alarm is now unset");
flag1 = 1;
} else if (isButtonPressed1 == 0) {
flag1 = 0;
}
}
void notifyOnButtonPress2() {
int isButtonPressed2 = digitalRead(2);
if (isButtonPressed2 == 1 && flag2 == 0) {
// We allow 1 notification per 15 seconds for now.
Blynk.notify("Dad's alarm is part set and has gone to bed");
flag2 = 1;
} else if (isButtonPressed2 == 0) {
flag2 = 0;
}
}
void setup() {
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// Setup notification button on pin 0
pinMode(0, INPUT_PULLUP);
// Setup notification button on pin 2
pinMode(2, INPUT_PULLUP);
timer.setInterval(16000 L, notifyOnButtonPress1);
timer.setInterval(16000 L, notifyOnButtonPress2);
}
void loop() {
Blynk.run();
timer.run(); // Initiates BlynkTimer
}
any help would be so greatly appreciated.
Alistair