Device wont connect online after reflashing code

esp32, blynk 2.0 app, aurdino ide

So just made some additional calibration inputs but now my device wont connect i already checked my auth, temp, and name, as well as wifi credentials and now i assume it has something to do with pushing too many reads per second not really sure how to diagnose that if it is the case,

my codes down below if anyone can notice a quick fix or any reason why this wouldn’t be working would be greatly appreciated.

/*************************************************************
@MISCHIEF_GROWS DIY DOSER AND WATERING CONTROLLER CODE

SYSTEM CAN ACTIVATE FEED PUMP TO WATER PLANTS OR DOSE RES FROM 3 NUTE SOURCES
GENERALLY IS RECOMMENDED FOR 2 PART NUTE SYSTEMS W/ 3 SOURCE AS WATER SOURCE 
(MOST EFFECTIVE AUTOMATED SETUP) - IF MORE SOURCES NEEDED ADD A RELAY WITH MORE 
CHANNELS AND COPY CODE MARKED *SOURCE EXTENSION* AND ADD BELOW THE CODE COPIED 
WITH VARIBLE CHANGED AND NEW PIN USED DEFINED.

CAN BE MODIFIED TO BE A PH UP AND PH DOWN ADJUSTER AS WELL JUST ADD GRAVITY 
PH SENSOR AND DM ME ON INSTA ILL WRITE A SIMPLE CODE IF THERES INTREST IN THIS. 

SIMPLE EASY TO FOLLOW AND MODIFY CODE MAKE SURE TO READ COMMENTS BEFORE CHANGIN

*************************************************************/
#define BLYNK_TEMPLATE_ID "TMPLAr7hm1Hz"
#define BLYNK_DEVICE_NAME "WATERING CONTROLLER"
#define BLYNK_AUTH_TOKEN "cbbz5HS8JpdpgkHcT7YDKwjHgiXRZcwy"

#define RELAY_PIN 27
#define PUMP_A 26
#define PUMP_B 25
#define PUMP_C 33              //*EXTENSION* copy        <- number corresponds to pin used for relay in5,6,7 pin
                               //*EXTENSION* paste here
                 
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

////WIFI STUFF CHANGE TO YOUR NETWORK OR DEVICE WONT CONNECT TO WIFI

char auth[] = BLYNK_AUTH_TOKEN;

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


//variables to be used later
int timecheck = digitalRead(V6);
int SHUT_DOWN = 0;
int FEED_LOCK = 0;

int doseML_A = digitalRead(V15);
int doseML_B = digitalRead(V16);
int doseML_C = digitalRead(V17);  //*EXTENSION* copy          <- initalize and declare pump inital value
                                 //*EXTENSION* paste here
int calA = digitalRead(V21);
int calB = digitalRead(V22);
int calC = digitalRead(V23);    //*EXTENSION* copy          <- initalize and declare pump inital value
                                 //*EXTENSION* paste here
int feedTimeA = doseML_A/calA;
int feedTimeB = doseML_B/calB;
int feedTimeC = doseML_C/calC;   //*EXTENSION* copy          <- initalize and declare pump inital value
                                 //*EXTENSION* paste here
int calMain = digitalRead(V24);           

BlynkTimer timer;
//////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
///CALIBRATION CODE/////////////////////////////////////////////////

//doser pumps
BLYNK_WRITE(V21){
calA = param.asInt();
}
BLYNK_WRITE(V22){
calB = param.asInt();
}
BLYNK_WRITE(V23){                     // copy section   *EXTENSION*
calC = param.asInt();                 //
 }                                    //

                                      // paste here
                                      //
                                      //
//feed pump 
BLYNK_WRITE(V24){
calMain = param.asInt();
}


//PUMP CODE//////////////////////////////////////////////////////////////
BLYNK_WRITE(V0)
{
  // Set incoming value from pin V0 to a variable
  // Update state
  int count = param.asInt();
 while(count == 1 && SHUT_DOWN==0){
    digitalWrite(V27, 1);
    digitalWrite(RELAY_PIN,1);
    delay(timecheck*1000);        //change to millis so kill code works mid feed = CALIBRATE 
    digitalWrite(RELAY_PIN,0);
    count = 0; 
    digitalWrite(V27, 0);
  }
}

//USER INPUT WATER TIME --> OUTPUTS ML EXPECTED PER PORT (MUST BE CALIBRATED IN CALBRATION INPUTS)
BLYNK_WRITE(V6)
{
  //reads user time input and displays ML conversion based on time input.
  timecheck = param.asInt();
  Blynk.virtualWrite(V12, calMain*timecheck);
}

//lock system to prevent unwanted waterings to occur
BLYNK_WRITE(V9) 
{
  SHUT_DOWN = param.asInt();  
}


//DOSER PUMP CODE////////////////////////////////////////////////////////

