BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Mega blynk timer function hell

Im wondering if anyone can help me. Im very new to arduino and blynk and am having some difficulties with my project. I’m using an arduino mega wifi r3 with esp8266 to connect to blynk. I believe I am flooding the server because my app just keeps disconnecting and I just cant seem to figure it out. I am building a controller to control a pump and soil moisture sensors, any advice or suggestions would be greatly appreciated!

#include <SPI.h>
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "REDACTED";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "REDACTED";
char pass[] = "REDACTED";

#define WATER_PUMP1                27                  // relay pin
#define VPIN_PUMP1ON               V14                 // Blynk button to control relay
#define VPIN_SLIDERTIMEON_PUMP1    V16                 // blynk app Numeric Input Widget



                  // Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial3

                  // or Software Serial on Uno, Nano...
                  //#include <SoftwareSerial.h>
                  //SoftwareSerial EspSerial(2, 3); // RX, TX

                  // Your ESP8266 baud rate:
#define ESP8266_BAUD 115200


ESP8266 wifi(&EspSerial);

int buttonState;                           //expecting 0 or 1
float stepValue;                           //expecting 0.00-80.00
float ml;                             //Step Widget to determine amount of ml/Output 0-80/Step 0.2
uint32_t startCount;                       //Millis reference used to calculate stopCount
uint32_t stopCount;                        //
uint32_t multiplier = 858;                 //Number of milliseconds for motor to produce 1ml of liquid
BlynkTimer timer; // Announcing the timer

WidgetTerminal terminal(V18);

//int solenoidPin = 30;                                   // solenoid valve pin

const int AirValue            = 620;                           //you need to replace this value with Value_1
const int WaterValue          = 280;                           //you need to replace this value with Value_2
int       soilMoistureValue   = 0;
int       soilmoisturepercent = 0;



void checkPump()
{
  if (buttonState == 1)
  {
    ml = stepValue * multiplier;             //Step Widget Value times Calibration Multiplier
    startCount = millis();              //Reference the Millis count
    stopCount = ml + startCount;
    terminal.print("stepValue is: ");
    terminal.println(stepValue);
    terminal.print("ml: ");
    terminal.println(ml);
    terminal.print("startCount is: ");
    terminal.println(startCount);
    terminal.print("stopCount is: ");
    terminal.println(stopCount);
    Blynk.virtualWrite(buttonState, 0);
    terminal.flush();
  }

  if (stopCount <= (millis() - startCount))            //If V0 x multi + start is less than or equal to total millis
  {
    digitalWrite(WATER_PUMP1, HIGH);
    terminal.println("LED");
    terminal.flush();
  }
  else (buttonState = 0);
  {
    ml = 0;
    startCount = 0;
    stopCount = 0;
    digitalWrite(WATER_PUMP1, LOW);
  }
}


