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
}
1 Like

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.

ive tried lambda timeouts and functions, tried getting a local server but cant connect the hardware. Im juat having no luck anywhere. Why is this code not connecting properly to the public servers?

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#define DHTTYPE DHT11   
#define DHTPIN 36                                              // Digital pin connected to the 
char auth[] = "*******";
char ssid[] = "******";
char pass[] = "*******";
//char server[] = "192.168.0.184";
//char port[] = "8080";
#define EspSerial Serial3
#define ESP8266_BAUD 115200

ESP8266 wifi(&EspSerial);

float      stepValue;                                          // expecting 0.00-4000.00 / 100 per step
const int  pumpPin              = 38;                          // Pump connected @ D27
uint32_t   multiplier           = 30;
uint32_t   startPump            = 0;
uint32_t   runCount;
bool       pumpRunning          = false;                       // false not running
int        buttonstate          = 0;                           // Button Widget set to Switch
int        solenoidPin          = 40;                          // solenoid valve pin
int        soilMoistureValue    = 0;
int        soilmoisturepercent  = 0;
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;                                              // SimpleTimer instance named timer
BLYNK_WRITE(V14) {                                             // blynk button
  buttonstate = param.asInt();   
}                             
BLYNK_WRITE(V16) {
  stepValue = param.asFloat();                                 // Step widget to choose mL output 0-4000 / 100 per step
}
BLYNK_CONNECTED() {
  Blynk.syncVirtual(V16);
}
void checkPump() {
  if (buttonstate == 1 && pumpRunning == false){
      pumpRunning = true;
      digitalWrite(solenoidPin, HIGH);
      digitalWrite(pumpPin, HIGH);
      startPump = millis();
      runCount = stepValue * multiplier;
      Serial.println("Water Amount:          ");
      Serial.print(stepValue);
      Serial.println("Run Time:          ");
      Serial.print(runCount);
  }
    if (millis() - startPump > runCount)
    {
      digitalWrite(solenoidPin, LOW);
      digitalWrite(pumpPin, LOW);
      Serial.println("Pump Off");
      pumpRunning = false;
      buttonstate = 0;
      Blynk.virtualWrite(V14, 0);
    } 
    
}
void soilsensorDataSend1()
{
  soilMoistureValue   = analogRead(A4);                                                 // A1     
  soilmoisturepercent = map(soilMoistureValue, 850, 474, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V0, soilmoisturepercent);  
}                                              
void soilsensorDataSend2() 
{
  soilMoistureValue   = analogRead(A5);                                                 // A2     
  soilmoisturepercent = map(soilMoistureValue, 778, 409, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V1, soilmoisturepercent);   
}                                             
void soilsensorDataSend3() 
{
  soilMoistureValue   = analogRead(A6);                                                 // A3     
  soilmoisturepercent = map(soilMoistureValue, 806, 422, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V2, soilmoisturepercent); 
}                                               
void soilsensorDataSend4()
{
  soilMoistureValue   = analogRead(A7);                                                 // A4       
  soilmoisturepercent = map(soilMoistureValue, 824, 417, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V3, soilmoisturepercent); 
}                                              
void soilsensorDataSend5()
{
  soilMoistureValue   = analogRead(A8);                                                 // B1       
  soilmoisturepercent = map(soilMoistureValue, 789, 425, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V4, soilmoisturepercent);  
}                                             
void soilsensorDataSend6()
{
  soilMoistureValue   = analogRead(A9);                                                 // B2       
  soilmoisturepercent = map(soilMoistureValue, 745, 332, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V5, soilmoisturepercent);                                              
}
void soilsensorDataSend7()
{
  soilMoistureValue   = analogRead(A10);                                                // B3       
  soilmoisturepercent = map(soilMoistureValue, 711, 317, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V6, soilmoisturepercent);                                               
}
void soilsensorDataSend8()
{
  soilMoistureValue   = analogRead(A11);                                                // B4     
  soilmoisturepercent = map(soilMoistureValue, 813, 480, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V7, soilmoisturepercent);                                               
}
void soilsensorDataSend9()
{
  soilMoistureValue   = analogRead(A12);                                                // C1       
  soilmoisturepercent = map(soilMoistureValue, 826, 459, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V8, soilmoisturepercent); 
}                                               
void soilsensorDataSend10()
{
  soilMoistureValue   = analogRead(A13);                                                // C2      
  soilmoisturepercent = map(soilMoistureValue, 833, 416, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V9, soilmoisturepercent); 
}                                            
void soilsensorDataSend11()
{
  soilMoistureValue   = analogRead(A14);                                                // C3    
  soilmoisturepercent = map(soilMoistureValue, 829, 419, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V10, soilmoisturepercent); 
}                                             
void soilsensorDataSend12()
{
  soilMoistureValue   = analogRead(A15);                                                // C4      
  soilmoisturepercent = map(soilMoistureValue, 766, 377, 0, 100);
  soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
  Blynk.virtualWrite(V11, soilmoisturepercent);                                             
}

