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.
    – aaa
    Apr 16, 2018 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 Sep 27, 2018 at 7:17

3 Answers 3


There is confusion about what is and what isn't possible with this board. This is because there are different versions with different power arrangements.

NodeMCU 0.9

In this board the USB's 5V and the 5V pin are directly connected together. The combined result is then fed through a diode before entering the 3.3V voltage regulator.

With this arrangement the 5V pin will provide the exact same voltage that the USB port feeds the board. However it is dangerous to connect that pin to any power source - it may kill (or at the very least disable) the USB port in your computer - when the board is also connected to a computer through the USB port.

NodeMCU 1.0 and 1.1

On this version the USB's power is first fed through the diode and then to the 5V pin and the 3.3V regulator together. This means that the 5V pin will show about 0.5V below whatever voltage is fed in through USB. This isolates the USB from the 5V pin so it becomes safe to provide power through the 5V pin whilst at the same time having the board plugged in to the computer - at the cost of having a slightly lower output from the 5V pin.

Original answer:

The VIN pin not directly connected to the USB's 5V supply (at least on the LoLin v3 board). this means the pin cannot be used as a 5V supply output.

  • 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.
  • 4
    It is not directly connected. There’s a schottky diode between the USB 5V pin and the 5V pin.
    – user2497
    Jun 8, 2019 at 21:41
  • This answer is not completely accurate. At best, it's no longer accurate. I can confirm that the 5V on my V3 board is NOT connected to the supply. When I meter it, I get 1.3V.
    – KDM
    Dec 29, 2019 at 15:45
  • The edit made this answer gibberish. That is, either the first paragraph is correct, or the rest is, but they are directly contradicting one another, so they can't both be true.
    – Jasper
    Oct 26, 2020 at 16:13

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, 2018 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, 2018 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, 2018 at 2:31

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 (except on NodeMCU v3 by LoLin).

On the V0.1 LoLin board, there are 2 diodes between the VIN and VU pins. So you cannot get power from one to the other. These diodes isolate the two possible sources of 5V power from each other while allowing the board to obtain the 5V needed by its its 3.3V power supply from either 5V source.

Other board versions might be different.

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.

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