I am trying to connect my 8 Channel Relay to my NodeMCU 12E and use it for automation with Alexa.

For digital output I am using the ports: D0,D1,D2,D4,D5,D6,D7,D8

And for power:

Relay(VCC) -> Board Vin

Relay(GND) -> Board GND

This is being powered by a micro USB cable coming from my computer.

After uploading, the code works properly. When i disconnect and reconnect the power cable the code just doesn't work-unless i take out the GND and Vin wires before connecting the power cable and then plug both back in.

After online research I was recommended not to use D3, D4, D8, so how can I get 8 ports to connect to my relay?

Relay: enter image description here

NodeMCU 12E:

enter image description here

  • \$\begingroup\$ You may well have joined the many who have built ESP8266 projects where their loads establish states of the bootstrap pins incompatible with the chip starting in the desired mode (ie, boot from external flash). This can be rather tricky to get right - research the required pin states at boot and look at what things like pulling resistors, LEDs and bipolar transistor bases may be doing to pins in their initial undriven state when they are sampled as boot mode inputs. \$\endgroup\$ Feb 23, 2019 at 20:41

1 Answer 1


The issue that you are experiencing, is because the state of tgh GPIOs 0, 2, and 15 are in a state that stops the NodeMCU from booting. These GPIOs are on the NodeMCU pins D3, D4, and D8.

Just leave these pins free, and connect the relays to other pins.

This table might be useful: https://iotbytes.wordpress.com/nodemcu-pinout/

  • \$\begingroup\$ Thanks the whole code works if I stop using D8 and use SD3 (GPIO10) instead \$\endgroup\$ Feb 24, 2019 at 8:02
  • \$\begingroup\$ be careful with gpio10 if you use spiffs \$\endgroup\$
    – dandavis
    Feb 25, 2019 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.