// This function tells Arduino what to do if there is a Widget
// which is requesting data for Virtual Pin (5)
//BLYNK_READ(V0)
// Push Soil Sensor values to Blynk graph
void soilsensorDataSend()
//                    Capacitive Soil Moisture Sensor V1.2     A1
{
  soilMoistureValue   = analogRead(A4);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

  Blynk.virtualWrite(V0, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     A2

  soilMoistureValue   = analogRead(A5);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

  Blynk.virtualWrite(V1, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     A3

  soilMoistureValue   = analogRead(A6);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

  Blynk.virtualWrite(V2, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     A4

  soilMoistureValue   = analogRead(A7);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

  Blynk.virtualWrite(V3, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     B1

  soilMoistureValue   = analogRead(A8);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

  Blynk.virtualWrite(V4, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     B2

  soilMoistureValue   = analogRead(A9);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

  Blynk.virtualWrite(V5, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     B3

  soilMoistureValue   = analogRead(A10);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

  Blynk.virtualWrite(V6, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     B4

  soilMoistureValue   = analogRead(A11);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

  Blynk.virtualWrite(V7, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     C1

  soilMoistureValue   = analogRead(A12);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

  Blynk.virtualWrite(V8, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     C2

  soilMoistureValue   = analogRead(A13);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

  Blynk.virtualWrite(V9, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     C3

  soilMoistureValue   = analogRead(A14);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

  Blynk.virtualWrite(V10, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     C4

  soilMoistureValue   = analogRead(A15);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V11, soilmoisturepercent);  // sending sensor value to Blynk app


}
void setup()
{
  // Debug console
  Serial.begin(9600);
  pinMode(WATER_PUMP1, OUTPUT);
  //pinMode(solenoidPin, OUTPUT);
  
  

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  Blynk.begin(auth, wifi, ssid, pass);
  while (Blynk.connect() == false) {}
  timer.setInterval(2000L, soilsensorDataSend); //timer will run every 2 sec
  timer.setInterval(3000L, checkPump); //timer will run every 3 sec


  Blynk.syncVirtual(V14);


  // You can also specify server:
  //Blynk.begin(auth, wifi, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8080);
}

void loop()
{
  Blynk.run();
  timer.run();       // run timer every second
}

// set as globals


BLYNK_WRITE(V14) { // blynk button
  buttonState = param.asInt();             // set the global button state as ON or OFF
  Serial.println(String("button state = ") + buttonState); // will output 1 or 0 to serial monitor
  Blynk.syncVirtual(V1); // trigger V1 function below to set current stepValue from widget, also put this line in setup() right after connecting to update on boot
}

BLYNK_WRITE(V16) { //blynk step widget
  stepValue = param.asFloat(); // set the global step value
  Serial.println(String("stepValue = ") + stepValue ); // will output stepValue to serial
}

I’m not sure how long it takes for your soilsensorDataSend function to execute. Adding a serial print statement at the beginning and end of the function would give you this information.

If it’s taking less than 1.2 seconds then this is what is flooding the server.
The Blynk server can cope with around one virtual write every 0.1 seconds, or 10 per second.
There are a number of ways to get around this, the simplest may be to add a small delay between each sensor read operation - but understanding how long the function takes to execute is the first step.

Also, doing a terminal.print is in effect the same as a Blynk.virtualWrite - it’s sending data to the server that the server has to process, so your checkPump function is doing the equivalent of 10 virtual writes every time it executes when buttonState == 1

Also, you have timers set at 2 and 3 second intervals, so every 6 seconds both timers will try to run simultaneously. This cant happen in practice, because your processor is single threaded and cant multitask, but it’s adding-in a degree of unpredictability to the timing processes.

You also have an issue with the logic of your checkPump function.
It takes 858ms to pump 1ml of water. This means that a stepValue of 3.5 or more will take more than 3000ms to execute.
Your checkPump function is executing every 3000ms and if buttonState == 1 then a new startCount and stopCount value is calculated.

You’d be better-off using a lambda timeout timer to act6ivate the pump for the required period of time.

Pete.

Thank you very much for the reply! really appreciate it. I have been trying to use a serial.print to display the excution time but I cant seem to get the serial monitor to display anyhing except the BLYNK logo, connected, etc, ready. I dont think i have the proper understanding. I am trying to graph the data over time with the super chart widget so I would only need to send each sensor data once every minute or so. I have looked into the Lambda timeout timer and also not grasping the understanding of it. I just feel like I am making it more complicated then it needs to be .

With the pump, I originally was trying to control the duration of the pump relay by a blynk step widget 100-5000 mL with 100 mL steps. With each step of 100 mL calibrated with an equation and variable to determine length of time a relay is on depending on the pump flow output. I was then told I cant do this and have to incorporate the terminal to display this information and a widget displaying 0-80 to calculate desired mL of water output and then mL outputted to terminal which doesnt make sense to me.

#include <SPI.h>
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

// 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[] = "******";

#define WATER_PUMP1                27                  // relay pin
#define VPIN_PUMP1ON               V14                 // Blynk button to control relay
#define VPIN_SLIDERTIMEON_PUMP1    V16                 // blynk app Numeric Input Widget



                  // Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial3

                  // or Software Serial on Uno, Nano...
                  //#include <SoftwareSerial.h>
                  //SoftwareSerial EspSerial(2, 3); // RX, TX

                  // Your ESP8266 baud rate:
#define ESP8266_BAUD 115200


ESP8266 wifi(&EspSerial);

int buttonState;                           //expecting 0 or 1
float stepValue;                           //expecting 0.00-80.00
float ml;                             //Step Widget to determine amount of ml/Output 0-80/Step 0.2
uint32_t startCount;                       //Millis reference used to calculate stopCount
uint32_t stopCount;                        //
uint32_t multiplier = 858;                 //Number of milliseconds for motor to produce 1ml of liquid
BlynkTimer timer; // Announcing the timer

WidgetTerminal terminal(V18);

//int solenoidPin = 30;                                   // solenoid valve pin

const int AirValue            = 620;                           //you need to replace this value with Value_1
const int WaterValue          = 280;                           //you need to replace this value with Value_2
int       soilMoistureValue   = 0;
int       soilmoisturepercent = 0;

unsigned long sensortime;

void checkPump()
{
  if (buttonState == 1)
  {
    ml = stepValue * multiplier;             //Step Widget Value times Calibration Multiplier
    startCount = millis();              //Reference the Millis count
    stopCount = ml + startCount;
    terminal.print("stepValue is: ");
    terminal.println(stepValue);
    terminal.print("ml: ");
    terminal.println(ml);
    terminal.print("startCount is: ");
    terminal.println(startCount);
    terminal.print("stopCount is: ");
    terminal.println(stopCount);
    Blynk.virtualWrite(buttonState, 0);
    terminal.flush();
  }

  if (stopCount <= (millis() - startCount))            //If V0 x multi + start is less than or equal to total millis
  {
    digitalWrite(WATER_PUMP1, HIGH);
    terminal.println("LED");
    terminal.flush();
  }
  else buttonState = 0;
  {
    ml = 0;
    startCount = 0;
    stopCount = 0;
    digitalWrite(WATER_PUMP1, LOW);
  }
}


// This function tells Arduino what to do if there is a Widget
// which is requesting data for Virtual Pin (5)
//BLYNK_READ(V0)
// Push Soil Sensor values to Blynk graph
void soilsensorDataSend()
//                    Capacitive Soil Moisture Sensor V1.2     A1
{
  Serial.print("Sensor Start Time: ");
  sensortime = millis();

  Serial.println(sensortime); //prints time since program started
  {
    
    soilMoistureValue   = analogRead(A4);         // reading sensor from analog pin
    soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
    soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

    Blynk.virtualWrite(V0, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     A2

    soilMoistureValue   = analogRead(A5);         // reading sensor from analog pin
    soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
    soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

    Blynk.virtualWrite(V1, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     A3

    soilMoistureValue   = analogRead(A6);         // reading sensor from analog pin
    soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
    soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

    Blynk.virtualWrite(V2, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     A4

    soilMoistureValue   = analogRead(A7);         // reading sensor from analog pin
    soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
    soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

    Blynk.virtualWrite(V3, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     B1

    soilMoistureValue   = analogRead(A8);         // reading sensor from analog pin
    soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
    soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

    Blynk.virtualWrite(V4, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     B2

    soilMoistureValue   = analogRead(A9);         // reading sensor from analog pin
    soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
    soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

    Blynk.virtualWrite(V5, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     B3

    soilMoistureValue   = analogRead(A10);         // reading sensor from analog pin
    soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
    soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  
    Blynk.virtualWrite(V6, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     B4

    soilMoistureValue   = analogRead(A11);         // reading sensor from analog pin
    soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
    soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

    Blynk.virtualWrite(V7, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     C1

     soilMoistureValue   = analogRead(A12);         // reading sensor from analog pin
    soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
    soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

    Blynk.virtualWrite(V8, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     C2

    soilMoistureValue   = analogRead(A13);         // reading sensor from analog pin
    soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
    soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

    Blynk.virtualWrite(V9, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     C3

    soilMoistureValue   = analogRead(A14);         // reading sensor from analog pin
    soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
    soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);

    Blynk.virtualWrite(V10, soilmoisturepercent);  // sending sensor value to Blynk app

  //                    Capacitive Soil Moisture Sensor V1.2     C4

    soilMoistureValue   = analogRead(A15);         // reading sensor from analog pin
    soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
    soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
    Blynk.virtualWrite(V11, soilmoisturepercent);  // sending sensor value to Blynk app

    Serial.print("Sensor Stop Time: ");
    time = millis();

    Serial.println(sensortime); //prints time since program started
  }


}
void setup()
{
  // Debug console
  Serial.begin(9600);
  pinMode(WATER_PUMP1, OUTPUT);
  //pinMode(solenoidPin, OUTPUT);
  
  

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  Blynk.begin(auth, wifi, ssid, pass);
  while (Blynk.connect() == false) {}
  timer.setInterval(2000L, soilsensorDataSend); //timer will run every 2 sec
  delay(500);
  timer.setInterval(3000L, checkPump); //timer will run every 3 sec


  Blynk.syncVirtual(V14);


  // You can also specify server:
  //Blynk.begin(auth, wifi, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8080);
}

void loop()
{
  Blynk.run();
  timer.run();       // run timer every second
}

// set as globals


BLYNK_WRITE(V14) { // blynk button
  buttonState = param.asInt();             // set the global button state as ON or OFF
  Serial.println(String("button state = ") + buttonState); // will output 1 or 0 to serial monitor
  Blynk.syncVirtual(V1); // trigger V1 function below to set current stepValue from widget, also put this line in setup() right after connecting to update on boot
}

BLYNK_WRITE(V16) { //blynk step widget
  stepValue = param.asFloat(); // set the global step value
  Serial.println(String("stepValue = ") + stepValue ); // will output stepValue to serial
}

So you’re saying that these messages…

aren’t appearing in your serial monitor when the widgets attached to V14 and V16 have their values changed?

Who has told you this?

Lambda timers will help you to simplify your code rather than complicate it. It’s currently not logical and doesn’t work correctly, so rather than restructure it to solve that problem using millis() comparisons in a different way you should experiment more with Lambda timeout timer functions. I’d suggest doing some Lambda experiments in a clean sketch to get your head around how to use them first.

Pete.

So after days of trying hundreds of variations, when my code starts and I start my app, the app disconnects and reconnects repeatedly for a few minutes until it finally connects but as soon as you use pump button or step widget to control pump amount it just disconnects. I am going crazy and just cant figure out what I am doing wrong. Any help would be greatly appreciated!!!

[Unformatted code removed by moderator]

#include <SimpleTimer.h>
#include <SPI.h>
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>



// 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[] = "********************";





// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial3

// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200




ESP8266 wifi(&EspSerial);


float stepValue;                                               //expecting 0.00-80.00
const int pumpPin = 27;                                        //Pump connected @ D27                               
uint32_t multiplier = 30; 
uint32_t startPump = 0;
uint32_t runCount;
bool pumpRunning = false;
int buttonstate = 0;                                           //Button Widget set to Switch


SimpleTimer timer;                                             // SimpleTimer instance named timer

//int solenoidPin = 30;                                        // solenoid valve pin

const int AirValue            = 620;                           // sensor value in air
const int WaterValue          = 280;                           // sensor value in water
int       soilMoistureValue   = 0;
int       soilmoisturepercent = 0;

BLYNK_WRITE(V14){                                              // blynk button
  buttonstate = param.asInt();{                                // 
  if (buttonstate == 1 && pumpRunning == false)
  checkPump();
  }
}  

BLYNK_WRITE(V16){
  stepValue = param.asFloat();                                 // numeric input widget to choose mL output 0-4000. 
}

BLYNK_CONNECTED(){
 
  Blynk.syncVirtual(V16);

}
 
void checkPump()
{
  if (buttonstate == 1 && pumpRunning == false)
  {
   
    
    pumpRunning = true;
    digitalWrite(pumpPin, HIGH);
    
    startPump = millis();
    runCount = stepValue * multiplier;
    Serial.println("Water Amount: ");
    Serial.println(stepValue);
    
    Serial.println("Run Time: ");
    Serial.println(runCount);
  }
  if (millis() - startPump > runCount)
  {
    digitalWrite(pumpPin, LOW);
    Serial.println("Pump Off");
    pumpRunning = false;
    buttonstate = 0;
    
  }
}
  

//                    Capacitive Soil Moisture Sensor V1.2     A1
void soilsensorDataSend1()
{
  soilMoistureValue   = analogRead(A4);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V0, soilmoisturepercent);  // sending sensor value to Blynk app
  soilMoistureValue   = analogRead(A5);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V1, soilmoisturepercent);  // sending sensor value to Blynk app
  soilMoistureValue   = analogRead(A6);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V2, soilmoisturepercent);  // sending sensor value to Blynk app
  
  soilMoistureValue   = analogRead(A7);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V3, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A8);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V4, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A9);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V5, soilmoisturepercent);  // sending sensor value to Blynk app
}
void soilsensorDataSend2()
{
  soilMoistureValue   = analogRead(A10);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V6, soilmoisturepercent);  // sending sensor value to Blynk app
 
  soilMoistureValue   = analogRead(A11);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V7, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A12);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V8, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A13);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V9, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A14);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V10, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A15);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V11, soilmoisturepercent);  // sending sensor value to Blynk app

}


void setup()
{
  // Debug console
  Serial.begin(9600);
  
  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  pinMode(pumpPin, OUTPUT);
  //pinMode(solenoidPin, OUTPUT);
  Blynk.begin(auth, wifi, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, wifi, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, wifi, ssid, pass, IP);
  while (Blynk.connect() == false) {}
  
  timer.setInterval(3000L, checkPump); //timer will run every 2 sec
  delay(1000);
  timer.setInterval(3000L, soilsensorDataSend1); //timer will run every 2 sec
  delay(1000);
  timer.setInterval(3000L, soilsensorDataSend2); //timer will run every 2 sec
  Blynk.virtualWrite(V14, 0);   // button widget buttonstate
  Blynk.virtualWrite(V16, 0);   // numeric input widget to control stepValue - amount of mL produced by pump 0-4000 step 200
}

void loop()
{ 
  timer.run();       // run timer every second
  Blynk.run();
}
 ~~

I’d suggest adding some serial print messages at strategic points throughout your code - such as at the beginning and end of your tined functions, and immediately after your Blynk.begin command. This will help you determine the program flow and how long it is taking for your various functions to execute.

Also, why are you using SimpleTimer instead of the built-in BlynkTimer, and what is the purpose of this line of code…

Pete.

Im sorry I am really new to coding and just trying really hard to learn it. I have been reading a lot of other similar blynk projects that are having similar problems. I have tried everything I could including the “while” statement while blynk is loading. I read that it can help with the connecting process? At this point I have been trying everything. I was using the Blynktimer originally but saw someone else using the simpletimer so i thought id give it a try. I have the serial.print commands before and after functions but it doesnt look like im flooding the server? I just dont understand.

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>



// 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[] = "********************"; 





// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial3

// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200




ESP8266 wifi(&EspSerial);


float stepValue;                                               //expecting 0.00-80.00
const int pumpPin = 27;                                        //Pump connected @ D27                               
uint32_t multiplier = 30; 
uint32_t startPump = 0;
uint32_t runCount;
bool pumpRunning = false;
int buttonstate = 0;                                           //Button Widget set to Switch
BlynkTimer timer;                                             // SimpleTimer instance named timer

//int solenoidPin = 30;                                        // solenoid valve pin

const int AirValue            = 620;                           // sensor value in air
const int WaterValue          = 280;                           // sensor value in water
int       soilMoistureValue   = 0;
int       soilmoisturepercent = 0;

BLYNK_WRITE(V14){                                              // blynk button
  buttonstate = param.asInt();{                                // 
  if (buttonstate == 1 && pumpRunning == false)
  checkPump();
  }
}  

BLYNK_WRITE(V16){
  stepValue = param.asFloat();                                 // numeric input widget to choose mL output 0-4000. 
}

BLYNK_CONNECTED(){
 
  Blynk.syncVirtual(V16);

}
 
void checkPump()
{
   Serial.println("checkpump start");
  
  if (buttonstate == 1 && pumpRunning == false)
  {
   
    
    pumpRunning = true;
    digitalWrite(pumpPin, HIGH);
    
    startPump = millis();
    runCount = stepValue * multiplier;
    Serial.println("Water Amount: ");
    Serial.println(stepValue);
    
    Serial.println("Run Time: ");
    Serial.println(runCount);
  }
  if (millis() - startPump > runCount)
  {
    digitalWrite(pumpPin, LOW);
    Serial.println("Pump Off");
    pumpRunning = false;
    buttonstate = 0;
    
  }
  Serial.println("checkpump end");
}
  

//                    Capacitive Soil Moisture Sensor V1.2     A1
void soilsensorDataSend1()
{
  Serial.println("Soil data sensor send 1 start");
  
  soilMoistureValue   = analogRead(A4);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V0, soilmoisturepercent);  // sending sensor value to Blynk app
  soilMoistureValue   = analogRead(A5);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V1, soilmoisturepercent);  // sending sensor value to Blynk app
  soilMoistureValue   = analogRead(A6);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V2, soilmoisturepercent);  // sending sensor value to Blynk app
  
  soilMoistureValue   = analogRead(A7);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V3, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A8);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V4, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A9);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V5, soilmoisturepercent);  // sending sensor value to Blynk app

  Serial.println("Soil data sensor send 1 end");
}
void soilsensorDataSend2()
{
  Serial.println("Soil data sensor send 2 start");
  
  soilMoistureValue   = analogRead(A10);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V6, soilmoisturepercent);  // sending sensor value to Blynk app
 
  soilMoistureValue   = analogRead(A11);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V7, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A12);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V8, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A13);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V9, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A14);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V10, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A15);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V11, soilmoisturepercent);  // sending sensor value to Blynk app

  Serial.println("Soil data sensor send 2 end");

}


