e mail alert help

hello every one!!
first of all i want to tell you that i am newbie in coding, and all my work is
most copy and paste from here and there.
i have make a controller for my aquarium that runs almost a year
it is a nano arduino with esp8266-01 and control a water refill system from
an optic IR sensor (auto and manual),also watching a battery voltage for
for power backup,control an on off lights relay , a fan relay,and a temperature
monitor.BUT i dont want to stop here ,in the future i want to add a Ph meter
from Atlas ,and some other staff.
My question is that: can i somehow get an email alert without running the blynk app
all the time. because when running continuously it draws my cellphone battery to
quickly.


/*Comment this out to disable prints and save space */
//#define BLYNK_PRINT Serial

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <TimeLib.h>    // need for server time
#include <WidgetRTC.h>  // need for server time

#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 7       //////////////////////////////////      Data wire is plugged into pin 7 on the Arduino
 OneWire oneWire(ONE_WIRE_BUS);
 DallasTemperature sensors(&oneWire);
 
char auth[] = "..............................";
char ssid[] = "............";
char pass[] = ".......................";

#include <SoftwareSerial.h>
          SoftwareSerial EspSerial(10,11); // RX, TX (exodos arduino)
   #define ESP8266_BAUD 9600
           ESP8266 wifi(&EspSerial); 

           BlynkTimer timer_4 ;   //////////////////////////////////////   DECLARE A TIMER AS  " timer_4 "            
           WidgetRTC rtc;         // for clock
           
////////////////////////////////////////////////////////////////////////   PINS
const int   RelayPin3     =3;             // AC-3
const int   RelayPin4     =4;             // AC-4
const int   analogPin     =0;             // optic sensor
const int   analogPinV    =1;             // voltmeter
const int   PumpPin       =13;            // AC-1
const int   LightsPin     =2;             // AC-2
const int   FanPin        =5;             // DC1
const int   VaccumPumpPin =6;             // DC2
///////////////////////////////////////////////////////////////////////   VARIABLES BLYNK
int    LightsOn   =11;
int    LightsOff  =21; 
int    V;
int    Slide ;
int    Counter =0;
String LastReffil  ;
String LastContact ;

float       AlphaTemp;
float       Corecting=0;
int         SetChangeTemp = 25; 

const uint16_t flash_time = 1000; 
/////////////////////////////////////////////////////////////////////         OTHER VARIABLES FOL LOOP SECTION

unsigned long MaxRunTime     =10*1000L;        //  ( 1 minute = 60*1000L ) max pump run
unsigned long MinOffTime     =60*60*1000L;     //  ( 1 hour = 60*60*1000L ) debounce
unsigned long    FanOff      = 5*60*1000L;     //   ON(reverse relay)
unsigned long    FanOn       = 10*60*1000L;    //   OFF (reverse relay)

          int                  WaterState; 
          boolean       PumpRunning=false;
          int        LastWaterState =HIGH;