void dhtemperature()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(true); // or dht.readTemperature(true) for Fahrenheit
 
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  Blynk.virtualWrite(V12, t);
  Blynk.virtualWrite(V13, h);
}

void setup()
{
  Serial.begin(9600);
  dht.begin();
  EspSerial.begin(ESP8266_BAUD);
  delay(10);
  pinMode(pumpPin,     OUTPUT);
  pinMode(solenoidPin, OUTPUT);
  Blynk.begin(auth, wifi, ssid, pass); 
  Blynk.virtualWrite(V14, 0);
  timer.setInterval(1000L, checkPump);
  delay(500);
  timer.setInterval(13000L, dhtemperature);
  delay(1000);
  timer.setInterval(13000L, soilsensorDataSend1);                              //timer will run every 3 sec
  delay(1000);
  timer.setInterval(13000L, soilsensorDataSend2); //timer will run every 3 sec
  delay(1000);
  timer.setInterval(13000L, soilsensorDataSend3);
  delay(1000);
  timer.setInterval(13000L, soilsensorDataSend4);
  delay(1000);
  timer.setInterval(13000L, soilsensorDataSend5);
  delay(1000);
  timer.setInterval(13000L, soilsensorDataSend6);
  delay(1000);
  timer.setInterval(13000L, soilsensorDataSend7);
  delay(1000);
  timer.setInterval(13000L, soilsensorDataSend8);
  delay(1000);
  timer.setInterval(13000L, soilsensorDataSend9);
  delay(1000);
  timer.setInterval(13000L, soilsensorDataSend10);
  delay(1000);
  timer.setInterval(13000L, soilsensorDataSend11);
  delay(1000);
  timer.setInterval(13000L, soilsensorDataSend12); 
}
void loop()
{
  timer.run();                                                            
  Blynk.run();
}

What does your serial monitor say when you start your device and it attempts to connect to Blynk?

Also, I think you should initialise your timers before attempting to connect to Blynk, as the combined duration of the delays will cause Blynk to disconnect before the first Blynk.run is executed.

I’m also interested in how you decided on the 1 second period between each timer.

I’m not sure why, but sometimes a soil read/send is taking less than 1 second, but sometimes almost 4 seconds like this…

I think you need to perform this test again, with a small number of timers that aren’t overlapping and study the results, then use these results to determine your timer timings.

Pete.

I have tried everything to stop the disconnecting so my logic was that if I made all 13 functions on a 13 second timer with a 1 second delay in between each start, then each would have 1 second in between each execution.

After only running one function in entire sketch I think I realize there is a problem with my hardware. It is connecting and disconnecting while only running one function.

If so, is there another hardware you would suggest that would work better for this project? I really just need at least 12 analog inputs, a few digital with wifi or ethernet.

this is serial monitor

