Blynk disconnects as soon as it connects , and analogread function doesnot work when connection last for 30sec or so

Hi,

Attached is my code,
I use Nano +8266shield.

Attached is my code.

#define ESP8266_BAUD 115200
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX
char auth[] = "8EOfvwCaj2223CDUJzzkWdSccbrIzF6i";
char ssid[] = "S R S 2.4G";
char pass[] = "jeyarani2083";
const int v1 = A7, v2 = A6, v3 = A5, c1 = A4, c2 = A3, c3 = A2;
int volt1, volt2, volt3, curr1, curr2, curr3, minn = 1023, maxx = 0;

ESP8266 wifi(&EspSerial);

BLYNK_READ(V5)
{
  curr3 = analogRead(c3);
  curr3 = curr3 / 1000;
  Blynk.virtualWrite(V5, curr3);
}

BLYNK_READ(V4)
{
  curr2 = analogRead(c2);
  curr2 = curr2 / 1000;
  Blynk.virtualWrite(V4, curr2);
}

BLYNK_READ(V3)
{
   for ( int i = 0; i < 10; i++ ) {
 
   int sensorValue = analogRead(v3);
  if (sensorValue<minn){minn=sensorValue;}
  if(sensorValue>maxx){maxx=sensorValue;}
  
}
volt3=maxx-minn;
maxx=0;
minn=1023;
  Blynk.virtualWrite(V3, volt3);
}

BLYNK_READ(V2)
{
  for ( int i = 0; i < 10; i++ ) {
   int sensorValue = analogRead(v2);
  if (sensorValue<minn){minn=sensorValue;}
  if(sensorValue>maxx){maxx=sensorValue;}
  
}
volt2=maxx-minn;
maxx=0;
minn=1023;
  Blynk.virtualWrite(V2, volt2);
}

BLYNK_READ(V1)
{
  for ( int i = 0; i < 10; i++ ) {
   int sensorValue = analogRead(v1);
  if (sensorValue<minn){minn=sensorValue;}
  if(sensorValue>maxx){maxx=sensorValue;}
  
}
volt1=maxx-minn;
maxx=0;
minn=1023;
  Blynk.virtualWrite(V1, volt1);
}

BLYNK_READ(V0)
{
  for ( int i = 0; i < 100; i++ ) {
   int sensorValue = analogRead(v1);
  if (sensorValue<minn){minn=sensorValue;}
  if(sensorValue>maxx){maxx=sensorValue;}
  
}
volt1=maxx-minn;
maxx=0;
minn=1023;
  Blynk.virtualWrite(V0, volt1);
}



void setup() {
  Serial.begin(9600);
  EspSerial.begin(ESP8266_BAUD);
  delay(100);
  pinMode(v1, INPUT);
  pinMode(v2, INPUT);
  pinMode(v3, INPUT);
  pinMode(c1, INPUT);
  pinMode(c2, INPUT);
  pinMode(c3, INPUT);
  pinMode(13, OUTPUT);
  Blynk.begin(auth, wifi, ssid, pass);
 

}

void loop() {
  if (Blynk.connected()) { // Blynk.run() is only called if connected to the server
    Blynk.run();
    digitalWrite(13, HIGH);

  }
  else {
    digitalWrite(13, LOW);
    Blynk.connect();
  }


  //delay(1000);


}

I get this output through serial,

[99] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino Nano

