I need help for my project. i used esp 8266 - 12E for push notification and its working fine. i want to used same hardware for NO and NC both notification. is it possible?
Yes, of course.
But without knowing more about your current hardware and software setup itâs impossible to point you in the right direction.
Pete.
Thanks for reply. i have used this project in machine. and every time i received message when its shutdown. i want to also set up when its start. so i can received message when machine is start and stop. for this i used Normally closed contact (NO) of machine.
For this i used
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
char auth[] = "";
char ssid[] = "";
char pass[] = "";
int flag=0;
void notifyOnButtonPress()
{
int isButtonPressed = digitalRead(D1);
if (isButtonPressed==1 && flag==0) {
Serial.println("WTG is Off");
Blynk.notify("Alert : Now WTG is Off");
flag=1;
}
else if (isButtonPressed==0)
{
flag=0;
}
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// Setup notification button on pin D1
pinMode(D1,INPUT_PULLUP);
timer.setInterval(6000L,notifyOnButtonPress);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}
You need to edit your post so that the code is formatted correctly:
You also need to provide some information abut The âmachineâ youâre connecting to. Is it the same set of contacts that will be used to monitor the power on and power off statuses, or different contacts connected to different pins of your ESP?
Pete.
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
char auth[] = ââ;
char ssid[] = ââ;
char pass[] = ââ;
int flag=0;
void notifyOnButtonPress()
{
int isButtonPressed = digitalRead(D1);
if (isButtonPressed==1 && flag==0) {
Serial.println(âWTG is Offâ);
Blynk.notify("Alert : Now WTG is Off");
flag=1;
}
else if (isButtonPressed==0)
{
flag=0;
}
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// Setup notification button on pin D1
pinMode(D1,INPUT_PULLUP);
timer.setInterval(6000L,notifyOnButtonPress);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}
i just used one dry contact normally closed(NC) of machine, only for status read. so when machine will shutdown then contact will change normally closed (NC) to normally open (NO) and i get massage âmachine is offâ. Now i want to modify project to get both message. when machine will start and when machine will stop.
So you need another if statement like this one:
where you test for isButtonPressed==0
Pete.
Yes, Right
Can you help me to write this program?
Try doing it yourself and if you get stuck, post your code and some information about the results youâre getting.
Pete.
This really isnât a coding help forum. Typically it should be something that is specific to BLYNK. Since you already seem to have the BLYNK part working, I donât see how this is related to needeing help with BLYNK.
BUTâŚ
Since it seams like a pretty easy answer here you go.
You basically just need to add an AND condition to your else if
statement, and the relevant BLYNK notification stuff.
So when Machine is running the switch will CLOSE, and the flag will be 1; it will then send notification and set flag to 0. When Machine stops the switch will OPEN, and the flag will be 0; it will then send notification and set flag to 1.
else if ((isButtonPressed==0) && (flag ==1) )
hey @Toro_Blanco , thank you for supporting. now it is work perfectly fine. @Toro_Blanco and @PeteKnight thank you both off you.
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
char auth[] = âXXXXâ;
char ssid[] = âTusharâ;
char pass[] = âXXXXâ;
int flag=0;
void notifyOnButtonPress()
{
int isButtonPressed = digitalRead(D1);
if (isButtonPressed==1 && flag==0) {
Serial.println(âWTG is ONâ);
// We allow 1 notification per 15 seconds for now.
Blynk.notify("Alert : Now WTG is ON");
flag=1;
}
else if ((isButtonPressed==0) && (flag ==1) ) {
Serial.println(âWTG is Offâ);
// We allow 1 notification per 15 seconds for now.
Blynk.notify(âAlert : Now WTG is OFFâ);
flag=0;
}
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// Setup notification button on pin D1
pinMode(D1,INPUT_PULLUP);
timer.setInterval(6000L,notifyOnButtonPress);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}