//PUMP-A DOSE
BLYNK_WRITE(V15)
{
    doseML_A = param.asInt();
    feedTimeA = doseML_A/calA;
}
//PUMP-B DOSE
BLYNK_WRITE(V16)
{
   doseML_B = param.asInt();
   feedTimeB = doseML_B/calB;
}
//PUMP-C DOSE                       // copy section *EXTENSION*
BLYNK_WRITE(V17)                    //
{                                   //
   doseML_C = param.asInt();        //
   feedTimeC = doseML_C/calC;       //
} 

                                    // paste here adjust name to next leter
                                    //
                                    //
                                    //
                                    
//DOSE FEED///////////////////////////////////////////////////////////
//feed lock input switch

BLYNK_WRITE(V3)
{
  FEED_LOCK = param.asInt();  
}

BLYNK_WRITE(V18)
{
  digitalWrite(V26, 1);
  int count = param.asInt();
  while(count == 1 && FEED_LOCK==0){
    digitalWrite(PUMP_A,1);
    delay(feedTimeA*1000);        //change to millis so kill code works mid feed + CALIBRATE
    digitalWrite(PUMP_A,0);
    count = 0; 
  }
  count = 1;
  while(count == 1 && FEED_LOCK==0){
    digitalWrite(PUMP_B,1);
    delay(feedTimeB*1000);        //change to millis so kill code works mid feed + CALIBRATE
    digitalWrite(PUMP_B,0);
    count = 0; 
    } 
  count = 1;
  while(count == 1 && FEED_LOCK==0){                                                                    // Copy section  *EXTENSION*
    digitalWrite(PUMP_C,1);                                                                             //
    delay(feedTimeC*1000);        //change to millis so kill code works mid feed + CALIBRATE            //
    digitalWrite(PUMP_C,0);                                                                             //
    count = 0;                                                                                          //
  }                                                                                                     
                                                                                                        // paste BEFORE V26 write command
                                                                                                        //
                                                                                                        //
                                                                                                        //
  digitalWrite(V26, 0);
}

//test pump code///////////////////////////////////////
BLYNK_WRITE(V19)
{
  int count = param.asInt();
  while(count == 1 && FEED_LOCK==0){
  digitalWrite(PUMP_A,1);
  delay(1000);
  digitalWrite(PUMP_A,0);
  delay(1000);
  digitalWrite(PUMP_B,1);
  delay(1000);
  digitalWrite(PUMP_B,0);
  delay(1000);
  digitalWrite(PUMP_C,1);
  delay(1000);
  digitalWrite(PUMP_C,0);
  count = 0;
 }
}


//////////////////////////////////////////////////////////////////////////////////
// precoded blynk stuff i just commented it out if anyone ends up wanting the skelton code

BLYNK_CONNECTED()
{
  Blynk.sendInternal("rtc", "sync"); //request current local time for device
  // Change Web Link Button message to "Congratulations!"
  Blynk.setProperty(V3, "offImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
  Blynk.setProperty(V3, "onImageUrl",  "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
  Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
}
// This function sends Arduino's uptime every second to Virtual Pin 2.

void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V2, millis() / 1000);
}


/////////////////////////////////////////////////////////////////////////////////

//**DONT TOUCH LEAVE ANY CODE BELOW THIS POINT IF YOU DONT KNOW WHAT YOUR DOING!


void setup()
{
  // Debug console
  pinMode(RELAY_PIN, OUTPUT);
  pinMode(PUMP_A, OUTPUT);
  pinMode(PUMP_B, OUTPUT);  
  pinMode(PUMP_C, OUTPUT);
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

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

////////////////////////////////////////////////////////////////////////

void loop()
{
  Blynk.run();
  timer.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

Wow, where to begin!!

What is this code intended to achieve?..

You’re also doing digitalWrites to physical pins that don’t exist on the ESP32. Are these meant to be Blynk.virtuaWrites ?

I’d suggest that you do a little reading…

Pete.

1 Like

I will definitely read through all this and lyk if it helps thank you for the quick response.

In regards to the chunk of code you asked about, it is supposed to serve as calibration for the pump system based on ml/sec of the pump to ensure the code is accurate user to user, and when the system gets unplugged or goes offline it doesn’t have to be re entered because its intended to read the user set calibration value in the app I made.

So right now i intend for it to read as 0 when system is first set since that the V pin default value and then i have a user input slider attached to that to change the value which then would stay inputted even through system going offline because its set in the app not the code…?

The main issue im struggling understanding is that i had this code running fine for the past month only thing i adjusted was adding that section u questioned cause i wanted the system to restart with the correct value since the virtual pins only fire when changed not immediately adjusted for inputted values.

also the pins writes are coded as intended i defined the pins in the top section of my code…?

Okay, well, you can’t use the digitalRead command to read data from a Blynk virtual pin.
digitalRead is using non-Blynk functionality to read the value from a digital (GPIO) pin on your ESP32 - but of course the ESP32 doesnt have a pin V15, V16, V17 etc.

The way to read-back stored values from the app is to use the BLYNK_CONNECTED() function, which it triggered every time your device connects or re-connects to the Blynk server, then within that function have Blynk.syncVirtual(vPin) commands for each virtual pin that you want to obtain the value from.
These Blynk.syncVirtual commands will cause the corresponding `BLYNK_WRITE(vPIN) functions to be triggered.

More on this in the Virtual Pin document that I linked to earlier.

Pete.