HELP - Blynk Not Updating

Hello, I have been a happy Blynk user for over a year now with about 4 or 5 ESP Arduino devices sending data to the cloud. But I have troubles off and on with my hydro monitor when making changes to the code. When I leave it alone it runs perfect. It is only when I am making changes and downloading a zillion times when suddenly it stops working. And over the year or so of developing the code this issue has only happened 3 or 4 times but it is very tiring and I would like to understand why and fix it for good.

Each time it has happened I have tried the following with no success:
-Google and check forums.
-Revert back to previous versions of firmware that were working.
-Reboot my computer and try again.
-Get annoyed and quit and come back the next day.
-Annoy my Friend who introduced me to Blynk. :wink:
-try another ESP8266 with the same code.

Meanwhile, my other 3 or 4 devices are working fine, although I am not touching them, they are just running and updating Blynk throughout this problem.

What happens is eventually after poking around and ripping my hair out it starts to work again and I have no idea why it stopped and no idea why it is working again.

It feels like the Blynk server gets mad and ignores the virtual pins on this one device for some random time?

I send out the following serial data and it I think it is the same working or not but below is not working:
,
[568] Connecting to blynk-cloud.com:80
,7166

502[13361] Connecting to blynk-cloud.com:80
,7148
503[20510] Connecting to blynk-cloud.com:80
,7148
503[27658] Connecting to blynk-cloud.com:80
,7125
505[34784] Connecting to blynk-cloud.com:80
,7128
505[41913] Connecting to blynk-cloud.com:80


I am running:
-Arduino 1.8.13
-Blynk Ver 0.6.1 by Volodymyr Shymansky
-ESP8266 Commmunity Ver 2.7.4 board manager

Below is my code:
```// https://www.arduino.cc/reference/en/
// 
// https://arduino-esp8266.readthedocs.io/en/latest/
//
// Average high time is 88.60mS by Scope
//
#include <ESP8266WiFi.h>

//BLYNK
#define BLYNK_PRINT Serial
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
char auth[] = "????"; //HERE YOU HAVE TO SET THE TOKEN GENERATED BY THE APP
char ssid[] = "????";
char pass[] = "???";
const int HydroPin = 5, HBeat = 16;
unsigned long time_now = 0, monthlyPulseCount = 0;
//int period = 60000;                               // time delay is one minute
int period = 6000;                              // delay is six seconds
unsigned int nowPulseCount = 0, wattHours = 0;
static bool flagClearMonthlyPulseCount = 0; 

// provide a way to clear totalPulses from the app
BLYNK_WRITE(V36) { 
  flagClearMonthlyPulseCount = param.asInt(); // save status
}

// this interupt just counts risting pulses (one puls per watt)
ICACHE_RAM_ATTR void wattCounter() {
  monthlyPulseCount++;
}
// call this for every pulse from hydro meter
void wiggleHeartBeat(){
  static bool flipflop = false;
  pinMode(HBeat, OUTPUT);
  if(flipflop == true){
    flipflop = false;
    digitalWrite(HBeat, HIGH);
    Blynk.virtualWrite(V30, 0);       // tell app a puls came in
    Blynk.run();
  }
  else{
    flipflop = true;
    digitalWrite(HBeat, LOW);
    Blynk.virtualWrite(V30, 255);     // tell app a puls came in
    Blynk.run();
  }
}

void setup() {
  Serial.begin(115200);
  pinMode(HydroPin, INPUT);
  Serial.println("The Hydro Monitor");
  WiFiClient client;
  WiFi.hostname("HydroMonitor");
  Serial.println(WiFi.localIP());
  Blynk.config(auth, "blynk-cloud.com", 80); //CONNECTION TO THE BLYNK SERVER
  //Blynk.begin(auth, ssid, pass);
  delay(500);
  monthlyPulseCount = 0;
  attachInterrupt(digitalPinToInterrupt(HydroPin), wattCounter, RISING);
  time_now = 0;                           // make sure zero for first entry into loop.
}

void loop() {
  // count pulses for one minute
  nowPulseCount = 0;
  do {
    pulseIn(HydroPin, HIGH, 10000000);
    nowPulseCount++;                    // count high pulses 
  } while (millis() - time_now < period); // has a minute elapsed?
  // reset timer for next minute while we do stuff.
  time_now = millis();
  wattHours = nowPulseCount * 60;        // we counted for one minute convert to one hour.
  Serial.print(nowPulseCount); Serial.print(","); Serial.println(wattHours);
  Blynk.virtualWrite(V31, wattHours);
  Blynk.virtualWrite(V35, monthlyPulseCount);
  wiggleHeartBeat();
  Serial.println("wiggle heart beat");
  // now check to see if we are being asked to reset the monthly count
  if (flagClearMonthlyPulseCount != 0){
    monthlyPulseCount = 0;
    Serial.print("Clearing Monthly pulse counter");
    Blynk.virtualWrite(V35, monthlyPulseCount);
  }
  // now update blynk
  Blynk.syncVirtual(V36); 
  Blynk.run();
}
  

Well, first of all, you should read about this…

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

Then you should read this…

https://docs.blynk.cc/#blynk-firmware-configuration-blynkconfig

especially the part that says …

NOTE: After Blynk.config(...) is called, your hardware is not yet connected to the server. It will try to connect while until it hits first instance of Blynk.run() or Blynk.connect() routine.

Pete.

Pete, thank you that is my problem and I have a simple version that works now so I need to back port it to my other projects.

What I still don’t understand however is why does it work most of the time and the sometimes spaze out when I am changing the code?

And why does a previous release that was working no longer work?

Is there something with Blynk I need to reset or clear?

It’s a bit like saying “sometimes my car won’t start - why is this” it’s impossible to say without more specific information.

Pete.

Yes, the car analogy, I understand. Things are working well now. Thank you for your help.