unsigned long       PreviousPumpMillis =0;
int                 FanState = LOW;
unsigned long    PreviousFanMillis =0;
//////////////////////////////////////////////////////////////////////    synchronize blynk with server
bool isFirstConnect = true;
BLYNK_CONNECTED() {
  if (isFirstConnect) {
    Blynk.syncAll();
    isFirstConnect = false;
  }
  rtc.begin();
}
////////////////////////////////////////////////////////////////////////    check connection
void checkBlynk(){ 
      bool isconnected = Blynk.connected();
      if (isconnected == false){
         Blynk.virtualWrite(V13,LightsOff); 
         digitalWrite(LightsPin,LOW);
      }
}
////////////////////////////////////////////////////////////////////////    relay_action   FUNCTION
void Relay() {  
    unsigned long x = millis();
    while(millis() - x < (flash_time*Slide)){ 
        digitalWrite(PumpPin, HIGH);
        yield();
    } 
} 
///////////////////////////////////////////////////////////////////////     CLOCK         FUNCTION
void Clock()
{
  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  //      String currentDate = String(day()) + " " + month() + " " + year();
  Blynk.virtualWrite(V7, currentTime);
  //      Blynk.virtualWrite(V10, currentDate);
} 
///////////////////////////////////////////////////////////////////////     VOLTMETER
void VoltMeter()
{
float       Vout=0.0; 
float       Vin =0.0;
float       R1  =102000.0;  //true   (106000.0)          
float       R2  =65000.0 ;  //true   (47000.0)           
int         Value =0; 
  Value= analogRead(analogPinV);    // read analog pin 1
  Vout=(Value*5)/1024.0;
  Vin =Vout/(R2/(R1+R2));
  if(Vin<0.09){Vin=0.0;}
  Blynk.virtualWrite(V17,Vin);
}  
///////////////////////////////////////////////////////////////////////     Lights         FUNCTION
void Lights()
{
     Blynk.virtualWrite(V12,LightsOn); 
     Blynk.virtualWrite(V13,LightsOff); 
             if (hour()>=LightsOn && hour()<LightsOff){
                     digitalWrite(LightsPin,HIGH);}
                else{digitalWrite(LightsPin,LOW);}  
}
/////////////////////////////////////////////////////////////////        temp fuction
void TempFuction(){
    sensors.requestTemperatures(); 
    //Serial.println(sensors.getTempCByIndex(0)); 
 
     AlphaTemp=(sensors.getTempCByIndex(0));
     AlphaTemp=AlphaTemp+Corecting;
 Blynk.virtualWrite(V21, AlphaTemp); // Temperature for gauge
 Blynk.virtualWrite(V22,AlphaTemp); // Temperature for graph // or V13,sensors.getTempCByIndex(0));
     AlphaTemp=AlphaTemp-Corecting;
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////      functions in time    ////////////////////////////////////////////////////////////
void TimeFunctions()    // functions in timers
{
Blynk.virtualWrite(V9,V);
Blynk.virtualWrite(V6,Counter);   if(Counter>20){Counter=0; } 
Clock();
Lights();
VoltMeter();
TempFuction();
Blynk.virtualWrite(V8,LastReffil);  // sendSensor();
Blynk.virtualWrite(V11,LastContact); //last time optic sensor hit water
Blynk.virtualWrite(V20,(MaxRunTime/1000));
Blynk.virtualWrite(V0,(FanOn/60000));
Blynk.virtualWrite(V10,(FanOff/60000));
Blynk.virtualWrite(V23, SetChangeTemp);
Blynk.virtualWrite(V24, Corecting);
}
//////////////////////////////////////////////////////////////////      TARGET TEMP SETPOINT
BLYNK_WRITE(V26)        // set
{
 SetChangeTemp = SetChangeTemp + param.asInt(); 
}
//////////////////////////////////////////////////////////////////      TEMP CORECTION SETPOINT
BLYNK_WRITE(V27)        // set
{
 Corecting = Corecting + param.asFloat(); 
}
BLYNK_WRITE(V19)        // set
{
 MaxRunTime = MaxRunTime + param.asInt(); 
}
BLYNK_WRITE(V14)        // set
{
 LightsOn = LightsOn + param.asInt(); 
}
BLYNK_WRITE(V15)        // set
{
 LightsOff = LightsOff + param.asInt(); 
}
BLYNK_WRITE(V16)        // set
{
 FanOn = FanOn  + param.asInt(); 
}
BLYNK_WRITE(V18)        // set
{
 FanOff = FanOff  + param.asInt(); 
}
////////////////////////////////////////////////////////////////////////      RELAY BUTTON REFFIL ON TIME FROM SLIDE
BLYNK_WRITE(V1)  //RelayPin4
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
      // process received value
      if(pinValue==0){digitalWrite(PumpPin,LOW);}
      if(pinValue==1){         
                       Relay();
                       digitalWrite(PumpPin,LOW); 
                       Blynk.virtualWrite(V1, 0); // "Blynk.virtualWrite(V1, 0);"(update app button 0=off/255=on)
                       Blynk.virtualWrite(V3, 0);
                       Counter=Counter+1;
                       LastReffil=String(hour()) + ":" + minute() ; 
                      }
}
///////////////////////////////////////////////////////////////////////        SLIDE
BLYNK_WRITE(V2)
{
 int A = param.asInt(); 
  Slide=A;
}
///////////////////////////////////////////////////////////////////////      RELAY BUTTON REFFIL PUSH
BLYNK_WRITE(V3)  // relaypin4
{
  int pinValue = param.asInt(); // assigning incoming value from pin V3 to a variable
      // process received value
      if(pinValue==0){digitalWrite(RelayPin4,LOW);}
      if(pinValue==1){ digitalWrite(RelayPin4,HIGH);}
                           
}  
///////////////////////////////////////////////////////////////////////     RELAY BUTTON FREE
BLYNK_WRITE(V4)  // RelayPin3
{
  int pinValue = param.asInt(); // assigning incoming value from pin V3 to a variable  
      if(pinValue==0){digitalWrite(RelayPin3,LOW);}
      if(pinValue==1){ digitalWrite(RelayPin3,HIGH);}
                           
}
////////// ///////////////////////////////////////////////////////////        CounterZero 
BLYNK_WRITE(V5)  // CounterZero
{
  int pinValue = param.asInt(); // assigning incoming value from pin V5 to a variable  
      if(pinValue==1){ Counter=0;}
}
///////////////////////////////////////////////////////////////////////     VaccumPump
BLYNK_WRITE(V25)  
{
  int pinValue = param.asInt(); // assigning incoming value from pin V25 to a variable  
      if(pinValue==0){digitalWrite( VaccumPumpPin,LOW);}
      if(pinValue==1){ digitalWrite( VaccumPumpPin,HIGH);}
                           
}
/////////////////////////////////////////////////////////////////////   SETUP   //////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
  delay(300000UL);
