Blynk disconnects often

im new to blynk

while using servo ,my connection often gets lost and connects after a while and it repeats

#include <Servo.h> 

// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX

#include <BlynkSimpleStream.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "token";
BlynkTimer timer;
Servo myservo;
int mot_min = 90;   //min servo angle  (set yours)
int mot_max = 180; //Max servo angle   (set yours)
int pir;
int activated =0;

/* HC-SR501 Motion Detector */
int relayInput= 7; 
int LightsON = 8;
int pirValue; // Place to store read PIR Value
int pirSensor=2;

void setup()
{
  Serial.begin(9600);
  Blynk.begin(Serial, auth);
  myservo.attach(10); 
  pinMode(relayInput, OUTPUT);
    pinMode(LightsON, OUTPUT);
  pinMode(pirSensor, INPUT);
  digitalWrite(relayInput, LOW);
 // myservo.write(mot_min);  
  //timer.setInterval(500L,getPirValue);
  timer.setInterval(1000L,myTimerEvent1);
}
BLYNK_WRITE(V3) {

myservo.write(param.asInt());
if(param.asInt()==90)
{
  digitalWrite(8,LOW);
  activated = 0;
}
if(param.asInt()==180)
{
  digitalWrite(8,HIGH);
  activated = 2;
}

}


void myTimerEvent1()
{  
 if(activated !=2 && pir==1)
  {
    int sensorValue = digitalRead(pirSensor);
    if(sensorValue == 1)
     {
      digitalWrite(relayInput,HIGH);
     } 
  }
  if(activated ==2)
  {
   int sensorValue = digitalRead(pirSensor);
   if(sensorValue == 1)
    {
     digitalWrite(LightsON,HIGH);
     
    }
  }
}

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

How are you powering your servo? If from a pin on the device , then you are probably causing brownouts, and thus disconnection.

Google proper ways of hooking up servos.

i cant find anything new other than powering from the pin

can you suggest me some

Seriously?? :face_with_raised_eyebrow:

no improvement sir

And when left alone (no V3 write events) it disconnects too? How do you handle V3 events in app? (A slider? , a step widget?)

slider

Then be sure to have turned on send on release option in APP.
Two possible cases came into my mind:

  1. a server flooding (hence the qustion about value change handling),
  2. a timer related issues (as servo uses PWM).

But I have not met such problems, so my points are only theoretical.

it would be nice to post a serial debug…