20:50:11.485 -> [9] 
20:50:11.485 ->     ___  __          __
20:50:11.485 ->    / _ )/ /_ _____  / /__
20:50:11.525 ->   / _  / / // / _ \/  '_/
20:50:11.525 ->  /____/_/\_, /_//_/_/\_\
20:50:11.565 ->         /___/ v0.6.1 on Arduino Mega
20:50:11.605 -> 
20:50:12.076 -> [599] Connecting to COGECO-9CA80
20:50:15.111 -> [3645] AT version:1.1.0.0(May 11 2016 18:09:56)
20:50:15.151 -> SDK version:1.5.4(baaeaebb)
20:50:15.191 -> compile time:May 20 2016 15:06:44
20:50:15.191 -> OK
20:50:20.212 -> [8758] +CIFSR:STAIP,"192.168.0.198"
20:50:20.252 -> +CIFSR:STAMAC,"a4:cf:12:d6:e6:d8"
20:50:20.292 -> [8766] Connected to WiFi
20:50:30.453 -> [18991] Ready (ping: 13ms).
20:50:43.835 -> Pump Off
20:50:44.331 -> Pump Off
20:50:45.336 -> Pump Off
20:50:46.343 -> Pump Off
20:50:47.342 -> Pump Off
20:50:48.371 -> Pump Off
20:50:49.359 -> Pump Off
20:50:50.347 -> Pump Off
20:50:51.366 -> Pump Off
20:50:52.351 -> Pump Off
20:50:53.339 -> Pump Off
20:50:54.338 -> Pump Off
20:50:55.356 -> Pump Off
20:50:56.351 -> Pump Off
20:50:57.361 -> Pump Off
20:50:58.340 -> Pump Off
20:50:59.370 -> Pump Off
20:51:00.359 -> Pump Off
20:51:01.354 -> Pump Off
20:51:02.343 -> Pump Off
20:51:03.371 -> Pump Off
20:51:05.416 -> Pump Off
20:51:26.143 -> Pump Off
20:51:26.190 -> [74714] Ready (ping: 36ms).
20:51:52.998 -> Pump Off
20:52:13.299 -> Pump Off
20:52:25.052 -> Pump Off
20:52:32.318 -> Pump Off
20:52:32.398 -> [140891] Ready (ping: 36ms).
20:52:59.143 -> Pump Off

This is the sketch i try with the 1 sensor

#define BLYNK_PRINT Serial

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
                                        // Digital pin connected to the 
char auth[] = "*******";
char ssid[] = "********";
char pass[] = "********";
//char server[] = "192.168.0.184";
//char port[] = "8088";
#define EspSerial Serial3
#define ESP8266_BAUD 115200

ESP8266 wifi(&EspSerial);


int        soilMoistureValue    = 0;
int        soilmoisturepercent  = 0;

BlynkTimer timer;                                              // SimpleTimer instance named timer

void soilsensorDataSend1()
{
  Serial.println("sensor 1 start");
  {
    soilMoistureValue   = analogRead(A4);                                                 // A1     
    soilmoisturepercent = map(soilMoistureValue, 850, 474, 0, 100);
    soilmoisturepercent = constrain(soilmoisturepercent, 0, 100);
    Blynk.virtualWrite(V0, soilmoisturepercent); 
  }
  Serial.println("sensor 1 end");  
}                                              

void setup()
{
  Serial.begin(9600);
  
  EspSerial.begin(ESP8266_BAUD);
  delay(10);
  
  timer.setInterval(2000L, soilsensorDataSend1);                              //timer will run every 3 sec
  Blynk.begin(auth, wifi, ssid, pass); 

}

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

with the outcome in the serial monitor

