Connection Problems with WMos D1

Hi everyone

I have some issues with the WMos D1.
First it connects to the WLan and to the Blynk server but after a view seconds it disconnects from the server
and starts the Connection process again.
I don´t know where is my mistake and I never had this issue maybe someone knows how to solve!


// Blink define with Blink libraries
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

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


// WLan name
char ssid[] = "***********"; 
// WLan passwort
char pass[] = "************"; 


//Measuring AC Current Using ACS712
const int sensorIn = A0;
int mVperAmp = 185; //185 for 5A, 100 for 20A und 66 for 30A Module

double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;


void setup()
{ 
 Serial.begin(9600);
 Blynk.begin(auth, ssid, pass);
}

void loop()
{
 // Start Blynik
 Blynk.run();

 //Voltage messer porzess
 Voltage = getVPP();
 VRMS = (Voltage/2.0) *0.707; 
 AmpsRMS = (VRMS * 1000)/mVperAmp;
 Serial.print(AmpsRMS);
 Serial.println(" Amps RMS");

 if (AmpsRMS <= 0.5)
 {
  Blynk.notify ("Prozess erledigt");
 }
 /*else
 {
  Blynk.notify ("Prozess am ausfuehren");
 }*/
}

float getVPP() // definition for getVPP
{
  float result;
  
  int readValue;             //value read from the sensor
  int maxValue = 0;          // store max value here
  int minValue = 1024;          // store min value here
  
   uint32_t start_time = millis();
   while((millis()-start_time) < 1000) //sample for 1 Sec
   {
       readValue = analogRead(sensorIn);
       // see if you have a new maxValue
       if (readValue > maxValue) 
       {
           /*record the maximum sensor value*/
           maxValue = readValue;
       }
       if (readValue < minValue) 
       {
           /*record the maximum sensor value*/
           minValue = readValue;
       }
   }
   
   // Subtract min from max
   result = ((maxValue - minValue) * 5.0)/1024.0;
      
   return result;
 }


Read this whole article very carefully

Especially Avoid the void part

It’s not the Wemos D1 that’s the problem, it’s your code.

You’re trying to take a voltage reading from the ACS712 module every time void loop runs, then send a Blynk notification.
Void loop should be running hundreds, if not thousands of times per second (although it won’t in this case as you have far too much code being evaluated/executed in each void loop cycle).

You need to use a timer to call the voltage reading function, at a sensible frequency (once per second, or once per minute maybe) and just have Blynk.run and timer.run in your void loop.

You can only send notifications once every 15 seconds, so if you need to use notifications you need to create some logic to manage that process. Personally, i doubt that notifications are the best thing to use - far better to update a value widget with the appropriate message text.

Pete.