How to make a 5-volt relay work with NodeMCU?

I have several of these modules. They have an optional opto-isolator built-in, but you have to remove the jumper to use it.

  • Connect your GPIO trigger as you have it
  • Run the relay's Vcc and Gnd pins to the MCU, not the power plug.
  • connect the power plug's +5v to the left-most pin, where the jumper once stood: JDVcc
  • connect the power plug ground to the MCU or the open common Gnd on the left-group of pins.

Now your relay coil(s) will be powered by the 5v plug, but the relay's logic and control are handled by the MCU.


The relay has no reference for what the voltage from the NodeMCU is. Since the power supplies of the two devices are isolated (from each other; the laptop may not be isolated itself, but the battery certainly should be) you can (and in fact must) connect the grounds of the relay board and the NodeMCU together. If neither power supply is isolated or if you are unsure if they are isolated then you should use an optoisolator in order to prevent potential power issues.