void setup()
{
  // Debug console
  Serial.begin(9600);
  
  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  pinMode(pumpPin, OUTPUT);
  //pinMode(solenoidPin, OUTPUT);
  Blynk.begin(auth, wifi, ssid, pass);
  Serial.println("Blynk Begin Time");
  // You can also specify server:
  //Blynk.begin(auth, wifi, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, wifi, ssid, pass, IP);
  
  timer.setInterval(3000L, checkPump); //timer will run every 2 sec
  delay(1000);
  timer.setInterval(3000L, soilsensorDataSend1); //timer will run every 2 sec
  delay(1000);
  timer.setInterval(3000L, soilsensorDataSend2); //timer will run every 2 sec
  Blynk.virtualWrite(V14, 0);   // button widget buttonstate
  Blynk.virtualWrite(V16, 0);   // numeric input widget to control stepValue - amount of mL produced by pump 0-4000 step 200
}

void loop()
{ 
  timer.run();       // run timer every second
  Blynk.run();
}

Actually it looks like its working now with a consistent connection now!!! My only problem is that the blynk button is not being turned off by the timer set by the mL widget after it is pressed. Am I doing something wrong in my code to trigger the the pump off after the set time?

[Unformatted code removed by moderator]

The serial monitor photo you posted is illegible. You should copy the contents of the serial monitor using CTRL-C and paste it into your post, with trip[le backticks at the beginning and end.

You also need triplebackticks at the begining and end of your code, not these characters…

Triple backticks look like this:
```

What does this mean, what is the mL widget?

Pete.

Thank you I was trying to figure that out I apologize and I really appreciate your patience with me, you have already been an incredible amount of help believe it or not.

So I have a blynk button on V14 to trigger a pump relay and a step widget on V16 to try and control the amount of water output in mL by using millis to time the on/off of the blynk button/pump relay. My hope is to be able to play with the multiplier integer to calibrate the time it takes to output the amount of water .

Also is there anyway you can remove my auth, ssid and pass from first post? It will not let me edit it.

18:19:19.506 -> [10768] Connected to WiFi
18:19:29.990 -> [21306] Ready (ping: 12ms).
18:19:30.599 -> Blynk Begin Time
18:19:33.646 -> checkpump start
18:19:33.646 -> Pump Off
18:19:33.646 -> checkpump end
18:19:34.632 -> Soil data sensor send 1 start
18:19:35.570 -> Soil data sensor send 1 end
18:19:35.617 -> Soil data sensor send 2 start
18:19:36.367 -> Soil data sensor send 2 end
18:19:36.648 -> checkpump start
18:19:36.648 -> Pump Off
18:19:36.648 -> checkpump end
18:19:37.632 -> Soil data sensor send 1 start
18:19:39.226 -> Soil data sensor send 1 end
18:19:39.226 -> Soil data sensor send 2 start
18:19:40.070 -> Soil data sensor send 2 end
18:19:40.070 -> checkpump start
18:19:40.070 -> Pump Off
18:19:40.070 -> checkpump end
18:19:40.679 -> Soil data sensor send 1 start
18:19:44.563 -> Soil data sensor send 1 end
18:19:44.563 -> checkpump start
18:19:44.610 -> Pump Off
18:19:44.610 -> checkpump end
18:19:44.657 -> Soil data sensor send 1 start
18:19:49.412 -> Soil data sensor send 1 end
18:19:49.412 -> Soil data sensor send 2 start
18:19:50.303 -> Soil data sensor send 2 end
18:19:50.303 -> checkpump start
18:19:50.349 -> Pump Off
18:19:50.349 -> checkpump end
18:19:50.349 -> Soil data sensor send 1 start
18:19:51.146 -> Soil data sensor send 1 end
18:19:51.146 -> Soil data sensor send 2 start
18:19:51.990 -> Soil data sensor send 2 end
18:19:51.990 -> checkpump start
18:19:52.037 -> Pump Off
18:19:52.037 -> checkpump end
18:19:52.084 -> Soil data sensor send 2 start
18:19:53.725 -> Soil data sensor send 2 end
18:19:53.725 -> Soil data sensor send 1 start
18:20:09.364 -> Soil data sensor send 1 end
18:20:09.364 -> Soil data sensor send 2 start
18:20:09.410 -> Soil data sensor send 2 end
18:20:19.301 -> checkpump start
18:20:19.301 -> Pump Off
18:20:19.301 -> checkpump end
18:20:19.348 -> Soil data sensor send 1 start
18:20:19.395 -> Soil data sensor send 1 end
18:20:19.395 -> Soil data sensor send 2 start
18:20:19.442 -> Soil data sensor send 2 end
18:20:19.489 -> [70746] Ready (ping: 112ms).
18:20:46.128 -> checkpump start
18:20:46.128 -> Pump Off
18:20:46.128 -> checkpump end
18:20:46.175 -> Soil data sensor send 1 start
18:20:46.175 -> Soil data sensor send 1 end
18:20:46.221 -> Soil data sensor send 2 start
18:20:46.268 -> Soil data sensor send 2 end
18:20:51.331 -> checkpump start
18:20:51.331 -> Pump Off
18:20:51.331 -> checkpump end
18:20:51.378 -> Soil data sensor send 1 start
18:20:51.425 -> Soil data sensor send 1 end
18:20:51.472 -> Soil data sensor send 2 start
18:20:51.472 -> Soil data sensor send 2 end
18:20:51.518 -> [102781] Ready (ping: 112ms).
18:20:51.847 -> checkpump start
18:20:51.847 -> Pump Off
18:20:51.847 -> checkpump end
18:20:52.643 -> Soil data sensor send 1 start
18:20:53.347 -> Soil data sensor send 1 end
18:20:53.628 -> Soil data sensor send 2 start
18:20:54.331 -> Soil data sensor send 2 end
18:20:54.659 -> checkpump start
18:20:54.659 -> Pump Off
18:20:54.659 -> checkpump end
18:20:55.643 -> Soil data sensor send 1 start
18:20:56.675 -> Soil data sensor send 1 end
18:20:56.675 -> Soil data sensor send 2 start
18:20:57.378 -> Soil data sensor send 2 end
18:20:57.659 -> checkpump start
18:20:57.659 -> Pump Off
18:20:57.659 -> checkpump end
18:20:58.639 -> Soil data sensor send 1 start
18:20:59.296 -> Soil data sensor send 1 end
18:20:59.624 -> Soil data sensor send 2 start
18:21:00.280 -> Soil data sensor send 2 end
18:21:00.655 -> checkpump start
18:21:00.655 -> Pump Off
18:21:00.655 -> checkpump end
18:21:01.639 -> Soil data sensor send 1 start
18:21:02.389 -> Soil data sensor send 1 end
18:21:02.624 -> Soil data sensor send 2 start
18:21:03.327 -> Soil data sensor send 2 end
18:21:03.655 -> checkpump start
18:21:03.655 -> Pump Off
18:21:03.655 -> checkpump end
18:21:04.639 -> Soil data sensor send 1 start
18:21:05.296 -> Soil data sensor send 1 end
18:21:05.624 -> Soil data sensor send 2 start
18:21:06.317 -> Soil data sensor send 2 end
18:21:06.645 -> checkpump start
18:21:06.645 -> Pump Off
18:21:06.645 -> checkpump end
18:21:07.630 -> Soil data sensor send 1 start
18:21:08.333 -> Soil data sensor send 1 end
18:21:08.614 -> Soil data sensor send 2 start
18:21:09.317 -> Soil data sensor send 2 end
18:21:09.646 -> checkpump start
18:21:09.646 -> Pump Off
18:21:09.646 -> checkpump end
18:21:10.630 -> Soil data sensor send 1 start
18:21:11.333 -> Soil data sensor send 1 end
18:21:11.661 -> Soil data sensor send 2 start
18:21:12.317 -> Soil data sensor send 2 end
18:21:12.317 -> checkpump start
18:21:12.364 -> Water Amount: 
18:21:12.364 -> 300.00
18:21:12.364 -> Run Time: 
18:21:12.364 -> 9000
18:21:12.364 -> checkpump end
18:21:12.646 -> checkpump start
18:21:12.646 -> checkpump end
18:21:13.630 -> Soil data sensor send 1 start
18:21:14.286 -> Soil data sensor send 1 end
18:21:14.614 -> Soil data sensor send 2 start
18:21:15.317 -> Soil data sensor send 2 end
18:21:15.646 -> checkpump start
18:21:15.646 -> checkpump end
18:21:16.630 -> Soil data sensor send 1 start
18:21:17.286 -> Soil data sensor send 1 end
18:21:17.661 -> Soil data sensor send 2 start
18:21:18.318 -> Soil data sensor send 2 end
18:21:18.646 -> checkpump start
18:21:18.646 -> checkpump end
18:21:19.630 -> Soil data sensor send 1 start
18:21:20.286 -> Soil data sensor send 1 end
18:21:20.661 -> Soil data sensor send 2 start
18:21:21.318 -> Soil data sensor send 2 end
18:21:21.646 -> checkpump start
18:21:21.646 -> Pump Off
18:21:21.646 -> checkpump end
18:21:22.630 -> Soil data sensor send 1 start
18:21:23.337 -> Soil data sensor send 1 end
#include <SPI.h>
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>



// 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[] = "********************"; 





// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial3

// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200




ESP8266 wifi(&EspSerial);


float stepValue;                                               //expecting 0.00-80.00
const int pumpPin = 27;                                        //Pump connected @ D27                               
uint32_t multiplier = 30; 
uint32_t startPump = 0;
uint32_t runCount;
bool pumpRunning = false;
int buttonstate = 0;                                           //Button Widget set to Switch
BlynkTimer timer;                                             // SimpleTimer instance named timer

//int solenoidPin = 30;                                        // solenoid valve pin still to be added

const int AirValue            = 620;                           // sensor value in air
const int WaterValue          = 280;                           // sensor value in water
int       soilMoistureValue   = 0;
int       soilmoisturepercent = 0;

BLYNK_WRITE(V14){                                              // blynk button
  buttonstate = param.asInt();{                                // 
  if (buttonstate == 1 && pumpRunning == false)
  checkPump();
  }
}  

BLYNK_WRITE(V16){
  stepValue = param.asFloat();                                 // numeric input widget to choose mL output 0-4000. 
}

BLYNK_CONNECTED(){
 
  Blynk.syncVirtual(V16);

}
 
void checkPump()
{
   Serial.println("checkpump start");
  
  if (buttonstate == 1 && pumpRunning == false)
  {
   
    
    pumpRunning = true;
    digitalWrite(pumpPin, HIGH);
    
    startPump = millis();
    runCount = stepValue * multiplier;
    Serial.println("Water Amount: ");
    Serial.println(stepValue);
    
    Serial.println("Run Time: ");
    Serial.println(runCount);
  }
  if (millis() - startPump > runCount)
  {
    digitalWrite(pumpPin, LOW);
    Serial.println("Pump Off");
    pumpRunning = false;
    buttonstate = 0;
    
  }
  Serial.println("checkpump end");
}
  

//                    Capacitive Soil Moisture Sensor V1.2     A1
void soilsensorDataSend1()
{
  Serial.println("Soil data sensor send 1 start");
  
  soilMoistureValue   = analogRead(A4);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V0, soilmoisturepercent);  // sending sensor value to Blynk app
  soilMoistureValue   = analogRead(A5);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V1, soilmoisturepercent);  // sending sensor value to Blynk app
  soilMoistureValue   = analogRead(A6);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V2, soilmoisturepercent);  // sending sensor value to Blynk app
  
  soilMoistureValue   = analogRead(A7);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V3, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A8);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V4, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A9);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V5, soilmoisturepercent);  // sending sensor value to Blynk app

  Serial.println("Soil data sensor send 1 end");
}
void soilsensorDataSend2()
{
  Serial.println("Soil data sensor send 2 start");
  
  soilMoistureValue   = analogRead(A10);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V6, soilmoisturepercent);  // sending sensor value to Blynk app
 
  soilMoistureValue   = analogRead(A11);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V7, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A12);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V8, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A13);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V9, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A14);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V10, soilmoisturepercent);  // sending sensor value to Blynk app

  soilMoistureValue   = analogRead(A15);         // reading sensor from analog pin
  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V11, soilmoisturepercent);  // sending sensor value to Blynk app

  Serial.println("Soil data sensor send 2 end");

}


void setup()
{
  // Debug console
  Serial.begin(9600);
  
  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  pinMode(pumpPin, OUTPUT);
  //pinMode(solenoidPin, OUTPUT);
  Blynk.begin(auth, wifi, ssid, pass);
  Serial.println("Blynk Begin Time");
  // You can also specify server:
  //Blynk.begin(auth, wifi, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, wifi, ssid, pass, IP);
  
  timer.setInterval(3000L, checkPump); //timer will run every 2 sec
  delay(1000);
  timer.setInterval(3000L, soilsensorDataSend1); //timer will run every 2 sec
  delay(1000);
  timer.setInterval(3000L, soilsensorDataSend2); //timer will run every 2 sec
  Blynk.virtualWrite(V14, 0);   // button widget buttonstate
  //Blynk.virtualWrite(V16, 0);   // numeric input widget to control stepValue - amount of mL produced by pump 0-4000 step 200
}

void loop()
{ 
  timer.run();       // run timer every second
  Blynk.run();
}

Done.

Pete.