ESP8266 with ultrasonic sensor

Hello everyone, I need your help. I am trying to get value of distance from ultrasonic sensor. I already connect the trigger wire to D1 and echo wire to D2, I already connect VCC to VCC and GND to GND. But I don’t get value in the gauge meter. I already set the gauge to get value from V0. Are there any problems in my code?

#define BLYNK_DEVICE_NAME "Tes Ultrasonic"

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

#define  trig  1
#define  echo  2

long duration;
int distance;

// You should get Auth Token in the Blynk App.
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Galaxy A138950";   // your ssid 
char pass[] = "tunggusebentar"; // your pass

BlynkTimer timer;

void setup()
  // Debug console
  pinMode(trig, OUTPUT);  // Sets the trigPin as an Output
  pinMode(echo, INPUT);   // Sets the echoPin as an Inpu
  Blynk.begin(auth, ssid, pass);

  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);

void loop()
void sendSensor()
  digitalWrite(trig, LOW);   // Makes trigPin low
  delayMicroseconds(2);       // 2 micro second delay

  digitalWrite(trig, HIGH);  // tigPin high
  delayMicroseconds(10);      // trigPin high for 10 micro seconds
  digitalWrite(trig, LOW);   // trigPin low

  duration = pulseIn(echo, HIGH);   //Read echo pin, time in microseconds
  distance = duration * 0.034 / 2;   //Calculating actual/real distance

  Serial.print("Distance = ");        //Output distance on arduino serial monitor
  Blynk.virtualWrite(V0, distance);
  delay(1000);                        //Pause for 3 seconds and start measuring distance again

Delete 1,2 and type 5,4 accordingly. Enjoy

You are not allowed to use delays with Blynk what so ever. This will block the connection to server and eventually your device will be disconnected from the cloud and no data will be sent to cloud and you will not get any values on your phone.

The pins on the board marked D1 and D2 are not GPIO1 and GPIO2.

Here, you’re telling your sketch to use GPIO1and GPIO2…

You need to either change which pins you’ve connected your sensor to, or change your code to use the correct PIN numbers.