WEMOS D1 will not connect to BLYNK

I am new to Blynk and trying to get it to reliably connect to the cloud. I have been able to previously connect a couple times but in between managing through other issues I have somehow lost any chance at connection. While I feel like there was initially something going on around the DNS settings, I have take everything back to original condition with my project script. Running the connection testing script postde below I still am not getting a connection established. I am running BLYNK Lib 0.6.1. Arduino IDE 1.8.13. I am using the ArduinoOTA lib for my project, but not in this test. The debug running with this test code outputs

18:30:56.966 -> [10002] Connecting to 0.0.0.0
18:31:01.961 -> [15003] Connecting to 0.0.0.0
18:31:06.961 -> [20004] Connecting to 0.0.0.0
18:31:11.967 -> [25005] Connecting to 0.0.0.0
18:31:16.974 -> [30006] Connecting to 0.0.0.0
18:31:21.975 -> [35007] Connecting to 0.0.0.0
18:31:26.964 -> [40008] Connecting to 0.0.0.0
18:31:31.970 -> [45009] Connecting to 0.0.0.0
18:31:36.961 -> [50010] Connecting to 0.0.0.0
18:31:41.971 -> [55011] Connecting to 0.0.0.0
18:31:46.974 -> [60012] Connecting to 0.0.0.0
18:31:51.981 -> [65013] Connecting to 0.0.0.0
18:31:56.965 -> [70014] Connecting to 0.0.0.0
18:32:01.989 -> [75015] Connecting to 0.0.0.0
18:32:06.967 -> [80016] Connecting to 0.0.0.0
18:32:11.995 -> [85017] Connecting to 0.0.0.0
18:32:16.990 -> [90018] Connecting to 0.0.0.0
18:32:21.962 -> [95019] Connecting to 0.0.0.0
18:32:26.967 -> [100020] Connecting to 0.0.0.0
18:32:31.965 -> [105021] Connecting to 0.0.0.0
18:32:36.983 -> [110022] Connecting to 0.0.0.0
18:32:41.983 -> [115023] Connecting to 0.0.0.0
I don’t have an issue connecting to the wifi account, just establishing a connetion to Blynk. I have also noticed my debug does not seem to show what it should like something is wrong with a file. The BLYNK graphic in the serial monitor is never produced and I do not get much at all out of it. When I manually write serial debugs in I do get that information back out but based on some other snips of debug screens mine is not on par with them.


#define BLYNK_PRINT Serial  // This prints to Serial Monitor
#define BLYNK_DEBUG  // Optional, this enables more detailed prints
#include <ESP8266WiFi.h>  // for ESP8266
#include <BlynkSimpleEsp8266.h>  // for ESP8266

char auth[] = "yxpA2SPSYelt5sViTVkX9YKPK8j1E-88";
char ssid[] = "GOHAWKS";
char pass[] = "harper2010";
//char server[] = "xxx.xxx.xxx.xxx";  // IP for your Local Server
//int port = 8080;



void setup() {
  Serial.begin(9600);  // BLYNK_PRINT data
  WiFi.begin(ssid, pass); 
 // Blynk.config(auth, server, port);
  Blynk.connect();
}



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

Hi, you need to change this line . . .

To

Blynk.config(auth);
Blynk.connect();

cul
billd

1 Like

Bill, Thanks for the help there. So that explains the test code which certainly fixed that issue and helped me understand a bit more of what’s going on. The problem is that my actual project already has that code in place and not commented out. There must be another problem causing the same result. I’m sure it is related to more syntax issues but I let you take a look.

#define BLYNK_DEBUG
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <ArduinoOTA.h>
#include <WidgetRTC.h>
#define BLYNK_PRINT Serial
//LittleFS includes
#include <ArduinoJson.h>
#include "FS.h"
#include <LittleFS.h>

char auth[] = "--";
char ssid[] = "--";
char pass[] = "--";

byte sensorInterrupt = 4;  // 0 = digital pin 2
byte sensorPin       = 4;

// The hall-effect flow sensor outputs approximately 4.5 pulses per second per
// litre/minute of flow.
float calibrationFactor = 2.25;

volatile byte pulseCount;                    //must be a volatile variable because triggered in a interrupt routine

float flowRate;
unsigned int flowMilliLitres;
unsigned long totalMilliLitres;
unsigned long totalLitres;

String currentTime;
String currentDate;
String yesterDate;

int ReCnctFlag;
int ReCnctCount;

int SThour;
int STmin;
int STsec;

bool litersResetFlag = 1;
bool flowNotifyFlage = 0;

unsigned long oldTime;

