Push Notification not working

I have tried my best to enable this piece of code to work but all in vain I have also read all the previous questions related to it but none of them helped me out in this problem Please Can you check my code if there is any mistake i am making or any improvement than can be made there?
Please help me bro
@Gunner @Costas @Dmitriy @Pavel @Jamin
My code is

#define BLYNK_PRINT SwSerial
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX
#include <BlynkSimpleStream.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
//char auth[] = "95b6eeef38fe481dba590c28febef4bb"; // For Blynk Cloud Server
char auth[] = "1ec485252d9542b999bc8766edc08172"; // For Local Server

BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
/*
int pinValue = 0;
BLYNK_WRITE(V7)
{
  pinValue = param.asInt();
}
*/
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  
//------------------Automatic Switching Code-----------------------//
double solar = analogRead(A1);
float voltage = solar*(5.0/(1023*0.2000818));
//----------------------------END----------------------------------//

//----------------Reading The condition of Relay 2 i.e Generator----------------//
const int  Relay2_Signal_Pin = 4;
int G = digitalRead( Relay2_Signal_Pin);
//-------------------------------------END--------------------------------------//

//-----------------------------Sending Value of digital and analog pin to the display widget-----------------------------//
//int Digitalpin = analogRead(Relay2_Signal_Pin);
//Blynk.virtualWrite(V3,Digitalpin);
Blynk.virtualWrite(V3,G);
Blynk.virtualWrite(V4,voltage);
//---------------------------------------------------END-----------------------------------------------------------------//

//-------------------------------Defining the virtual pin for Termina widget---------------------------//
WidgetTerminal terminal(V8);
//-------------------------------------------------END-------------------------------------------------//

//--------------------------------------Coding for Terminal Widget-------------------------------------//
int acload = digitalRead(2);
if(acload>0)
terminal.println("AC Load is turned ON");
else
{terminal.println("AC Load is off");}
terminal.flush();
//if(!acload)
//-----------------------------------------------------END-------------------------------------------//

//-------------Load indication system for Blynk------------------//
//int acload = digitalRead(2);
if(digitalRead(2))
{Blynk.virtualWrite(V1,255);}
//terminal.println("AC Load is turned ON");
//else
//{terminal.println("AC Load is off");
//terminal.flush();}
//if(!acload)
else
Blynk.virtualWrite(V1,0);
if(digitalRead(13))
Blynk.virtualWrite(V2,255);
else
Blynk.virtualWrite(V2,0);
//--------------------END--------------------------------//  
  
//------------------------Indication System-------------------------//   
   if(voltage<1)
   {  
     Blynk.virtualWrite(V5, 0);
     if(!G)
    {Blynk.virtualWrite(V6, 255);
     Blynk.virtualWrite(V7, 0);}
     
    
    if(G)
 { //delay(1L * 1000L);  //Is commented out just for checking in proteus virtual simulation , include it in real programming
    Blynk.virtualWrite(V6, 0);
    Blynk.virtualWrite(V7,255);
      }}
  else
    {Blynk.virtualWrite(V5, 255);
    Blynk.virtualWrite(V6,0);
    Blynk.virtualWrite(V7,0);}
    //-----------------END----------------//
}


//-----------------------------------------Notification Coding--------------------------------------------//
void notifyOnButtonPress()
{
  // Invert state, since button is "Active LOW"
  int isButtonPressed = !digitalRead(7);
  if (isButtonPressed) {
    SwSerial.println("Button is pressed.");

    // Note:
    //   We allow 1 notification per 15 seconds for now.
    Blynk.notify("Yaaay... button is pressed!");
  }
}

//--------------------------------------------END---------------------------------------------------------//


void setup()
{
pinMode(A1,INPUT);
/*pinMode(A1,INPUT);
pinMode(13,OUTPUT);
pinMode(2,OUTPUT);
pinMode(4,OUTPUT);*/
  
  // Debug console
  SwSerial.begin(9600);

  // Blynk will work through Serial
  // Do not read or write this serial manually in your sketch
  Serial.begin(9600);
  Blynk.begin(Serial, auth);

  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
 // timer.setInterval(6000L,  notifyOnButtonPress);

  //--------------------------Notification Code----------------------------------//
   Blynk.notify("Device started");
  // Setup notification button on pin 2
  pinMode(7, INPUT_PULLUP);
  // Attach pin 2 interrupt to our handler
  attachInterrupt(digitalPinToInterrupt(7), notifyOnButtonPress, CHANGE);
  //--------------------------------END------------------------------------------//
}

void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
}

Thanks

  1. Your code is badly structured (e.g. declaring terminal in timer?)
  2. Do we really need to go through all the commented out sections?
  3. If you think something is not working - use a simple sketch and check if it works. If it does - integrate it into your project.

http://examples.blynk.cc

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "YourAuthToken";
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

BlynkTimer timer;

void notifyUptime()
{
  long uptime = millis() / 60000L;
  Blynk.notify(String("Running for ") + uptime + " minutes.");
}

void setup()
{
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  Blynk.notify("Device started");

  timer.setInterval(60000L, notifyUptime);
}

void loop()
{
  Blynk.run();
  timer.run();
}
3 Likes

Thanks for the reply
And ok sir I am gonna try it simply then go for this one
@Pavel

@Pavel Sir this one is solved
Thanks for everything
Blynk The Best