13

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
19

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.
  • 2
    It is not directly connected. There’s a schottky diode between the USB 5V pin and the 5V pin. – user2497 Jun 8 '19 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 '19 at 15:45
1

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).

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.

0

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.

Cheeers!

  • 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

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