sensors.begin();
pinMode(analogPinV,INPUT);
pinMode(analogPin,INPUT);
pinMode(PumpPin,OUTPUT);
pinMode(LightsPin,OUTPUT);
pinMode(FanPin,OUTPUT);
pinMode(RelayPin4,OUTPUT);
pinMode(RelayPin3,OUTPUT);
pinMode(VaccumPumpPin,OUTPUT);
//Serial.begin(9600);
EspSerial.begin(ESP8266_BAUD);
delay(10); 
Blynk.begin(auth, wifi, ssid, pass);
timer_4.setInterval(4000L,TimeFunctions);   // start timer
}

///////////////////////////////////////////////////////////////////       LOOP   ////////////////////////////////////////////////////////////////////////
void loop() {

    unsigned long CurrentMillis = millis();
            
              V = analogRead(0);
              V= map(V,0,1023,0,255);       
    if       (V<90)
         { 
          WaterState =HIGH;  // close pump
          LastContact=String(hour()) + ":" + minute() ;
         }      
     else{  
         if(V>=90)
         {
          WaterState =LOW;  // open pump
         }      

        }
  if (WaterState != LastWaterState){ PreviousPumpMillis = CurrentMillis;}
  
     if(PumpRunning==true){           
      if ((WaterState== HIGH )  || ((CurrentMillis-PreviousPumpMillis)>=MaxRunTime))
             {digitalWrite(PumpPin,LOW); 
             PumpRunning=false;
             PreviousPumpMillis=CurrentMillis;
             }}
     else { if (( WaterState== LOW ) &&(CurrentMillis-PreviousPumpMillis >= MinOffTime))       
             {digitalWrite(PumpPin,HIGH);   
             PumpRunning=true;
             PreviousPumpMillis=CurrentMillis;
             Counter=Counter+1;
             LastReffil=String(hour()) + ":" + minute() ;
             }}
             LastWaterState = WaterState;
     //  Serial.print(V); //  delete(//) for check for false optic sensor
      // Serial.println();  
 ////////////////////////////////////////////////////////////////////////       FAN
          if((FanState == HIGH)&&(CurrentMillis-PreviousFanMillis>=FanOn))
    {
      FanState = LOW;
      PreviousFanMillis = CurrentMillis;
      digitalWrite(FanPin,FanState);
    }
    else if((FanState == LOW)&&(CurrentMillis-PreviousFanMillis>=FanOff))
      {
      FanState = HIGH;
      PreviousFanMillis = CurrentMillis;
      digitalWrite(FanPin,FanState); 
      } 
///////////////////////////////////////////////////////////////////////////   BLYNK  /////////////////////////////////////////////////////////////////
Blynk.run();
timer_4.run(); // Initiates SimpleTimer 
                   
} // close loop
             
   
             



you dont need the app to be active on your phone. When you send an email from your code, the email is sent by the Blynk servers to the recipient.

You might want to read this document… You already have BlynkTimer used in some places, so adding additional timers instead of all those millis() comparisons in your void loop() is well worth considering.

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

And as mentioned, email is NOT active App dependent (aside from the email widget being present… which I can’t recall if even that is still needed).