BlynkTimer timer;
BlynkTimer timer1;
WidgetRTC rtc;
WidgetTerminal terminal1(V8);
WidgetTable table;

BLYNK_ATTACH_WIDGET(table, V1);

int rowIndex;

//Set your Static IP address
IPAddress local_IP(192, 168, 1, 25);
//Set your Gateway IP address
IPAddress gateway(192, 168, 1, 1);

IPAddress subnet(255, 255, 255, 0);
IPAddress primaryDNS(8, 8, 8, 8);   //optional
IPAddress secondaryDNS(8, 8, 4, 4); //optional

bool loadData() {
  File dataFile = LittleFS.open("/data.json", "r");
  if (!dataFile) {
    Serial.println("Failed to open data file");
    return false;
  }

  size_t size = dataFile.size();
  if (size > 1024) {
    Serial.println("Data file size is too large");
    return false;
  }

  // Allocate a buffer to store contents of the file.
  std::unique_ptr<char[]> buf(new char[size]);

  // We don't use String here because ArduinoJson library requires the input
  // buffer to be mutable. If you don't use ArduinoJson, you may as well
  // use configFile.readString instead.
  dataFile.readBytes(buf.get(), size);

  StaticJsonDocument<100> doc;
  auto error = deserializeJson(doc, buf.get());
  if (error) {
    Serial.println("Failed to parse config file");
    return false;
  }

  totalMilliLitres = doc["totalMilliLitres"];
  yesterDate = doc["yesterDate"].as<String>();   ////Note: loading as string from LittleFS
  return true;
}

bool saveData() {
  StaticJsonDocument<100> doc;

  doc["totalMilliLitres"] = totalMilliLitres;
  doc["yesterDate"] = yesterDate;                ////Note: but to save does not work to load as<String>..
  
  File dataFile = LittleFS.open("/data.json", "w");
  if (!dataFile) {
    Serial.println("Failed to open config file for writing");
    return false;
  }

  serializeJson(doc, dataFile);
  return true;
}

void ICACHE_RAM_ATTR pulseCounter()
{
  // Increment the pulse counter
  pulseCount++;
}

void setup()
{
  pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, LOW);
  WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS);//
  WiFi.begin(ssid,pass);
  Serial.begin(9600);
  Blynk.config(auth);
  Blynk.connect();
  ArduinoOTA.setHostname("flowmeter_v5pnt4");
  ArduinoOTA.begin();

  if (!LittleFS.begin()) 
  {
    Serial.println("Failed to mount file system");
    return;
  }

  if (!loadData()) 
  {
    Serial.println("Failed to load Data");
  } 
  else 
  {
    Serial.println("Data loaded");
  }

  timer.setInterval(1000L, sendValues);
  delay(100);
  timer.setInterval(1000L, printTIME);
  delay(100);
  timer.setInterval(1000L, WiFistrength);
  delay(100);
  timer.setInterval(10000L, checkcounterReset);
  
  
  digitalWrite(sensorPin, HIGH);

  setSyncInterval(720*60);

  pulseCount        = 0;
  flowRate          = 0.0;
  flowMilliLitres   = 0;
  //totalMilliLitres  = 0;
  oldTime           = 0;

  // The Hall-effect sensor is connected to pin 2 which uses interrupt 0.
  // Configured to trigger on a FALLING state change (transition from HIGH
  // state to LOW state)
  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
  
}

BLYNK_CONNECTED()
{
  rtc.begin();
  ReCnctCount = 0;
  printTIME();
  Blynk.syncVirtual(V9);
  //Blynk.syncVirtual(V0);
  timer.setTimeout(5000L,[](){                                   //Lambda "Reconnection" timer function
      terminal1.println(" ");
      terminal1.println(String ("Connected ") + currentTime + " " + currentDate);
      terminal1.println(String ("Yesterdate ") + yesterDate);
      terminal1.flush();
    });
    
  Blynk.syncVirtual(V12);
  Blynk.syncVirtual(V7);
}

void loop()
{
  ArduinoOTA.handle();
  Blynk.run();
  timer.run();
  
  if (Blynk.connected())
  {                                             //If Blynk connected run as normal
    Blynk.run();
    Serial.println("Blynk Connected");
  }
  else if (ReCnctFlag == 0){                                          //test connection flag
    Serial.println("Blynk Failed to Connect, Trying Again");
    ReCnctFlag = 1;                                                 //set connection flag
    timer.setTimeout(60000L,[](){                                   //Lambda "Reconnection" timer function
      ReCnctFlag = 0;
      ReCnctCount++;                                                //count up reconnection attempts
      Blynk.connect();                                              //try to connect again
    });
  }
}

