I've read that Vin pin is directly connected to usb cable in esp8266 (which is 5V). I wonder if I can power a relay 5V and a servo motor Sg90 with this pin? And is there any danger of doing that ?

  • esp8266 is a 3.3 V chip without USB. what dev board do you have? – Juraj Mar 16 at 16:43
  • I have esp8266 node mcu with usb adapter – Radja Mar 16 at 17:01
  • most devkits have a diode connecting USB to Vin. you can burn this diode if you draw too much current. The current handling depends on how cheap they were at the factory, but anything above 1A will fry a cheapo board. Of course, you can solder bridge out the burnt diode, as long as you take care sending when plugging the USB into an actual PC. – dandavis Mar 18 at 18:07

The GPIO pins on the ESP8266 (including the ones with built-in NodeMCU) are 3.3v tolerant.

First, if there is ever any feedback from the 5v+ from the relay coming back down the signal wire, it'll likely cook the ESP.

Also, if it's a 5v relay, 3.3v from the ESP most likely wouldn't be enough to trigger the unit anyhow.

You'll either need to power the relay from an external power supply (or the Vin pin depending on the mA the relay requires), and then use a voltage converter (eg. logic level converter) so you can have 5v on the relay side (I'm speaking of the signal pin here), and 3.3v on the ESP side, or purchase a relay that will operate on 3.3v.


Relays, motors, and other inductive loads release a surge of reverse current when you remove power from them. You have to connect a suitably sized “flyback diode” across the coil, wired backwards from the normal current flow direction to protect the other devices on the circuit from that reverse current or they will likely be damaged.

Relays and motors also draw a large in-rush of current when they are first connected, which can cause the supply voltage to droop.

You can buy relays that are made to be controlled by logic levels. They take a low power 5V or 3.3V logic level input, plus a separate power supply, and use the logic input to switch the relay on and off safely. The relay modules I’m using have optical isolation for the logic lines for extra protection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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