But I have not found any Blynk.email() command in your code anyhow?? So I am unsure of your actual dilemma.

thank you for your advise.
i make some changes to keep my loop clean,and i ad an email alert example
in the voltmeter function.
when the app is on play mode(running) i get the mail normal.
but when the app is on stop mode (not running) i dont get any mail.
what i am not doing right…what i am missing

///////////////////////////////////////////////////////////////////////     VOLTMETER
void VoltMeter()
{
float       Vout=0.0; 
float       Vin =0.0;
float       R1  =102000.0;  //true   (106000.0)          
float       R2  =65000.0 ;  //true   (47000.0)           
int         Value =0; 
  Value= analogRead(analogPinV);    // read analog pin 1
  Vout=(Value*5)/1024.0;
  Vin =Vout/(R2/(R1+R2));
  if(Vin<0.09){Vin=0.0;}
  Blynk.virtualWrite(V17,Vin);
   if (first_time) {
                   if(Vin<=12.5){
                               Blynk.email("tatas_jr@hotmail.com","Subject: low voltage", "volt is <12.5");
                               }      
                   first_time = false;
                   }
  if(Vin>12.5){
     first_time = true;
  }
}

Backticks, not commas…

Blynk%20-%20FTFC

Not a clue… you are not showing full code, so we have no idea how you are calling your email command.

Perhaps you are using BLYNK_READ() functions, which require the App to be active for an associated Widget with it’s reading rate set to control timing?? Who knows.

i am sorry
here is foul code


/*Comment this out to disable prints and save space */
//#define BLYNK_PRINT Serial

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <TimeLib.h>    // need for server time
#include <WidgetRTC.h>  // need for server time

#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 7       //////////////////////////////////      Data wire is plugged into pin 7 on the Arduino
 OneWire oneWire(ONE_WIRE_BUS);
 DallasTemperature sensors(&oneWire);
 
char auth[] = ".........................";
char ssid[] = "............";
char pass[] = "...........................";

#include <SoftwareSerial.h>
          SoftwareSerial EspSerial(10,11); // RX, TX (exodos arduino)
   #define ESP8266_BAUD 9600
           ESP8266 wifi(&EspSerial); 

           BlynkTimer timer_4 ;   //////////////////////////////////////   DECLARE A TIMER AS  " timer_4 "            
           WidgetRTC rtc;         // for clock
           
////////////////////////////////////////////////////////////////////////   PINS
const int   RelayPin3     =3;             // AC-3
const int   RelayPin4     =4;             // AC-4
const int   analogPin     =0;             // optic sensor
const int   analogPinV    =1;             // voltmeter
const int   PumpPin       =13;            // AC-1
const int   LightsPin     =2;             // AC-2
const int   FanPin        =5;             // DC1
const int   VaccumPumpPin =6;             // DC2
///////////////////////////////////////////////////////////////////////   VARIABLES BLYNK
int    LightsOn   =11;
int    LightsOff  =21; 
int    V;
int    Slide ;
int    Counter =0;
String LastReffil  ;
String LastContact ;

float       AlphaTemp;
float       Corecting=0;
int         SetChangeTemp = 25; 
bool first_time = true;             // for email send one time
const uint16_t flash_time = 1000; 
/////////////////////////////////////////////////////////////////////         OTHER VARIABLES FOL LOOP SECTION

unsigned long MaxRunTime     =10*1000L;        //  ( 1 minute = 60*1000L ) max pump run
unsigned long MinOffTime     =60*60*1000L;     //  ( 1 hour = 60*60*1000L ) debounce
unsigned long    FanOff      = 5*60*1000L;     //   ON(reverse relay)
unsigned long    FanOn       = 10*60*1000L;    //   OFF (reverse relay)

          int                  WaterState; 
          boolean       PumpRunning=false;
          int        LastWaterState =HIGH;
unsigned long       PreviousPumpMillis =0;
int                 FanState = LOW;
unsigned long    PreviousFanMillis =0;