void sendValues()
{
    detachInterrupt(sensorInterrupt);
       
    // Because this loop may not complete in exactly 1 second intervals we calculate
    // the number of milliseconds that have passed since the last execution and use
    // that to scale the output. We also apply the calibrationFactor to scale the output
    // based on the number of pulses per second per units of measure (litres/minute in
    // this case) coming from the sensor.
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
   
    // Note the time this processing pass was executed. Note that because we've
    // disabled interrupts the millis() function won't actually be incrementing right
    // at this point, but it will still return the value it was set to just before
    // interrupts went away.
    oldTime = millis();
   
    // Divide the flow rate in litres/minute by 60 to determine how many litres have
    // passed through the sensor in this 1 second interval, then multiply by 1000 to
    // convert to millilitres.
    flowMilliLitres = (flowRate / 60) * 1000;
   
    // Add the millilitres passed in this second to the cumulative total
    totalMilliLitres += flowMilliLitres;
     
    unsigned int frac;
   
    // Reset the pulse counter so we can start incrementing again
    pulseCount = 0;
   
    // Enable the interrupt again now that we've finished sending output
    attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
    totalLitres = (totalMilliLitres/1000);
    Blynk.virtualWrite(V0, totalMilliLitres);
    Blynk.virtualWrite(V1, totalLitres);
    Blynk.virtualWrite(V6, flowRate);
    
    if(flowRate >= 3.1 && flowNotifyFlage == true)
    {
      Blynk.notify(String ("Waters flowing @ ") + flowRate + (" L/Min"));
      flowNotifyFlage = false;
      timer.setTimeout(3600000L,[]()
      {                                   //after one hour reset notify
        flowNotifyFlage = true;
      });
    }
    
  if (!saveData())                         //save mL to little FS
  {
    Serial.println("Failed to save Data");
  } 
  else 
  {
    Serial.println("Data saved");
  }
 
}

void checkcounterReset()                         //time input
{
 if(hour() == SThour)
 {                           //daily clear total liters
  if((minute() >= STmin) && (minute() <= (STmin + 50)))
  {
    if(litersResetFlag == 0)
    {
      litersResetFlag = 1;                           //change flag so only exicute once
      Blynk.notify(String ("Yesterdays water ") + (totalMilliLitres / 1000));

    
      if(totalMilliLitres >= 1000)
      {
        Blynk.virtualWrite(V10, "add", rowIndex , yesterDate + String("  Water received"),(totalMilliLitres/1000) + String(" L")) ;
        Blynk.virtualWrite(V10, "pick", rowIndex);
        yesterDate = currentDate;
        terminal1.println(" ");
        terminal1.print(yesterDate);
        terminal1.flush();
        
        if (!saveData()) 
        {
          Serial.println("Failed to save Data");
        } else {
        terminal1.println(" ");
        terminal1.print("Saved LittleFS");
        terminal1.flush();
        }

      }
      else
      {
        Blynk.virtualWrite(V10, "add", rowIndex , yesterDate + String("    No Water"),(totalMilliLitres/1000) + String(" L")) ;
        Blynk.virtualWrite(V10, "pick", rowIndex);
        terminal1.println(" ");
        terminal1.print(yesterDate);
        terminal1.flush();
        yesterDate = currentDate;
        terminal1.println(" ");
        terminal1.print(yesterDate);
        terminal1.println("");
        terminal1.flush();

        if (!saveData()) 
        {
          terminal1.print("Failed to save Data");
          terminal1.flush();
        } else {
          terminal1.print("Data saved");
          terminal1.flush();
        }
      }
      
      rowIndex++; 
      totalMilliLitres = 0;
      Blynk.virtualWrite(V6,totalMilliLitres);
      Blynk.virtualWrite(V12, rowIndex);
    }
  }
 }

 
 
 if(hour()== 23 && litersResetFlag == 1){                            //change flag so that counter can be reset next day
    if(minute()>= 01){
      litersResetFlag = 0;
      yesterDate = currentDate;
      terminal1.println(" ");
      terminal1.print(yesterDate);
      terminal1.println(" ");
      terminal1.println(String ("Changeflag ") + currentTime + " " + currentDate);
      terminal1.flush();
      Blynk.notify("ChangeFlag");

      if (!saveData())                         //save mL to little FS
      {
        Serial.println("Failed to save Data");
      } 
      else 
      {
        Serial.println("Data saved");
      }
    }
  }
}

void printTIME()                                //what it says!
{
  currentDate = String(day())+ "/" + month();
  currentTime = String(hour())+ ":" + minute() + ":" + second();
  Blynk.virtualWrite(V4, currentTime);
}

