NODEMCU V3 WIFI MODULE ESP8266 CH340G keeps disconnecting

Hello,
I have purchased a nodeMCU that I would like to use for activating a 4-channel relays shield, I have not yet connected any relays to it because first I need a stable connection.
That is were lies the problem, every 5 seconds or so it’s connecting and then disconnecting.
I have used the Blynk example template and selected the board : "nodeMCU 0.9 (ESP 12 Module).

This is what comes out of the serial monitor:

ets Jan 8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x4010f000, len 3460, room 16
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4
tail 4
chksum 0xc9
csum 0xc9
v00047bc0
~ld

I think that when it connects, it reboots over and over again…
question is why…

My code is below (reduced version for testing only):

// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID           "xxxxxxx"
#define BLYNK_DEVICE_NAME           "Water"
#define BLYNK_AUTH_TOKEN            "xxxxxxx"

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


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

WidgetLED led1(V1);

char auth[] = BLYNK_AUTH_TOKEN;

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxxxx";
char pass[] = "xxxxxx";


void setup()
{
  // Debug console
  Serial.begin(115200);

  pinMode(D3, OUTPUT);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,68,119), 8080);
}

void blinkLedWidget()                             // V1 LED Widget water
{
 
  if (D3==LOW) {
    led1.on();
    Serial.println("LED on V1: on");
  } else {
    led1.off();
    Serial.println("LED on V1: off");
  }
    
}

void loop()
{
  blinkLedWidget();
  Serial.println("hello world");
  Blynk.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

Anny help is much appreciated!

@rtd69 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.

Thanks Pete, that works better!

You should read this
https://docs.blynk.io/en/legacy-platform/legacy-articles/keep-your-void-loop-clean

Also, I don’t recommend using the D3 pin (GPIO 0), try a different pin. GPIO4 and GPIO5 are the safest pins to use as GPIO.

If GPIO0 (Pin D3) is pulled LOW at startup then the NodeMCU will enter programming mode, rather than run mode.
Your serial output indicates that then device isn’t entering run mode.

I’d also recommend that you use virtual datastreams rather than digital ones, and you keep your void loop clean…

Pete.