I know that Vin can be used to power the board but have also been reading that it can be used as a 5V output. Is it possible to assign Vin as an output as I would any other GPIO?

If I want to power an LED from GPIO 12, I would assign GPIO:

const int LEDpin_0 = 12; // D6, LED power pin

...and in the setup:

pinMode(LEDpin_0, OUTPUT);

I can then turn on and off the LED based on whether or not GPIO 12 goes HIGH or LOW.

Can I do the same with Vin without resorting to relays or other hardware?

  • The board will still need power (probably over USB?). You cannot change the power pin in code or switch it on/off. But if the 5V usb is going straight to the vin pin, then you can use it to power external components. – Paul Apr 16 '18 at 5:54
  • Im wondering if i can have 3Amps power supply source for this. Im not sure what regulator does the board have. cause 3amps is quite high for dev boards – Rae Villena Sep 27 '18 at 7:17

The VIN pin is directly connected to the USB's 5V supply. Which means that when the board is powered by USB you can take 5V out of that pin.

  • You cannot control that voltage. It is always on, and always 5V (or whatever your USB port happens to provide - 4.75v - 5.25v).
  • You must never ever connect VIN to a power source and connect the USB socket. That can destroy the USB port in your computer. There is zero back-powering protection on that board.
  • Drawing more than 500mA from the VIN pin could cause the USB port of your computer to be shut down.
  • 2
    It is not directly connected. There’s a schottky diode between the USB 5V pin and the 5V pin. – user2497 Jun 8 at 21:41

No you cannot use a Vin or VU pin as a GPIO pin which can be controlled by a program. Vin can be used as an input for 5V battery or as a 5V output when NodeMCU is powered by USB.(Expect on NodeMCU v3 by Lolin).

To get 5V to power external 5V sensors you can use Vin pin(on Lolin NodeMCU v3 use VU to get 5V output instead of Vin).

To control 5V sensor with help of GPIOs on NodeMCU you will need a logic shifter connected between your sensor and GPIO pin thats boost the 3v3 to 5V.


my 2 cents:

A LoLin NodeMCU V3 when powered via USB in the Vin pin reads 2.2 V (don't know why) but... in the VV pin you can get the 5V coming from the USB; so if you need 5V use that pin.

The board if powered via Vin with 5V, the VV pin reads 2 V (don't know why either)

in any case you can always get 3V in the 3V pin.


  • IMPORTANT WARNING: According to other sites around NEVER feed a NodeMCU via Vin (5V) and also connect it to a USB. You can blown your USB port or board. – Carlos M Oct 10 '18 at 18:11
  • 3
    the question was if you can use 5 V pin as gpio. (I know, it is hard to understand how can someone ask it) – Juraj Oct 10 '18 at 18:20
  • Your comment is the only one I've found so far searching that states the LoLin NodeMCU has power on VV instead of Vin. I'm seeing that as well. Doesn't follow the NodeMCU spec. Although I agree with other comments that this doesn't necessarily relate to this question. – David Nov 29 '18 at 2:31

protected by Juraj Nov 26 '18 at 16:06

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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