void WiFistrength()                              //prints wifi strength
{
  long rssi = WiFi.RSSI();           
  Blynk.virtualWrite(V5,rssi);
}

BLYNK_WRITE(V0)
{
  totalMilliLitres = param.asInt();
}

BLYNK_WRITE(V2)
{
  if (param.asInt())
  {                             //manual reset Liters
    totalMilliLitres = 0;
    Blynk.virtualWrite(V1, totalLitres);
  }
}

BLYNK_WRITE(V3)
{
  if(param.asInt())
  {                             //manual uptick for testing
    totalMilliLitres += 1000; 
    Blynk.virtualWrite(V0, totalMilliLitres);
    Blynk.virtualWrite(V1, totalLitres);
  }
}

BLYNK_WRITE(V7)
{
  if(param.asInt())
  {
    flowNotifyFlage = false;
  }else{
    flowNotifyFlage = true;
  }
}

BLYNK_WRITE(V9)
{
  TimeInputParam t(param);                        //time input
  SThour = t.getStartHour();
  STmin = t.getStartMinute();
  
  litersResetFlag = 0;

  terminal1.println(" ");
  terminal1.println(String("Counter reset time ") + t.getStartHour() + ":" +
               t.getStartMinute());
  terminal1.flush();   
  
}

BLYNK_WRITE(V11)
{
  if (param.asInt()){                             //manual reset esp if needed
    Blynk.notify("Reseting ESP in 5s");
    timer.setTimeout(5000L,[]()
      {                                   //after one hour reset notify
         ESP.reset();
      });
  }
}

BLYNK_WRITE(V12)
{
  rowIndex = param.asInt();
}

BLYNK_WRITE(V14)
{
  if (param.asInt())
  {
    //Blynk.notify("ResetFlag");
    litersResetFlag = 0;
    Blynk.virtualWrite(V14, 0);
  }
}

Hi,

I’m not familiar with json type coding, there are a lot of things that don’t look right to me, but that may be because the syntax is different than I’m used to.

I’d suggest some structured troubleshooting, start with the basic sketch that you now know works - then add segments/functions of your project in sequence to determine what breaks the connection.

I’d add the Blynk code first, then confirm.

Then add the bare bones to read the sensor, then confirm, then gradually add the other stuff later.

cul

billd

I’m wondering if your provider is blocking your blynk traffic. Running this in the command prompt.

ping blynk-cloud.com

and see what the results are.

It’s my sketch, I didn’t look over it to see if anything was changed to bad, but the original works great. I use that json parsing to LittleFS in most of my projects. Dead easy and stores all the variables in LittleFS after every change so any reboot or internet drop doesn’t affect anything.

1 Like