[191] Con2:S R S 2.4G
[16781] WIGI GOT IP
AT version:1.5.0.0(Oct 24 2017 12:03:18)
SDK version(11
[24346] IP = +CIPSTA:ip:"192.168.0.114"
+CIPSTA:gateway:"192.168/0.1"
+CIPST.
[24364] WOK
[34708] Ready (ping: 23ms).
[36783] Invalid HW cmd: wr
[235343] Ready (ping: 14ms).
[245642] Invalid HW cmd: vy
[368002] Ready (ping: 14ms).
[470030] Ready (ping: 12ms).
[478589] Invalid HW cmd: wr
[621368] Ready (ping: 15ms).

Help is very much appreciated…

When you create a serial port that which is using serial emulation (with the SoftwareSerial library) you Nano’s processor, combined with the limitations of the SoftwareSerial library, can’t reliably sustain a baud rate higher than 9600

However, you can’t simply change this one line of code, as you first have to tell your ESP8266 shield to also communicate at 9600 bps.
You do this using AT commands, and how you do it will depend on the hardware you have available to you.

Pete.

Thanks @PeteKnight , Connection looks stable now, with the code modified , but

#define ESP8266_BAUD 9600
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX
char auth[] = "8EOfvwCaj2223CDUJzzkWdSccbrIzF6i";
char ssid[] = "S R S 2.4G";
char pass[] = "jeyarani2083";
const int v1 = A7, v2 = A6, v3 = A5, c1 = A4, c2 = A3, c3 = A2;
int volt1, volt2, volt3, minn = 1023, maxx = 0;
float curr1, curr2, curr3;

ESP8266 wifi(&EspSerial);

BLYNK_READ(V5)
{
  curr3 = analogRead(c3);
  curr3 = curr3 / 1000;
  Blynk.virtualWrite(V5, curr3);
  Serial.println(curr3);
}

BLYNK_READ(V4)
{
  curr2 = analogRead(c2);
  curr2 = curr2 / 1000;
  Blynk.virtualWrite(V4, curr2);
 // Serial.println(curr2);
}

BLYNK_READ(V3)
{
  curr1 = analogRead(c1);
  curr1 = curr1 / 1000;
  Blynk.virtualWrite(V3, curr1);
  //Serial.println(curr1);
}

BLYNK_READ(V2)
{
  for ( int i = 0; i < 10; i++ ) {
   int sensorValue = analogRead(v2);
  if (sensorValue<minn){minn=sensorValue;}
  if(sensorValue>maxx){maxx=sensorValue;}
  
}
volt2=maxx-minn;
maxx=0;
minn=1023;
  Blynk.virtualWrite(V2, volt2);
 // Serial.println(volt2);
}

BLYNK_READ(V1)
{
  for ( int i = 0; i < 10; i++ ) {
   int sensorValue = analogRead(v1);
  if (sensorValue<minn){minn=sensorValue;}
  if(sensorValue>maxx){maxx=sensorValue;}
  
}
volt1=maxx-minn;
maxx=0;
minn=1023;
  Blynk.virtualWrite(V1, volt1);
  //Serial.println(volt1);
}

BLYNK_READ(V0)
{
  for ( int i = 0; i < 100; i++ ) {
   int sensorValue = analogRead(v1);
  if (sensorValue<minn){minn=sensorValue;}
  if(sensorValue>maxx){maxx=sensorValue;}
  
}
volt1=maxx-minn;
maxx=0;
minn=1023;
 // Blynk.virtualWrite(V0, volt1);
}



void setup() {
  Serial.begin(9600);
  EspSerial.begin(ESP8266_BAUD);
  delay(100);
  pinMode(v1, INPUT);
  pinMode(v2, INPUT);
  pinMode(v3, INPUT);
  pinMode(c1, INPUT);
  pinMode(c2, INPUT);
  pinMode(c3, INPUT);
  pinMode(13, OUTPUT);
  Blynk.begin(auth, wifi, ssid, pass);
 

}

void loop() {
  if (Blynk.connected()) { // Blynk.run() is only called if connected to the server
    Blynk.run();
    digitalWrite(13, HIGH);

  }
  else {
    digitalWrite(13, LOW);
    Blynk.connect();
  }


  //delay(1000);


}

But When I look at my app, I get a const 0, in guage, and whereas if i see on the serial monitor I can get some float values, for the variable “curr3”., any specific care to be taken to write float values to a guage?

[99] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino Nano

[191] Con2:S R S 2.4G
[7009] WIFI GOT IP
AT version:1.5.0.0(Oct 24 2017 12:03:18)
SDK version:2.1.0(ace2d95)
compile time:Oct 24 2017 15:48:02
Bin version(Wroom 02):1.5.1
OK
[12868] IP = +CIPSTA:ip:"192.168.0.114"
+CIPSTA:gateway:"192.168.0.1"
+CIPSTA:netmask:"255.255.255.0"
[12911] WOK
[23801] Ready (ping: 23ms).
0.05
0.33
0.17
0.00
0.29
0.18
0.00
0.47
0.28
0.11
0.38
0.48
0.48
0.48
0.48
0.48
0.48
0.48

Any ideas?
Thanks…

How is your gauge configured?

Pete.