Working with IR on blynk 2.0

Dear Pete
I am trying to design a smart parking system using blynk 2.0
I am receiving the following error on blynk 2.0
receiving the error [415154] Connecting to blynk-cloud.com:80
I have attached the code below.

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

#define BLYNK_TEMPLATE_ID "TMPLX_HTkpF4"

#define BLYNK_DEVICE_NAME "smart parking"

#define BLYNK_AUTH_TOKEN "HP8iTUEonGQCSVTAUZyO5gCeB3mK6o2J"

char ssid[] = "vijay";

char pass[] = "vijay@1234";

int IR_sensor = D1;

int value = 0 ;

void setup()

{
  pinMode(IR_sensor,INPUT);

  Serial.begin(115200);

  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

  value = digitalRead(IR_sensor);

  if(value == HIGH){

   

    Blynk.virtualWrite(V2, value);

    Serial.println(1);

  }

  else{

   

    Blynk.virtualWrite(V2, value);

    Serial.println(0);

  }  

 

}

void loop()

{

  Blynk.run();  

} 

Thanks in advance

@vijaysiva Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

Pete.

You should read this…

However, when you’ve made that change you sketch won’t work as I suspect you are hoping it will.

void setup only executes once, so the IR sensor will be read just once - when the device boots. In addition, placing a Blynk.virtualWrite in void setup almost certainly won’t write the data to Blynk because although Blynk.begin() has executed Blynk.connected() is not yet true.

And, don’t be tempted to place the IR code that’s currently in void setup into the void loop, this breaks the #1 rule of Blynk.
Instead, you need to set-up a BlynkTimer to call a function on a regular basis and put your IR code in there.

I’m also a bit confused about why this is an IR sensor. If you’re attempting to figure out if a vehicle is parked in a space then why not use a simple LDR, Photodiode or luminance sensor?

Pete.