I think he proved Blynk is OK with the very basic sketch at the top of the thread (after he added Blynk.config(auth); back in . . . :slight_smile:
billd

1 Like

I’ll add this to the ever growing list of stuff to investigate :wink:
billd

1 Like

So what does the serial monitor show when running this code?

My first move would be to reboot the router and any additional access points you have, and run an IP scanner to ensure that no other device is using that IP address.
Have you reserved this IP address in your router for this particular device, or changed your DHCP pool settings to exclude 192.168.1.25 ?
If not then it’s very likely that another device will already have been allocated this IP address.

Personally, I assign static IPs to all of my IoT devices in the .200+ range and set my DHCP pool to allocate up to .199 so there is no risk of an IP clash and I don’t have to keep maintaining my router’s list of reserved IP/MAC address combos.

Pete.

That sketch was old I don’t remember if it worked here is one that is kind of working now. There is one problem that I am trouble shooting is that the water 0’s at midnight the last couple of nights. Not sure if it is a network issue or if it is some how calling my V2 function. Or maybe its just a gremlin somewhere in the clouds… It isn’t my timed reset because then it would call the notify. I added a notify in the V2 function to see if that will give me any info tonight.

#define BLYNK_PRINT Serial // Defines the object that is used for printing
#define BLYNK_DEBUG        // Optional, this enables more detailed prints
/* Comment this out to disable prints and save space */

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <ArduinoOTA.h>
#include <WidgetRTC.h>
#include <ESP8266mDNS.h>              //for OTA
#include <WiFiUdp.h>                  //for OTA

//LittleFS includes
#include <ArduinoJson.h>
#include "FS.h"
#include <LittleFS.h>

char auth[] = "";
char ssid[] = "";
char pass[] = "";

byte sensorInterrupt = 4;  // 0 = digital pin 2
byte sensorPin       = 4;

// The hall-effect flow sensor outputs approximately 4.5 pulses per second per
// litre/minute of flow.
float calibrationFactor = 2.25;

volatile byte pulseCount;                    //must be a volatile variable because triggered in a interrupt routine

float flowRate;
unsigned int flowMilliLitres;
unsigned long totalMilliLitres;
unsigned long totalLitres;

String currentTime;
String currentDate;
String yesterDate;

int ReCnctFlag;
int ReCnctCount;

int SThour;
int STmin;
int STsec;

bool litersResetFlag = 0;
bool flowNotifyFlage = 0;

unsigned long oldTime;
String strsetHostname;

BlynkTimer timer;
BlynkTimer timer1;
WidgetRTC rtc;
WidgetTerminal terminal1(V8);
WidgetTable table;

BLYNK_ATTACH_WIDGET(table, V1);

int rowIndex;

// Set your Static IP address
IPAddress local_IP(192, 168, 0, 42);
// Set your Gateway IP address
IPAddress gateway(192, 168, 0, 1);

IPAddress subnet(255, 255, 255, 0);
IPAddress primaryDNS(8, 8, 8, 8);   //optional
IPAddress secondaryDNS(8, 8, 4, 4); //optional

bool loadData() {
  File dataFile = LittleFS.open("/data.json", "r");
  if (!dataFile) {
    //Serial.println("Failed to open data file");
    return false;
  }

  size_t size = dataFile.size();
  if (size > 1024) {
    //Serial.println("Data file size is too large");
    return false;
  }

  // Allocate a buffer to store contents of the file.
  std::unique_ptr<char[]> buf(new char[size]);

  // We don't use String here because ArduinoJson library requires the input
  // buffer to be mutable. If you don't use ArduinoJson, you may as well
  // use configFile.readString instead.
  dataFile.readBytes(buf.get(), size);

  StaticJsonDocument<100> doc;
  auto error = deserializeJson(doc, buf.get());
  if (error) {
    Serial.println("Failed to parse config file");
    return false;
  }

  totalMilliLitres = doc["totalMilliLitres"];
  yesterDate = doc["yesterDate"].as<String>();   ////Note: loading as string from LittleFS
  litersResetFlag = doc["litersResetFlag"];
  Blynk.virtualWrite(V1, totalLitres);
  return true;
}

bool saveData() {
  StaticJsonDocument<100> doc;

  doc["totalMilliLitres"] = totalMilliLitres;
  doc["yesterDate"] = yesterDate;                ////Note: but to save does not work to load as<String>..
  doc["litersResetFlag"] = litersResetFlag;
  
  File dataFile = LittleFS.open("/data.json", "w");
  if (!dataFile) {
    //Serial.println("Failed to open config file for writing");
    return false;
  }

  serializeJson(doc, dataFile);
  return true;
}

void ICACHE_RAM_ATTR pulseCounter()
{
  // Increment the pulse counter
  pulseCount++;
}

void printTIME()                                //what it says!
{
  currentDate = String(day())+ "/" + month();
  currentTime = String(hour())+ ":" + minute() + ":" + second();
  Blynk.virtualWrite(V4, currentTime);
}

void WiFistrength()                              //prints wifi strength
{
  long rssi = WiFi.RSSI();           
  Blynk.virtualWrite(V5,rssi);
}

void setup()
{
  Serial.begin(115200);
  pinMode(D3, OUTPUT);
  digitalWrite(D3, HIGH);
  
  pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, LOW);
  WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS);
  WiFi.begin(ssid,pass);
  
  if (WiFi.waitForConnectResult() != WL_CONNECTED)         //was while loop
  {       
    Serial.println("Connection Failed! Rebooting...");
    delay(1000);                                            //was 5s
    ESP.restart();
  }

  ArduinoOTA.setHostname("flowmeter_v7");
  ArduinoOTA.begin();
  
  Blynk.config(auth);
  Blynk.connect();

  if (!LittleFS.begin()) 
  {
    Serial.println("Failed to mount file system");
    return;
  }

  if (!loadData()) 
  {
    Serial.println("Failed to load Data");
  } 
  else 
  {
    Serial.println("Data loaded");
  }

  timer.setInterval(1000L, sendValues);
  delay(100);
  timer.setInterval(1000L, printTIME);
  delay(100);
  timer.setInterval(1000L, WiFistrength);
  delay(100);
  timer.setInterval(10000L, checkcounterReset);
  
  digitalWrite(sensorPin, HIGH);

  setSyncInterval(720*60);

  pulseCount        = 0;
  flowRate          = 0.0;
  flowMilliLitres   = 0;
  //totalMilliLitres  = 0;
  oldTime           = 0;

  // The Hall-effect sensor is connected to pin 2 which uses interrupt 0.
  // Configured to trigger on a FALLING state change (transition from HIGH
  // state to LOW state)
  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
  
}