21:26:41.217 -> [9] 
21:26:41.217 ->     ___  __          __
21:26:41.217 ->    / _ )/ /_ _____  / /__
21:26:41.257 ->   / _  / / // / _ \/  '_/
21:26:41.257 ->  /____/_/\_, /_//_/_/\_\
21:26:41.297 ->         /___/ v0.6.1 on Arduino Mega
21:26:41.337 -> 
21:26:41.777 -> [599] Connecting to COGECO-9CA80
21:26:44.824 -> [3645] AT version:1.1.0.0(May 11 2016 18:09:56)
21:26:44.864 -> SDK version:1.5.4(baaeaebb)
21:26:44.904 -> compile time:May 20 2016 15:06:44
21:26:44.944 -> OK
21:26:51.963 -> [10760] +CIFSR:STAIP,"192.168.0.198"
21:26:52.003 -> +CIFSR:STAMAC,"a4:cf:12:d6:e6:d8"
21:26:52.043 -> [10769] Connected to WiFi
21:27:03.912 -> [22694] Ready (ping: 12ms).
21:27:04.233 -> sensor 1 start
21:27:04.393 -> sensor 1 end
21:27:05.227 -> sensor 1 start
21:27:05.467 -> sensor 1 end
21:27:07.231 -> sensor 1 start
21:27:07.325 -> sensor 1 end
21:27:09.238 -> sensor 1 start
21:27:09.278 -> sensor 1 end
21:27:11.224 -> sensor 1 start
21:27:11.424 -> sensor 1 end
21:27:13.211 -> sensor 1 start
21:27:14.309 -> sensor 1 end
21:27:15.233 -> sensor 1 start
21:27:15.347 -> sensor 1 end
21:27:17.231 -> sensor 1 start
21:27:17.351 -> sensor 1 end
21:27:19.206 -> sensor 1 start
21:27:34.263 -> sensor 1 end
21:27:39.379 -> sensor 1 start
21:27:39.379 -> sensor 1 end
21:27:39.379 -> [58211] Ready (ping: 13ms).
21:27:44.905 -> sensor 1 start
21:27:45.219 -> sensor 1 end
21:27:45.219 -> sensor 1 start
21:27:45.533 -> sensor 1 end
21:27:47.238 -> sensor 1 start
21:27:47.285 -> sensor 1 end
21:27:49.203 -> sensor 1 start
21:27:49.323 -> sensor 1 end
21:27:51.244 -> sensor 1 start
21:28:06.259 -> sensor 1 end
21:28:17.634 -> sensor 1 start
21:28:17.634 -> sensor 1 end
21:28:24.788 -> sensor 1 start
21:28:24.788 -> sensor 1 end
21:28:24.788 -> [103593] Ready (ping: 12ms).
21:28:25.204 -> sensor 1 start
21:28:25.298 -> sensor 1 end
21:28:27.209 -> sensor 1 start
21:28:27.302 -> sensor 1 end
21:28:29.227 -> sensor 1 start
21:28:29.267 -> sensor 1 end
21:28:31.231 -> sensor 1 start
21:28:31.271 -> sensor 1 end
21:28:33.220 -> sensor 1 start
21:28:33.534 -> sensor 1 end
21:28:35.241 -> sensor 1 start

and this is with just dht function

20:58:53.050 -> [9] 
20:58:53.050 ->     ___  __          __
20:58:53.050 ->    / _ )/ /_ _____  / /__
20:58:53.050 ->   / _  / / // / _ \/  '_/
20:58:53.090 ->  /____/_/\_, /_//_/_/\_\
20:58:53.130 ->         /___/ v0.6.1 on Arduino Mega
20:58:53.170 -> 
20:58:53.639 -> [599] Connecting to COGECO-9CA80
20:58:56.662 -> [3645] AT version:1.1.0.0(May 11 2016 18:09:56)
20:58:56.702 -> SDK version:1.5.4(baaeaebb)
20:58:56.742 -> compile time:May 20 2016 15:06:44
20:58:56.742 -> OK
20:59:03.801 -> [10760] +CIFSR:STAIP,"192.168.0.198"
20:59:03.801 -> +CIFSR:STAMAC,"a4:cf:12:d6:e6:d8"
20:59:03.841 -> [10769] Connected to WiFi
20:59:14.094 -> [21083] Ready (ping: 12ms).
20:59:15.032 -> DHT Function Start
20:59:15.383 -> DHT Function End
20:59:17.029 -> DHT Function Start
20:59:17.350 -> DHT Function End
20:59:19.018 -> DHT Function Start
20:59:19.332 -> DHT Function End
20:59:21.016 -> DHT Function Start
20:59:21.284 -> DHT Function End
20:59:23.020 -> DHT Function Start
20:59:23.460 -> DHT Function End
20:59:25.038 -> DHT Function Start
20:59:25.278 -> DHT Function End
20:59:27.024 -> DHT Function Start
20:59:27.298 -> DHT Function End
20:59:29.040 -> DHT Function Start
20:59:29.354 -> DHT Function End
20:59:31.069 -> DHT Function Start
20:59:31.583 -> DHT Function End
20:59:33.056 -> DHT Function Start
20:59:48.326 -> DHT Function End
20:59:59.554 -> DHT Function Start
20:59:59.554 -> DHT Function End
21:00:04.879 -> DHT Function Start
21:00:04.919 -> DHT Function End
21:00:04.919 -> [71864] Ready (ping: 34ms).
21:00:05.587 -> DHT Function Start
21:00:05.987 -> DHT Function End
21:00:07.047 -> DHT Function Start
21:00:07.247 -> DHT Function End
21:00:09.046 -> DHT Function Start
21:00:09.280 -> DHT Function End
21:00:11.057 -> DHT Function Start
21:00:11.371 -> DHT Function End
21:00:13.068 -> DHT Function Start
21:00:13.268 -> DHT Function End
21:00:15.075 -> DHT Function Start
21:00:15.309 -> DHT Function End
21:00:17.077 -> DHT Function Start
21:00:17.318 -> DHT Function End
21:00:19.094 -> DHT Function Start
21:00:19.529 -> DHT Function End
21:00:21.089 -> DHT Function Start
21:00:21.479 -> DHT Function End
21:00:23.086 -> DHT Function Start
21:00:23.326 -> DHT Function End
21:00:25.063 -> DHT Function Start
21:00:25.463 -> DHT Function End
21:00:40.788 -> DHT Function Start
21:00:40.828 -> DHT Function End
21:00:52.699 -> DHT Function Start
21:00:52.699 -> DHT Function End
21:00:57.985 -> DHT Function Start
21:00:58.025 -> DHT Function End
21:00:58.025 -> [124935] Ready (ping: 34ms).
21:00:59.084 -> DHT Function Start
21:00:59.325 -> DHT Function End
21:01:01.074 -> DHT Function Start
21:01:01.274 -> DHT Function End
21:01:03.103 -> DHT Function Start
21:01:18.450 -> DHT Function End
21:01:24.603 -> DHT Function Start
21:01:24.643 -> DHT Function End
21:01:24.643 -> [151575] Ready (ping: 34ms).
21:01:30.276 -> DHT Function Start
21:01:30.549 -> DHT Function End
21:01:31.110 -> DHT Function Start
21:01:31.270 -> DHT Function End
21:01:33.089 -> DHT Function Start
21:01:33.484 -> DHT Function End
21:01:35.101 -> DHT Function Start
21:01:35.301 -> DHT Function End
21:01:37.114 -> DHT Function Start