//////////////////////////////////////////////////////////////////////    synchronize blynk with server
bool isFirstConnect = true;
BLYNK_CONNECTED() {
  if (isFirstConnect) {
    Blynk.syncAll();
    isFirstConnect = false;
  }
  rtc.begin();
}
////////////////////////////////////////////////////////////////////////    check connection
void checkBlynk(){ 
      bool isconnected = Blynk.connected();
      if (isconnected == false){
         Blynk.virtualWrite(V13,LightsOff); 
         digitalWrite(LightsPin,LOW);
      }
}
////////////////////////////////////////////////////////////////////////    relay_action   FUNCTION
void Relay() {  
    unsigned long x = millis();
    while(millis() - x < (flash_time*Slide)){ 
        digitalWrite(PumpPin, HIGH);
        yield();
    } 
} 
///////////////////////////////////////////////////////////////////////     CLOCK         FUNCTION
void Clock()
{
  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  //      String currentDate = String(day()) + " " + month() + " " + year();
  Blynk.virtualWrite(V7, currentTime);
  //      Blynk.virtualWrite(V10, currentDate);
} 
///////////////////////////////////////////////////////////////////////     VOLTMETER
void VoltMeter()
{
float       Vout=0.0; 
float       Vin =0.0;
float       R1  =102000.0;  //true   (106000.0)          
float       R2  =65000.0 ;  //true   (47000.0)           
int         Value =0; 
  Value= analogRead(analogPinV);    // read analog pin 1
  Vout=(Value*5)/1024.0;
  Vin =Vout/(R2/(R1+R2));
  if(Vin<0.09){Vin=0.0;}
  Blynk.virtualWrite(V17,Vin);
   if (first_time) {
                   if(Vin<=12.5){
                               Blynk.email("tatas_jr@hotmail.com","Subject: low voltage", "volt is <12.5");
                               }      
                   first_time = false;
                   }
  if(Vin>12.5){
     first_time = true;
  }
}  
///////////////////////////////////////////////////////////////////////     Lights         FUNCTION
void Lights()
{
     Blynk.virtualWrite(V12,LightsOn); 
     Blynk.virtualWrite(V13,LightsOff); 
             if (hour()>=LightsOn && hour()<LightsOff){
                     digitalWrite(LightsPin,HIGH);}
                else{digitalWrite(LightsPin,LOW);}  
}
/////////////////////////////////////////////////////////////////        temp fuction
void TempFuction(){
    sensors.requestTemperatures(); 
    //Serial.println(sensors.getTempCByIndex(0)); 
 
     AlphaTemp=(sensors.getTempCByIndex(0));
     AlphaTemp=AlphaTemp+Corecting;
 Blynk.virtualWrite(V21, AlphaTemp); // Temperature for gauge
 Blynk.virtualWrite(V22,AlphaTemp); // Temperature for graph // or V13,sensors.getTempCByIndex(0));
     AlphaTemp=AlphaTemp-Corecting;
}
///////////////////////////////////////////////////////////////////      fan function
void fan (){ 
      unsigned long CurrentMillis = millis();
            if((FanState == HIGH)&&(CurrentMillis-PreviousFanMillis>=FanOn))
    {
      FanState = LOW;
      PreviousFanMillis = CurrentMillis;
      digitalWrite(FanPin,FanState);
    }
    else if((FanState == LOW)&&(CurrentMillis-PreviousFanMillis>=FanOff))
      {
      FanState = HIGH;
      PreviousFanMillis = CurrentMillis;
      digitalWrite(FanPin,FanState); 
      } 
}
//////////////////////////////////////////////////////////////////////      refill
void refill(){
 unsigned long  CurrentMillis = millis();
            
              V = analogRead(0);
              V= map(V,0,1023,0,255);       
    if       (V<90)
         { 
          WaterState =HIGH;  // close pump
          LastContact=String(hour()) + ":" + minute() ;
         }      
     else{  
         if(V>=90)
         {
          WaterState =LOW;  // open pump
         }      

        }
  if (WaterState != LastWaterState){ PreviousPumpMillis = CurrentMillis;}
  
     if(PumpRunning==true){           
      if ((WaterState== HIGH )  || ((CurrentMillis-PreviousPumpMillis)>=MaxRunTime))
             {digitalWrite(PumpPin,LOW); 
             PumpRunning=false;
             PreviousPumpMillis=CurrentMillis;
             }}
     else { if (( WaterState== LOW ) &&(CurrentMillis-PreviousPumpMillis >= MinOffTime))       
             {digitalWrite(PumpPin,HIGH);   
             PumpRunning=true;
             PreviousPumpMillis=CurrentMillis;
             Counter=Counter+1;
             LastReffil=String(hour()) + ":" + minute() ;
             }}
             LastWaterState = WaterState;
     //  Serial.print(V); //  delete(//) for check for false optic sensor
      // Serial.println(); 
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////      functions in time    ////////////////////////////////////////////////////////////
void TimeFunctions()    // functions in timers
{
Blynk.virtualWrite(V9,V);
Blynk.virtualWrite(V6,Counter);   if(Counter>20){Counter=0; } 
Clock();
Lights();
VoltMeter();
TempFuction();
fan();
refill();
Blynk.virtualWrite(V8,LastReffil);  // sendSensor();
Blynk.virtualWrite(V11,LastContact); //last time optic sensor hit water
Blynk.virtualWrite(V20,(MaxRunTime/1000));
Blynk.virtualWrite(V0,(FanOn/60000));
Blynk.virtualWrite(V10,(FanOff/60000));
Blynk.virtualWrite(V23, SetChangeTemp);
Blynk.virtualWrite(V24, Corecting);
}
//////////////////////////////////////////////////////////////////      TARGET TEMP SETPOINT
BLYNK_WRITE(V26)        // set
{
 SetChangeTemp = SetChangeTemp + param.asInt(); 
}
//////////////////////////////////////////////////////////////////      TEMP CORECTION SETPOINT
BLYNK_WRITE(V27)        // set
{
 Corecting = Corecting + param.asFloat(); 
}
BLYNK_WRITE(V19)        // set
{
 MaxRunTime = MaxRunTime + param.asInt(); 
}
BLYNK_WRITE(V14)        // set
{
 LightsOn = LightsOn + param.asInt(); 
}
BLYNK_WRITE(V15)        // set
{
 LightsOff = LightsOff + param.asInt(); 
}
BLYNK_WRITE(V16)        // set
{
 FanOn = FanOn  + param.asInt(); 
}
BLYNK_WRITE(V18)        // set
{
 FanOff = FanOff  + param.asInt(); 
}
////////////////////////////////////////////////////////////////////////      RELAY BUTTON REFFIL ON TIME FROM SLIDE
BLYNK_WRITE(V1)  //RelayPin4
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
      // process received value
      if(pinValue==0){digitalWrite(PumpPin,LOW);}
      if(pinValue==1){         
                       Relay();
                       digitalWrite(PumpPin,LOW); 
                       Blynk.virtualWrite(V1, 0); // "Blynk.virtualWrite(V1, 0);"(update app button 0=off/255=on)
                       Blynk.virtualWrite(V3, 0);
                       Counter=Counter+1;
                       LastReffil=String(hour()) + ":" + minute() ; 
                      }
}
///////////////////////////////////////////////////////////////////////        SLIDE
BLYNK_WRITE(V2)
{
 int A = param.asInt(); 
  Slide=A;
}
///////////////////////////////////////////////////////////////////////      RELAY BUTTON REFFIL PUSH
BLYNK_WRITE(V3)  // relaypin4
{
  int pinValue = param.asInt(); // assigning incoming value from pin V3 to a variable
      // process received value
      if(pinValue==0){digitalWrite(RelayPin4,LOW);}
      if(pinValue==1){ digitalWrite(RelayPin4,HIGH);}
                           
}  
///////////////////////////////////////////////////////////////////////     RELAY BUTTON FREE
BLYNK_WRITE(V4)  // RelayPin3
{
  int pinValue = param.asInt(); // assigning incoming value from pin V3 to a variable  
      if(pinValue==0){digitalWrite(RelayPin3,LOW);}
      if(pinValue==1){ digitalWrite(RelayPin3,HIGH);}
                           
}
////////// ///////////////////////////////////////////////////////////        CounterZero 
BLYNK_WRITE(V5)  // CounterZero
{
  int pinValue = param.asInt(); // assigning incoming value from pin V5 to a variable  
      if(pinValue==1){ Counter=0;}
}
///////////////////////////////////////////////////////////////////////     VaccumPump
BLYNK_WRITE(V25)  
{
  int pinValue = param.asInt(); // assigning incoming value from pin V25 to a variable  
      if(pinValue==0){digitalWrite( VaccumPumpPin,LOW);}
      if(pinValue==1){ digitalWrite( VaccumPumpPin,HIGH);}
                           
}
/////////////////////////////////////////////////////////////////////   SETUP   //////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
 // delay(300000UL);
