Arduino UNO+ESP 8266 + SoftSerial - lost connection (Login Timeout)

Hello All
Please help me with my project. I use Arduino UNO + ESP8266 as SoftSerial. I made check status for WiFi connection, reconnect to WiFi and server if nessesary, check status for connection to local server. Now I have a problemm - if I change slider status at app several time - have message “Login Timeout” and programm reconnect to server. Some times a have message “Invalid HW cmd: v»Ђ3”
I try to use delay() between sending info but can not understand - is it problem with arduino\esp, or WiFi or local server?

Thank You

My code:

#define BLYNK_PRINT Serial

#include <WiFi.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

 char auth[] = "xxxxxxxxxxxxxxxxx";  // local server

char ssid[] = "xxxxx";
char pass[] = "xxxxxxxxxxx";
char local_server[] = "xxx.xxx.xxx.xxx";
unsigned int port      = 8442;
boolean status_WiFi;
void(* resetFunc) (void) = 0; //declare reset function @ address 0


// LEDS Start

WidgetLED led_status(V9); //register to virtual pin 9


//LEDS End
// Water start

#include <OneWire.h>
OneWire ds(4); // OneWire for water temperature
int water_temperature = 0; // water temp from DS18B20
int water_temperature_target = 80;
int water_temperature_delta = 3;

long lastUpdateTimeWaterTemp = 0; // last time water temp update
const int TEMP_WATER_UPDATE_TIME = 2000; // delta water temp update

// Water End
 
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX

#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);

int redpin = 11; // select the pin for the red LED
int greenpin =10; // select the pin for the green LED
int bluepin =9; // select the pin for the  blue LED


void setup() {

  pinMode(LED_BUILTIN, OUTPUT);    //led
  
  pinMode(redpin, OUTPUT);
  pinMode(bluepin, OUTPUT);
  pinMode(greenpin, OUTPUT);
  
  Serial.begin(9600);
  delay(10);

  RGB_status_led (HIGH,LOW,LOW);
    
  EspSerial.begin(ESP8266_BAUD);
  delay(50);  
  
  Blynk.config(wifi, auth, local_server, port);
  CheckBlynkStatus ();

  delay(50);
  Blynk.virtualWrite(V2, water_temperature_delta);
  delay(50);
}

void loop() {

detectWaterTemperature(); // Check water temp from DS18b20

Blynk.run();  
CheckBlynkStatus ();
}

void CheckBlynkStatus ()
{
  
  bool isconnected = Blynk.connected();
  if(!isconnected)
  {
   // Blynk.config(wifi, auth, local_server, port);
    Serial.println("Blynk not connected :(");

    status_WiFi=Blynk.connectWiFi(ssid, pass);
    delay(10);

    if (status_WiFi) {
      Serial.println("WiFi Connected!"); 
      RGB_status_led (LOW,LOW,HIGH); 
  
      bool result = Blynk.connect();
      delay(10);
      if (result)
      {
         Serial.println("Blynk connected!");
         RGB_status_led (LOW,HIGH,LOW);
      }
    } else {
      Serial.println("WiFi Disconnected ("); 
      RGB_status_led (HIGH,LOW,LOW);
    }
  
  } else {
    RGB_status_led (LOW,HIGH,LOW); 
  }
}

int detectWaterTemperature(){
 
  byte data[2];
  ds.reset();
  ds.write(0xCC);
  ds.write(0x44);
 
  if (millis() - lastUpdateTimeWaterTemp > TEMP_WATER_UPDATE_TIME)
  {
    lastUpdateTimeWaterTemp = millis();
    ds.reset();
    ds.write(0xCC);
    ds.write(0xBE);
    data[0] = ds.read();
    data[1] = ds.read();
 
    // Calculate water temperature
    water_temperature = (data[1] << 8) + data[0]; water_temperature = water_temperature >> 4;

    Serial.println(water_temperature); // Water temperature

    if (water_temperature<(water_temperature_target-water_temperature_delta)) 
    {
      Blynk.setProperty(5, "color", "#04C0F8");   // Blue
      Blynk.setProperty(V9, "color", "#04C0F8");

      Blynk.setProperty(V9, "label", "Cold");      
    } else 
    {
      if (water_temperature>(water_temperature_target+water_temperature_delta))
      {
        Blynk.setProperty(5, "color", "#D3435C");  // RED
        Blynk.setProperty(V9, "color", "#D3435C");
        Blynk.setProperty(V9, "label", "HOT");
        
      } else
      {
        Blynk.setProperty(5, "color", "#23C48E"); //GREEN
        Blynk.setProperty(V9, "color", "#23C48E");
        Blynk.setProperty(V9, "label", "OK");
      }
    }
     delay(50);
     led_status.on();
     delay(50);
     Blynk.virtualWrite(5, water_temperature);
     delay(50);
  }
}

BLYNK_CONNECTED() {
    Blynk.syncAll();
}

void RGB_status_led (int r, int g, int b)
{
  analogWrite(redpin, r);
  analogWrite(greenpin, g);
  analogWrite(bluepin, b);
}

// Water temperature slider
BLYNK_WRITE(V3)   
{   
  int value = param.asInt(); // Get value as integer
  int temp=value; // water_temperature_target+value;
  if ((temp>10) && (temp<93))
  {
    water_temperature_target=temp;
    Blynk.virtualWrite(V1, water_temperature_target);
  }
}

Welcome to the forum.

Unfortunately there are few issues with your request…

This forum is here to assist with your own learning of how to use Blynk, it’s commands, and it’s features… not teach anyone how to program.

Nor is this forum’s purpose to troubleshoot, fix or make your code for you… but we help you learn about Blynk :wink:

And by help learn, we mean you first read through all the readily available documentation and examples (all those links are at the upper right of this page, scroll up if you don’t see them), and spend time learning how they work, before trying to merge a bunch of them together. You can certainly ask Blynk related questions as you go… and we assist with those questions as best able.

There are already many topics about the various functions you are looking to do… and admittedly many are NOT designed for Arduinos with ESP shield connection… but there have been some workarounds for that as well. If you have tried some of those methods and are having issues, then then you can post your code here (your code, not someone elses example that you don’t understand) and supply details on what is or isn’t working and what you have already tried to do to resolve it.

Then, if we can assist with any Blynk related issues we will try…

Hello
I corrected question. Now can I hope to community help?

Thank You

You might want to read up on BlynkTimer and how to utilise it instead of running some of your existing functions directly from the void loop() where they try to run hundreds of times a second.

http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/how-to-display-any-sensor-data-in-blynk-app