this is with just pump function

21:11:18.864 -> [9] 
21:11:18.864 ->     ___  __          __
21:11:18.864 ->    / _ )/ /_ _____  / /__
21:11:18.904 ->   / _  / / // / _ \/  '_/
21:11:18.904 ->  /____/_/\_, /_//_/_/\_\
21:11:18.944 ->         /___/ v0.6.1 on Arduino Mega
21:11:18.984 -> 
21:11:19.452 -> [599] Connecting to COGECO-9CA80
21:11:22.486 -> [3645] AT version:1.1.0.0(May 11 2016 18:09:56)
21:11:22.526 -> SDK version:1.5.4(baaeaebb)
21:11:22.566 -> compile time:May 20 2016 15:06:44
21:11:22.566 -> OK
21:11:27.595 -> [8758] +CIFSR:STAIP,"192.168.0.198"
21:11:27.635 -> +CIFSR:STAMAC,"a4:cf:12:d6:e6:d8"
21:11:27.675 -> [8766] Connected to WiFi
21:11:37.847 -> [18992] Ready (ping: 13ms).
21:11:38.440 -> Pump Function Start
21:11:38.440 -> Pump Off
21:11:38.560 -> Pump Function End
21:11:38.876 -> Pump Function Start
21:11:38.876 -> Pump Off
21:11:38.950 -> Pump Function End
21:11:40.842 -> Pump Function Start
21:11:40.842 -> Pump Off
21:11:40.922 -> Pump Function End
21:11:42.859 -> Pump Function Start
21:11:42.859 -> Pump Off
21:11:42.939 -> Pump Function End
21:11:44.861 -> Pump Function Start
21:11:44.861 -> Pump Off
21:11:44.942 -> Pump Function End
21:11:46.854 -> Pump Function Start
21:11:46.854 -> Pump Off
21:11:46.934 -> Pump Function End
21:11:48.845 -> Pump Function Start
21:11:48.845 -> Pump Off
21:11:48.966 -> Pump Function End
21:11:50.841 -> Pump Function Start
21:11:50.841 -> Pump Off
21:11:50.921 -> Pump Function End
21:11:52.855 -> Pump Function Start
21:11:52.855 -> Pump Off
21:11:52.895 -> Pump Function End
21:11:54.879 -> Pump Function Start
21:11:54.879 -> Pump Off
21:11:54.919 -> Pump Function End
21:11:56.867 -> Pump Function Start
21:11:56.867 -> Pump Off
21:11:56.987 -> Pump Function End
21:11:58.867 -> Pump Function Start
21:11:58.867 -> Pump Off
21:11:58.947 -> Pump Function End
21:12:00.866 -> Pump Function Start
21:12:00.866 -> Pump Off
21:12:00.946 -> Pump Function End
21:12:02.843 -> Pump Function Start
21:12:02.843 -> Pump Off
21:12:02.924 -> Pump Function End
21:12:04.862 -> Pump Function Start
21:12:04.862 -> Pump Off
21:12:04.902 -> Pump Function End
21:12:06.853 -> Pump Function Start
21:12:06.853 -> Pump Off
21:12:06.933 -> Pump Function End
21:12:08.857 -> Pump Function Start
21:12:08.857 -> Pump Off
21:12:09.017 -> Pump Function End
21:12:10.842 -> Pump Function Start
21:12:10.842 -> Pump Off
21:12:10.922 -> Pump Function End
21:12:12.874 -> Pump Function Start
21:12:12.874 -> Pump Off
21:12:12.949 -> Pump Function End
21:12:14.847 -> Pump Function Start
21:12:14.847 -> Pump Off
21:12:14.927 -> Pump Function End
21:12:16.872 -> Pump Function Start
21:12:16.872 -> Pump Off
21:12:16.912 -> Pump Function End
21:12:18.854 -> Pump Function Start
21:12:18.854 -> Pump Off
21:12:19.014 -> Pump Function End
21:12:20.881 -> Pump Function Start
21:12:20.881 -> Pump Off
21:12:20.921 -> Pump Function End
21:12:22.865 -> Pump Function Start
21:12:22.865 -> Pump Off
21:12:22.945 -> Pump Function End
21:12:24.854 -> Pump Function Start
21:12:24.854 -> Pump Off
21:12:24.935 -> Pump Function End
21:12:26.852 -> Pump Function Start
21:12:26.852 -> Pump Off
21:12:27.012 -> Pump Function End
21:12:28.883 -> Pump Function Start
21:12:28.883 -> Pump Off
21:12:28.963 -> Pump Function End
21:12:30.837 -> Pump Function Start
21:12:30.837 -> Pump Off
21:12:31.111 -> Pump Function End
21:12:32.870 -> Pump Function Start
21:12:32.870 -> Pump Off
21:12:32.910 -> Pump Function End
21:12:34.867 -> Pump Function Start
21:12:34.867 -> Pump Off
21:12:49.881 -> Pump Function End
21:13:01.385 -> Pump Function Start
21:13:01.385 -> Pump Off
21:13:01.385 -> Pump Function End
21:13:06.733 -> Pump Function Start
21:13:06.733 -> Pump Off
21:13:06.733 -> Pump Function End
21:13:06.733 -> [107881] Ready (ping: 12ms).
21:13:07.466 -> Pump Function Start
21:13:07.466 -> Pump Off
21:13:07.626 -> Pump Function End
21:13:08.873 -> Pump Function Start
21:13:08.873 -> Pump Off