BLYNK_CONNECTED()
{
  rtc.begin();
  ReCnctCount = 0;
  printTIME();
  Blynk.syncVirtual(V9);
  Blynk.syncVirtual(V7);
  timer.setTimeout(5000L,[](){                                   //Lambda "Reconnection" timer function
      terminal1.println(" ");
      terminal1.println(String ("Connected ") + currentTime + " " + currentDate);
      //terminal1.println(String ("Yesterdate ") + yesterDate);
      terminal1.flush();
      if (!loadData()) 
      {
        terminal1.println("Failed to load on Connect");
        terminal1.flush();
      } 
      else 
      {
        terminal1.println("Loaded on Connect");
        terminal1.flush();
      }
      Blynk.syncVirtual(V12);
   });
   
  
}

void loop()
{
  ArduinoOTA.handle();
  //Blynk.run();
  timer.run();
  
  if (Blynk.connected())
  {                                             //If Blynk connected run as normal
    Blynk.run();
  }
  else if (ReCnctFlag == 0){                                          //test connection flag
    ReCnctFlag = 1;                                                 //set connection flag
    timer.setTimeout(600000L,[](){                                   //Lambda "Reconnection" every 10 minutes
      ReCnctFlag = 0;
      ReCnctCount++;                                                //count up reconnection attempts
      Blynk.connect();                                              //try to connect again
    });
  }
}

void sendValues()
{
    detachInterrupt(sensorInterrupt);
       
    // Because this loop may not complete in exactly 1 second intervals we calculate
    // the number of milliseconds that have passed since the last execution and use
    // that to scale the output. We also apply the calibrationFactor to scale the output
    // based on the number of pulses per second per units of measure (litres/minute in
    // this case) coming from the sensor.
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
   
    // Note the time this processing pass was executed. Note that because we've
    // disabled interrupts the millis() function won't actually be incrementing right
    // at this point, but it will still return the value it was set to just before
    // interrupts went away.
    oldTime = millis();
   
    // Divide the flow rate in litres/minute by 60 to determine how many litres have
    // passed through the sensor in this 1 second interval, then multiply by 1000 to
    // convert to millilitres.
    flowMilliLitres = (flowRate / 60) * 1000;
   
    // Add the millilitres passed in this second to the cumulative total
    totalMilliLitres += flowMilliLitres;
     
    //unsigned int frac;
   
    // Reset the pulse counter so we can start incrementing again
    pulseCount = 0;
   
    // Enable the interrupt again now that we've finished sending output
    attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
    totalLitres = (totalMilliLitres/1000);
    Blynk.virtualWrite(V0, totalMilliLitres);
    Blynk.virtualWrite(V1, totalLitres);
    Blynk.virtualWrite(V6, flowRate);
    
    if(flowRate >= 3.1 && flowNotifyFlage == true)
    {
      Blynk.notify(String ("Waters flowing @ ") + flowRate + (" L/Min"));
      flowNotifyFlage = false;
      timer.setTimeout(3600000L,[]()
      {                                   //after one hour reset notify
        flowNotifyFlage = true;
      });
    }
    
  if (!saveData())                         //save mL to little FS
  {
    terminal1.println("Failed to load on Send values");
    terminal1.flush();
  } 
  else 
  {
    Serial.println("Data saved");
  }
 
}

