Blynk stops working after a couple of minutes

Hello, I am fairly new to blynk and I am using it to control multiple sensors and a servo via Arduino Mega. When I first start the project up, it works beautifully. The ir temperature and distance updates quickly and the servo responds (though that is a bit glitchy). But after a couple of minutes, everything stops responding. The sensor read-outs stop updating and the servo will no longer respond. Am I flooding the system? The code is attached below:

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial1

#include <BlynkSimpleStream.h>
#include <Servo.h>
#include "IRTemp.h"

char auth[] = "af30119367fd4b9ea111f78318fd9b14";

//UR Pines
#define trigPin 10
#define echoPin 13

//IR Pins
static const byte PIN_DATA    = 2; // Choose any pins you like for these
static const byte PIN_CLOCK   = 3;
static const byte PIN_ACQUIRE = 4;

//Alarm Pins
#define Light_PIN 5
#define Buzz_PIN 6

Servo servo;
BlynkTimer timer;
int heat = 80;
static const TempUnit SCALE=FAHRENHEIT;  // Options are CELSIUS, FAHRENHEIT
long duration, distance; // Duration used to calculate distance
float irTemperature, ambientTemperature;
int t1;

  servo.write(param.asInt());  // Servo

// Enable/disable blinking using virtual pin 4
  if (param.asInt()) {
  } else {
    digitalWrite(Light_PIN, LOW);
    digitalWrite(Buzz_PIN, LOW);

// Change blink interval using virtual pin 5
  long interval = param.asLong();
  boolean wasEnabled = timer.isEnabled(t1);
  t1 = timer.setInterval(interval, alarmBlynk);
  if (!wasEnabled) {

  Blynk.virtualWrite(8,distance);// virtualpin 8 distance

  Blynk.virtualWrite(1,irTemperature);// virtualpin 1 ir temperature

  Blynk.virtualWrite(2,ambientTemperature);// virtualpin 2 ambient temperature

void setup(){
  // Debug console

  // Blynk will work through Serial
  // Do not read or write this serial manually in your sketch
  Blynk.begin(Serial, auth);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  timer.setInterval(1000, measureDistance);
  timer.setInterval(1000, IRread);

  // Configure LED and timer
  pinMode(Light_PIN, OUTPUT);
  pinMode(Buzz_PIN, OUTPUT);
  t1 = timer.setInterval(500L, alarmBlynk);

void loop()
{;; // Initiates SimpleTimer

//UR Sensor
void measureDistance()
  /* The following trigPin/echoPin cycle is used to determine the
 distance of the nearest object by bouncing soundwaves off of it. */ 
 digitalWrite(trigPin, LOW); 

 digitalWrite(trigPin, HIGH);
 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 //Calculate the distance (in cm) based on the speed of sound.
 distance = duration/58.2;


void IRread() {
      irTemperature = irTemp.getIRTemperature(SCALE);
      ambientTemperature = irTemp.getAmbientTemperature(SCALE);

void alarmBlynk(){
  digitalWrite(Light_PIN, !digitalRead(Light_PIN));
  digitalWrite(Buzz_PIN, !digitalRead(Buzz_PIN));

It’s possible you could be flooding Blynk. I’m seeing quite a few write commands in your code. I believe the limit is 10 per second.

it would be useful to see an serial monitor debug output.

what communication module do you use?

please, set baud rate to 115200 in serial and serial1
communication for arduino, 9600 is very slow and obsolete. 9600 is only needed on arduino software serial, which is not used in your case.

after couple of minutes only the communication between arduino and blynk server halts, or the whole hw is blocking?