sensors.begin();
pinMode(analogPinV,INPUT);
pinMode(analogPin,INPUT);
pinMode(PumpPin,OUTPUT);
pinMode(LightsPin,OUTPUT);
pinMode(FanPin,OUTPUT);
pinMode(RelayPin4,OUTPUT);
pinMode(RelayPin3,OUTPUT);
pinMode(VaccumPumpPin,OUTPUT);
//Serial.begin(9600);
EspSerial.begin(ESP8266_BAUD);
delay(10); 
Blynk.begin(auth, wifi, ssid, pass);
timer_4.setInterval(4000L,TimeFunctions);   // start timer
}

///////////////////////////////////////////////////////////////////       LOOP   ////////////////////////////////////////////////////////////////////////
void loop() {
Blynk.run();
timer_4.run(); // Initiates SimpleTimer 
                   
} // close loop
             
   
             ```

This is as expected.
Leave the app running, when you close the Blynk app on the phone.

It is a bit misleading, but there are two modes in the app: run and edit.

When in run mode the app runs on your phone and also the hardware talks to the Blynk server.
When in edit mode, the sketch on the hardware no longer talks to the server.

Hit the play button in the phone, then close the Blynk app.

Hmm, OK, @tatas I have to retract this statement as my recent tests confirm that email will NOT be sent when App in not in active mode (nor will notifications) :thinking:. I am sure this was not always the case, but then it has been awhile since I last worked extensively with email tests in my projects.

The Server WILL get the command from the sketch, as later evidenced when the App is set to run (active) mode, I see the resultant vPin data, but the Server will not actually process the email (or notification).

@Dmitriy did something change? or just my memory that got switched to inactive mode :stuck_out_tongue:

However, this is NOT true. Even if the App itself is shutdown with the project in edit mode, all other Blynk.virtualWrite() and other such commands will keep getting data sent to and received from the server, as evidenced by later super chart readings and other device feedbacks.

And you can even keep controlling and get feedback via API commands in realtime (I used the browser to test).

I know im late to the party… but @tatas, am i missing the email widget in the project?

Or is it just below the page or something?

BTW, this shouldn’t be an issue. Just leave your project running (play mode), then close out the App (AKA even swipe it from recent tasks if needed - just don’t LOG out). Email WILL still work, and at least in my case, my phone doesn’t even register the Blynk app as a battery drain when in the “background” like that.

Which basically makes the whole “will email work if in edit mode” a non-issue… unless you really want emails when editing your project :stuck_out_tongue:

The battery drain register of blynk App independent of the other programs use too.
my cellphone battery last about 12 hours(medium-high use).with blynk App running last almost the half.
But at the bottom of this i want to say that Blynk is a great platform and
i meaning that, but when we are talking for full security projects like
fire detectors
leakage prevention
dangerous gass avoidance
medical support systems
production sensitive parameters
and others…++
i thing it is wise to have a double lock security-alarm that is not foul
independent on App running(other people get alarm too without having
blynk, or get alarm at office pc because i lost my cellphone).
I wish blynk support this in the future
because it is going to be a next level
upgrade in my opinion.
Thank you all for your support and your answers.

To be honest, I think that the real strength of Blynk is that it allows you to produce extremely powerful and sophisticated apps at virtually no cost. On the hardware side, the library is also very powerful and easy to use - and very stable.

Things like Blynk alerts are fairly basic in their functionality, but generally work okay for most situations. Personally I prefer to use a notification service like Pushover or Pushbullet as it has much more functionality and works across multiple platforms.

Obviously if someone is looking at a commercial system where notifications are essential then they should be thinking about signing-up to Blynk’s paid-for service and asking for customisation that provides a solution to all of their needs.

Virtually all of the scenarios you’ve listed here are things that ought to be treated as commercial solutions, requiring enhanced features, dedicated servers and enhances support services. Building a mission critical on a free developer platform isn’t the way to run a business in my opinion.

Pete.

2 Likes

Not sure why you are still talking about phone battery life with regards to notifications.

Try it.

  • Start an app that sends you an email once per minute.
  • Power your phone off completely to prove to yourself that it is not needed for the app to be running and for the Blynk servers to send notifications
  • While your phone is off, you will get emails in your email inbox.
  • After a few minutes, start you phone again.
  • You will see that emails were sent while your phone was off.