BlynkTimer Doesn't Work

Holla, i need your guidance for my last project in university. BlynkTimer on my code doesn’t work when i put pinMode for ultrasonic sensor in void setup. But before that, BlynkTimer can work properly. It would be a happiness for me if you can guide me, thank you!

That’s my code :

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

char auth[] = "*******";
char ssid[] = "*******";
char pass[] = "*******";

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

#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

BlynkTimer timer;

const int WP_PIN = 6;

#include <Servo.h>
Servo servo;

#include <virtuabotixRTC.h>

//CLK, DAT, RST
virtuabotixRTC myRTC(8, 9, 10);

///Sensor Ultrasonic 1
#define echopin1 4
#define trigpin1 5


//Sensor Ultrasonic 2
#define echopin2 11
#define trigpin2 12

void setup()
{
  // Debug console
  Serial.begin(9600);
  
  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);
  Blynk.begin(auth, wifi, ssid, pass);
  
  //Sensor Ultrasonic 1
  pinMode (trigpin1, OUTPUT);
  pinMode (echopin1, INPUT);
  Serial.println("Sensor Ultrasonic 1 Terpasang");

  //Sensor Ultrasonic 2
  pinMode (trigpin2, OUTPUT);
  pinMode (echopin2, INPUT);
  Serial.println("Sensor Ultrasonic 2 Terpasang");  
  
  pinMode(WP_PIN, OUTPUT);
  Serial.println("Pompa Air Terpasang");

  servo.attach(7);
  Serial.println("Motor Servo Terpasang");
  //  myRTC.setDS1302Time(00,27,16,1,26,7,2021);
  

  timer.setInterval(10L, SensorUltrasonic);
  timer.setInterval(10000L, JadwalMakanMinum);
}

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


BLYNK_WRITE (V2) {
  if (param.asInt() == 1) {
    servo.write(180);
    Serial.println("Motor Servo Bergerak ke 180°");
  }
  else if (param.asInt() == 0) {
    servo.write(0);
    Serial.println("Motor Servo Bergerak ke 0°");
  }
}


BLYNK_WRITE (V3) {
  if (param.asInt() == 1) {
    digitalWrite(WP_PIN, HIGH);
    Serial.println("Pompa Air ON");
  }
  else if (param.asInt() == 0) {
    digitalWrite(WP_PIN, LOW);
    Serial.println("Pompa Air OFF");
  }
}


void JadwalMakanMinum()
{
  myRTC.updateTime();
  Serial.println("Waktu RTC Telah Diupdate");

  Serial.print("Waktu Sekarang :");
  Serial.print(myRTC.hours);
  Serial.print(":");
  Serial.print(myRTC.minutes);
  Serial.print(":");
  Serial.println(myRTC.seconds);

  if (myRTC.hours == 12 && myRTC.minutes >= 00) {
    servo.write(180);
    Serial.println("Motor Servo Aktif");

    digitalWrite(WP_PIN, HIGH);
    Serial.println("Pompa Air ON");
  }
  else if (myRTC.hours == 12 && myRTC.minutes <= 01) {
    servo.write(0);
    digitalWrite(WP_PIN, LOW);
    Serial.println("Pemberian Makanan & Minuman Berhasil");
  }
  else {
    Serial.println("Belum Jadwalnya Makan & Minum");
  }
}

void SensorUltrasonic() {
  digitalWrite(trigpin1, LOW);
  delayMicroseconds(4);
  digitalWrite(trigpin1, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigpin1, LOW);
  long t1 = pulseIn(echopin1, HIGH);
  long cm1 = t1 / 29 / 2;

  Serial.print("Jarak Sensor 1 : ");
  Serial.print(cm1);
  Serial.println(" cm");

  digitalWrite(trigpin2, LOW);
  delayMicroseconds(4);
  digitalWrite(trigpin2, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigpin2, LOW);
  long t2 = pulseIn(echopin2, HIGH);
  long cm2 = t2 / 29 / 2;

  Serial.print("Jarak Sensor 2 : ");
  Serial.print(cm2);
  Serial.println(" cm");
}

This is preview of my serial monitor

You’re trying to read both sensors 100 times per second.
Is that really feasible with whatever hardware you are using?

I’d start by extending that to one reading every second, and maybe comment-out the code which reads the second sensor.
You could also add serial print statements at the beginning and end of the SensorUltrasonic() function to see how long it takes to execute.

I’d also remove this:

as it doesn’t do anything.

You’ve also omitted to provide any information about the Blynk library version that you’re using, so there could also be an issue there.

Pete.

Thanks Mr. Pete for your guidance. When i created code to run just 2 ultrasonic sensor, the 100 times per second interval works. But i will try to change the interval and remove the BLYNK_CONNECTED code.

Oh sorry, i forgot to give the information about that. My Blynk library version is 0.61 on Arduino UNO, Mr. Pete.