void checkcounterReset()                         //time input
{
 if(hour() == SThour)
 {                           //daily clear total liters
  if(minute() >= STmin)
  {
    if(litersResetFlag == 0)
    {
      litersResetFlag = 1;                           //change flag so only exicute once
      Blynk.notify(String ("Yesterdays water ") + (totalMilliLitres / 1000));

    
      if(totalMilliLitres >= 1000)
      {
        Blynk.virtualWrite(V10, "add", rowIndex , yesterDate + String("  Water received"),(totalMilliLitres/1000) + String(" L")) ;
        Blynk.virtualWrite(V10, "pick", rowIndex);
        yesterDate = currentDate;
        terminal1.println(" ");
        terminal1.print(yesterDate);
        terminal1.flush();
        
        if (!saveData()) 
        {
          Serial.println("Failed to save Data");
        } else {
        terminal1.println(" ");
        terminal1.print("Saved LittleFS");
        terminal1.flush();
        }

      }
      else
      {
        Blynk.virtualWrite(V10, "add", rowIndex , yesterDate + String("    No Water"),(totalMilliLitres/1000) + String(" L")) ;
        Blynk.virtualWrite(V10, "pick", rowIndex);
        terminal1.println(" ");
        terminal1.print(yesterDate);
        terminal1.flush();
        yesterDate = currentDate;
        terminal1.println(" ");
        terminal1.print(yesterDate);
        terminal1.println("");
        terminal1.flush();

        if (!saveData()) 
        {
          terminal1.print("Failed to save Data");
          terminal1.flush();
        } else {
          terminal1.print("Data saved");
          terminal1.flush();
        }
      }
      
      rowIndex++; 
      totalMilliLitres = 0;
      Blynk.virtualWrite(V6,totalMilliLitres);
      Blynk.virtualWrite(V12, rowIndex);
    }
  }
 }
 
 if((hour()== 23)&& (litersResetFlag == 1)){                            //change flag so that counter can be reset next day
    if(minute()>= 01){
      litersResetFlag = 0;
      yesterDate = currentDate;
      //terminal1.println(" ");
      terminal1.print(yesterDate);
      terminal1.println(String ("Changeflag ") + currentTime + " " + currentDate);
      terminal1.println(" ");
      terminal1.flush();
      Blynk.notify("ChangeFlag");

      if (!saveData())                         //save mL to little FS
      {
        Serial.println("Failed to save Data");
      } 
      else 
      {
        Serial.println("Data saved");
      }
    }
  }
}

BLYNK_WRITE(V0)
{
  totalMilliLitres = param.asInt();
}

BLYNK_WRITE(V2)
{
  if (param.asInt())
  {                             //manual reset Liters
    totalMilliLitres = 0;
    Blynk.virtualWrite(V1, totalLitres);
    Blynk.notify("Reset counter");
  }
}

BLYNK_WRITE(V3)
{
  if(param.asInt())
  {                             //manual uptick for testing
    totalMilliLitres += 1000; 
    Blynk.virtualWrite(V0, totalMilliLitres);
    Blynk.virtualWrite(V1, totalLitres);
  }
}

BLYNK_WRITE(V7)
{
  if(param.asInt())
  {
    flowNotifyFlage = false;
  }else{
    flowNotifyFlage = true;
  }
}

BLYNK_WRITE(V9)
{
  TimeInputParam t(param);                        //time input
  SThour = t.getStartHour();
  STmin = t.getStartMinute();
  
  litersResetFlag = 0;

  terminal1.println(" ");
  terminal1.println(String("Counter reset time ") + t.getStartHour() + ":" +
               t.getStartMinute());
  terminal1.flush();   
  
}

BLYNK_WRITE(V11)
{
  if (param.asInt()){                             //manual reset esp if needed
    Blynk.notify("Reseting ESP in 5s");
    timer.setTimeout(5000L,[]()
      {                                   //after one hour reset notify
         ESP.reset();
      });
  }
}

BLYNK_WRITE(V12)
{
  rowIndex = param.asInt();
}

BLYNK_WRITE(V14)
{
  if (param.asInt())
  {
    //Blynk.notify("ResetFlag");
    litersResetFlag = 0;
    Blynk.virtualWrite(V14, 0);
  }
}

BLYNK_WRITE(V15)
{
    if (param.asInt())
    {
       digitalWrite(D3,LOW);
       timer.setTimeout(900L,[]()
       {                             
        digitalWrite(D3,HIGH);
        Blynk.virtualWrite(V15,0);
       });
    }
}

Dave, appreciate you chimming in and opening the door(for me) to Little FS. Didn’t know about it and your program is almost exactly what I am after with my water meter program, keeping track of monthly/daily water usage. I can definitely ping the Blynk cloud with no issues. I was able to quickly resolve the test script above and the program communicated to the Blynk server just fine. IP was my originally my first concern so I reserved that IP in my router settings. That’s not it. My serial monitor just spits out a couple debugs I inserted. Every minute it will try to connect and start over with the same repeating message. I’ll try your other code.

-Nick