actually now the one sensor is connected properly

22:52:32.942 ->     ___  __          __
22:52:32.942 ->    / _ )/ /_ _____  / /__
22:52:32.942 ->   / _  / / // / _ \/  '_/
22:52:32.982 ->  /____/_/\_, /_//_/_/\_\
22:52:33.022 ->         /___/ v0.6.1 on Arduino Mega
22:52:33.062 -> 
22:52:33.518 -> [599] Connecting to COGECO-9CA80
22:52:36.552 -> [3645] AT version:1.1.0.0(May 11 2016 18:09:56)
22:52:36.592 -> SDK version:1.5.4(baaeaebb)
22:52:36.632 -> compile time:May 20 2016 15:06:44
22:52:36.632 -> OK
22:52:43.687 -> [10760] +CIFSR:STAIP,"192.168.0.198"
22:52:43.727 -> +CIFSR:STAMAC,"a4:cf:12:d6:e6:d8"
22:52:43.727 -> [10769] Connected to WiFi
22:52:53.872 -> [20966] Ready (ping: 12ms).
22:52:54.152 -> sensor 1 start
22:52:54.352 -> sensor 1 end
22:52:54.912 -> sensor 1 start
22:52:54.992 -> sensor 1 end
22:52:56.912 -> sensor 1 start
22:52:56.992 -> sensor 1 end
22:52:58.912 -> sensor 1 start
22:52:58.952 -> sensor 1 end
22:53:00.912 -> sensor 1 start
22:53:00.992 -> sensor 1 end
22:53:02.907 -> sensor 1 start
22:53:02.987 -> sensor 1 end
22:53:04.941 -> sensor 1 start
22:53:05.021 -> sensor 1 end
22:53:06.941 -> sensor 1 start
22:53:07.021 -> sensor 1 end
22:53:08.901 -> sensor 1 start
22:53:08.981 -> sensor 1 end
22:53:10.901 -> sensor 1 start
22:53:10.981 -> sensor 1 end
22:53:12.901 -> sensor 1 start
22:53:12.981 -> sensor 1 end
22:53:14.925 -> sensor 1 start
22:53:15.005 -> sensor 1 end
22:53:16.925 -> sensor 1 start
22:53:16.965 -> sensor 1 end
22:53:18.925 -> sensor 1 start
22:53:18.965 -> sensor 1 end
22:53:20.925 -> sensor 1 start
22:53:20.965 -> sensor 1 end
22:53:22.920 -> sensor 1 start
22:53:23.000 -> sensor 1 end
22:53:24.914 -> sensor 1 start
22:53:25.034 -> sensor 1 end
22:53:26.914 -> sensor 1 start
22:53:26.994 -> sensor 1 end
22:53:28.915 -> sensor 1 start
22:53:28.994 -> sensor 1 end
22:53:30.915 -> sensor 1 start
22:53:30.995 -> sensor 1 end
22:53:32.915 -> sensor 1 start
22:53:32.995 -> sensor 1 end
22:53:34.933 -> sensor 1 start
22:53:35.013 -> sensor 1 end
22:53:36.933 -> sensor 1 start
22:53:36.973 -> sensor 1 end
22:53:38.933 -> sensor 1 start
22:53:38.973 -> sensor 1 end
22:53:40.933 -> sensor 1 start
22:53:41.013 -> sensor 1 end
22:53:42.933 -> sensor 1 start
22:53:42.973 -> sensor 1 end
22:53:44.922 -> sensor 1 start
22:53:45.002 -> sensor 1 end
22:53:46.922 -> sensor 1 start
22:53:46.962 -> sensor 1 end
22:53:48.922 -> sensor 1 start
22:53:48.962 -> sensor 1 end
22:53:50.922 -> sensor 1 start
22:53:51.002 -> sensor 1 end
22:53:52.922 -> sensor 1 start
22:53:53.002 -> sensor 1 end
22:53:54.906 -> sensor 1 start
22:53:55.026 -> sensor 1 end
22:53:56.906 -> sensor 1 start
22:53:57.026 -> sensor 1 end
22:53:58.906 -> sensor 1 start
22:53:58.986 -> sensor 1 end
22:54:00.907 -> sensor 1 start
22:54:01.026 -> sensor 1 end
22:54:02.907 -> sensor 1 start
22:54:02.987 -> sensor 1 end
22:54:04.937 -> sensor 1 start
22:54:05.017 -> sensor 1 end
22:54:06.937 -> sensor 1 start
22:54:06.977 -> sensor 1 end
22:54:08.937 -> sensor 1 start
22:54:08.977 -> sensor 1 end
22:54:10.938 -> sensor 1 start
22:54:10.978 -> sensor 1 end
22:54:12.938 -> sensor 1 start
22:54:12.978 -> sensor 1 end
22:54:14.928 -> sensor 1 start
22:54:15.008 -> sensor 1 end
22:54:16.928 -> sensor 1 start
22:54:16.968 -> sensor 1 end
22:54:18.928 -> sensor 1 start
22:54:18.969 -> sensor 1 end
22:54:20.929 -> sensor 1 start
22:54:20.969 -> sensor 1 end
22:54:22.929 -> sensor 1 start
22:54:22.969 -> sensor 1 end
22:54:24.917 -> sensor 1 start
22:54:25.037 -> sensor 1 end
22:54:26.917 -> sensor 1 start
22:54:26.997 -> sensor 1 end
22:54:28.918 -> sensor 1 start
22:54:28.998 -> sensor 1 end
22:54:30.918 -> sensor 1 start
22:54:30.998 -> sensor 1 end
22:54:32.918 -> sensor 1 start
22:54:32.958 -> sensor 1 end
22:54:34.942 -> sensor 1 start
22:54:35.062 -> sensor 1 end
22:54:36.902 -> sensor 1 start
22:54:36.982 -> sensor 1 end
22:54:38.902 -> sensor 1 start
22:54:38.982 -> sensor 1 end
22:54:40.903 -> sensor 1 start
22:54:40.983 -> sensor 1 end
22:54:42.903 -> sensor 1 start
22:54:42.983 -> sensor 1 end
22:54:44.933 -> sensor 1 start
22:54:45.093 -> sensor 1 end
22:54:46.933 -> sensor 1 start
22:54:46.973 -> sensor 1 end
22:54:48.933 -> sensor 1 start
22:54:48.973 -> sensor 1 end
22:54:50.934 -> sensor 1 start
22:54:50.974 -> sensor 1 end
22:54:52.934 -> sensor 1 start
22:54:52.974 -> sensor 1 end
22:54:54.904 -> sensor 1 start
22:54:54.984 -> sensor 1 end
22:54:56.904 -> sensor 1 start
22:54:57.024 -> sensor 1 end
22:54:58.904 -> sensor 1 start
22:54:58.984 -> sensor 1 end
22:55:00.904 -> sensor 1 start
22:55:00.984 -> sensor 1 end
22:55:02.905 -> sensor 1 start
22:55:02.985 -> sensor 1 end
22:55:04.939 -> sensor 1 start
22:55:04.979 -> sensor 1 end
22:55:06.939 -> sensor 1 start
22:55:07.019 -> sensor 1 end
22:55:08.939 -> sensor 1 start
22:55:08.979 -> sensor 1 end
22:55:10.899 -> sensor 1 start
22:55:10.979 -> sensor 1 end
22:55:12.899 -> sensor 1 start
22:55:12.979 -> sensor 1 end
22:55:14.909 -> sensor 1 start
22:55:14.989 -> sensor 1 end
22:55:16.909 -> sensor 1 start
22:55:17.029 -> sensor 1 end
22:55:18.909 -> sensor 1 start
22:55:18.989 -> sensor 1 end
22:55:20.909 -> sensor 1 start
22:55:20.989 -> sensor 1 end
22:55:22.909 -> sensor 1 start
22:55:22.989 -> sensor 1 end
22:55:24.909 -> sensor 1 start
22:55:24.989 -> sensor 1 end
22:55:26.943 -> sensor 1 start
22:55:27.023 -> sensor 1 end
22:55:28.943 -> sensor 1 start
22:55:28.983 -> sensor 1 end
22:55:30.944 -> sensor 1 start
22:55:30.984 -> sensor 1 end
22:55:32.944 -> sensor 1 start
22:55:32.984 -> sensor 1 end
22:55:34.914 -> sensor 1 start
22:55:34.994 -> sensor 1 end
22:55:36.914 -> sensor 1 start
22:55:37.034 -> sensor 1 end
22:55:38.914 -> sensor 1 start
22:55:38.994 -> sensor 1 end
22:55:40.914 -> sensor 1 start
22:55:40.994 -> sensor 1 end
22:55:42.914 -> sensor 1 start
22:55:42.994 -> sensor 1 end
22:55:44.914 -> sensor 1 start
22:55:44.994 -> sensor 1 end
22:55:46.909 -> sensor 1 start
22:55:47.029 -> sensor 1 end
22:55:48.909 -> sensor 1 start
22:55:48.989 -> sensor 1 end
22:55:50.909 -> sensor 1 start
22:55:50.989 -> sensor 1 end
22:55:52.909 -> sensor 1 start
22:55:52.989 -> sensor 1 end
22:55:54.926 -> sensor 1 start
22:55:55.006 -> sensor 1 end
22:55:56.926 -> sensor 1 start
22:55:57.046 -> sensor 1 end
22:55:58.926 -> sensor 1 start
22:55:59.022 -> sensor 1 end
22:56:00.926 -> sensor 1 start
22:56:01.006 -> sensor 1 end
22:56:02.927 -> sensor 1 start
22:56:02.967 -> sensor 1 end
22:56:04.927 -> sensor 1 start
22:56:04.967 -> sensor 1 end