I'm having trouble with ESP8266, D1/D2 (GPIO05/04) pin

This D1/D2 (GPIO05/04) pins are always in ON position… or my board is corrupted…?
How to turn it OFF at starting so that I can turn it ON as needed…
D4, D5, D6, D7, D8 are working fine… D4 is… well, you know it already…

I’m new… please help… I want to control 6/7 things, 5 things are working find…

Here is the soul

#define BLYNK_TEMPLATE_ID "xxxxxxxxxxxxx"
#define BLYNK_DEVICE_NAME "xxxxxxxxxxxxxxx"
#define BLYNK_AUTH_TOKEN "xxxxxxxxxxxxxxxxxxxxx"

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "DIR-615-C80D";
char pass[] = "xxx@xxxxxx";

BLYNK_WRITE(V0)
{
  int value = param.asInt();
  Serial.println(value);
  if(value == 1)
  {
    digitalWrite(D4, LOW);
    Serial.println("LED ON");
  }
  if(value == 0)
  {
     digitalWrite(D4, HIGH);
     Serial.println("LED OFF");
  }
}

BLYNK_WRITE(V1)
{
  int value = param.asInt();
  Serial.println(value);
  if(value == 1)
  {
    digitalWrite(D5, LOW);
    Serial.println("LED ON");
  }
  if(value == 0)
  {
     digitalWrite(D5, HIGH);
     Serial.println("LED OFF");
  }
}

BLYNK_WRITE(V2)
{
  int value = param.asInt();
  Serial.println(value);
  if(value == 1)
  {
    digitalWrite(D6, LOW);
    Serial.println("LED ON");
  }
  if(value == 0)
  {
     digitalWrite(D6, HIGH);
     Serial.println("LED OFF");
  }
}

BLYNK_WRITE(V3)
{
  int value = param.asInt();
  Serial.println(value);
  if(value == 1)
  {
    digitalWrite(D7, LOW);
    Serial.println("LED ON");
  }
  if(value == 0)
  {
     digitalWrite(D7, HIGH);
     Serial.println("LED OFF");
  }
}

BLYNK_WRITE(V4)
{
  int value = param.asInt();
  Serial.println(value);
  if(value == 1)
  {
    digitalWrite(D8, HIGH);
    Serial.println("LED ON");
  }
  if(value == 0)
  {
     digitalWrite(D8, LOW);
     Serial.println("LED OFF");
  }
}
BLYNK_WRITE(V5)
{
  int value = param.asInt();
  Serial.println(value);
  if(value == 1)
  {
    digitalWrite(D2, LOW);
    Serial.println("LED ON");
  }
  if(value == 0)
  {
     digitalWrite(D2, HIGH);
     Serial.println("LED OFF");
  }
}
void setup()
{
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  pinMode(D4,OUTPUT);
  pinMode(D5,OUTPUT);
  pinMode(D6,OUTPUT);
  pinMode(D7,OUTPUT);
  pinMode(D8,OUTPUT);
  pinMode(D2,OUTPUT);
  digitalWrite(D4, HIGH); //D4
  digitalWrite(D5, HIGH); //D5
  digitalWrite(D6, HIGH); //D6
  digitalWrite(D7, HIGH); //D7
  digitalWrite(D8, LOW);  //D8
  digitalWrite(D2, HIGH);  //D2
}

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

Please edit your post and add triple backticks ( ``` ) before and after your whole sketch.

Replace it with this ```

The 3 dots.

@CyborgTJB please copy the triple backticks that @John93 has provided and paste them at the beginning and end of the code in your original post, so that the code displays correctly.
Don’t use different characters instead of triple backticks, they won’t work.

Pete.

OH… that happened…

I’m using this relay for D2…
I tried both

  digitalWrite(D2, LOW);  //D2
  digitalWrite(D2, HIGH);  //D2

I see neither " Optocoupler" or “Transistor BC547” at it…
May be it is the culprit… let me check…

How is your V5 datastream configured?

Pete.

I’m not sure what you are asking…
may be this…

Maybe your board is broken.

Actually, the code, the board was working properly…
This relay board is not working properly… I tried transistor relay with " digitalWrite(D2, LOW)" and it is working now…
Thanks for support…

Even the board you mentioned has a transistor. You can see that on the board next to the zener diode.

You should have placed an LED on the GPIO and tested it.

Anyways glad that you got it working.

Are you powering your relay from a separate 5v supply, and using a common GND connection between the relay supply and the one used for the MCU?
If not then you’ll probably have unreliable results in the future.

Pete.

“Are you powering your relay from a separate 5v supply?”
Yes…

“using a common GND connection between the relay supply and the one used for the relay?”
Yes

What’s wrong on that…?

If your relay is powered from a different power source, then you will need to tie the GND together. Else that will not work.

If you want to isolate your MCU and relay then you should use an relay with opto isolator.

Powering everything with same power source… 5v driver…
I setup extra Capacitors for loads…
I think I’m giving enough power…

There’s nothing wrong with that, it’s how you should be doing it - hence my comment that…

Pete.

Do you want me to try that relay from the power of MCU…?

That statement seems to contradict your answers here…

What exactly does that mean?

Pete.

Ummmnnnn… I connected 3 capacitors to 5v driver.
If turn on all, it was giving “ing” sound of like struggling… So I connect 2 more capacitors. It’s working find now…