07:15:17.683 -> $nٴ⸮`fC[⸮xKż⸮Data loaded
07:15:27.150 -> Blynk Failed to Connect, Trying Again
07:15:27.883 -> Data saved
07:15:28.887 -> Data saved
07:15:29.858 -> Data saved
07:15:30.855 -> Data saved
07:15:31.884 -> Data saved
07:15:32.865 -> Data saved
07:15:33.857 -> Data saved
07:15:35.331 -> Data saved
07:15:35.852 -> Data saved
07:15:36.853 -> Data saved
07:15:37.856 -> Data saved
07:15:38.847 -> Data saved
07:15:39.861 -> Data saved
07:15:40.857 -> Data saved
07:15:41.853 -> Data saved
07:15:42.827 -> Data saved
07:15:43.838 -> Data saved
07:15:44.856 -> Data saved
07:15:45.846 -> Data saved
07:15:46.831 -> Data saved
07:15:47.856 -> Data saved
07:15:48.854 -> Data saved
07:15:49.862 -> Data saved
07:15:50.840 -> Data saved
07:15:51.836 -> Data saved
07:15:52.868 -> Data saved
07:15:53.851 -> Data saved
07:15:54.851 -> Data saved
07:15:55.837 -> Data saved
07:15:56.849 -> Data saved
07:15:57.854 -> Data saved
07:15:58.857 -> Data saved
07:15:59.862 -> Data saved
07:16:00.857 -> Data saved
07:16:01.862 -> Data saved
07:16:02.873 -> Data saved
07:16:03.856 -> Data saved
07:16:04.862 -> Data saved
07:16:05.847 -> Data saved
07:16:06.864 -> Data saved
07:16:07.863 -> Data saved
07:16:08.861 -> Data saved
07:16:09.861 -> Data saved
07:16:10.862 -> Data saved
07:16:11.881 -> Data saved
07:16:12.874 -> Data saved
07:16:13.850 -> Data saved
07:16:14.857 -> Data saved
07:16:15.881 -> Data saved
07:16:17.137 -> Data saved
07:16:17.843 -> Data saved
07:16:18.822 -> Data saved
07:16:19.850 -> Data saved
07:16:20.856 -> Data saved
07:16:21.840 -> Data saved
07:16:22.854 -> Data saved
07:16:23.842 -> Data saved
07:16:24.843 -> Data saved
07:16:25.894 -> Data saved
07:16:26.852 -> Data saved
07:16:36.151 -> Blynk Failed to Connect, Trying Again
07:16:36.190 -> Data saved
07:16:36.860 -> Data saved
07:16:37.852 -> Data saved
07:16:38.857 -> Data saved

In cmd line type this and show us the results

ipconfig /all

Windows IP Configuration

Host Name . . . . . . . . . . . . : User-PC
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : mahaska.org

Ethernet adapter Local Area Connection:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Intel® 82567LM-3 Gigabit Network Connection
Physical Address. . . . . . . . . : 00-23-24-04-E5-8E
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes

Wireless LAN adapter Local Area Connection* 1:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Microsoft Hosted Network Virtual Adapter
Physical Address. . . . . . . . . : C4-04-15-6E-21-7E
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes

Wireless LAN adapter Wireless Network Connection 4:

Connection-specific DNS Suffix . : mahaska.org
Description . . . . . . . . . . . : NETGEAR WNA3100 N300 Wireless USB Adapter
Physical Address. . . . . . . . . : C4-04-15-6E-21-7E
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::f053:8128:839e:a0a9%5(Preferred)
IPv4 Address. . . . . . . . . . . : 192.168.1.44(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Friday, September 25, 2020 12:28:05 PM
Lease Expires . . . . . . . . . . : Tuesday, September 29, 2020 7:43:49 AM
Default Gateway . . . . . . . . . : 192.168.1.1
DHCP Server . . . . . . . . . . . : 192.168.1.1
DHCPv6 IAID . . . . . . . . . . . : 398722069
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1B-24-FE-EC-00-23-24-04-E5-8E
DNS Servers . . . . . . . . . . . : 192.168.1.1
NetBIOS over Tcpip. . . . . . . . : Enabled

1 Like

I used your updated code and it connects just fine. I will run it against the previous code to figure out where the differences are but off hand this recent version is using

 #include <ESP8266mDNS.h>              //for OTA
#include <WiFiUdp.h>                  //for OTA

and the previous code is not. I really wonder if this is derived from issues with the esp8266 library files. I had installed them with the instructions on the esp8266 forum but there was alot of back and fourth with these libraries(installing and removing) when I initially was troubleshooting this. I also originally had this hooked up via USB and had gone through the steps noted to pursue that method. Thinking back s there something that I would have needed to stop or reverse in doing so?

At any rate this is working now so I suppose I can move forward in getting this up and running for my particular mission. If there is more that you all would like me to check I am all ears

-Thanks or all the help

-Nick

one other side note…I was following the original @Everlanders post regarding troubles with the accumulators losing inventory as I figured it would be the best place to start, until you posted the code you did Dave. It is almost exactly what I am needing aside from converting to gallons and Units opposed to Liters and Milliliters.

My charts will just need to reset daily to provide a 24hr accum that can be trended with a bar chart over time. I’m still trying to make sense of all of the VPINS and exactly what you are doing with them but saving the accum for use at startup is an important part of what I was wanting to accomplish.