Hello, I would like to ask you all for help to solve a problem on a relay that I am using with the nodemcu ESP8266 microcontroller. I have tried to create a program to turn the relay on and off, and when I give it 5v power on the VIN pin in nodemcu or 5v from external, the program does not work, the relay just turns on but does not execute the program code. After I try to give it 3v power from nodemcu or external, the relay works according to the program code. Please help me for those who know the solution
Always show us a good schematic of your proposed circuit.
Show us good images of your ‘actual’ wiring.
Give links to components.
Your program is OK.
Your 5V supply may be too weak.
Or you may have a pin connected straight to the relay...
So please tell us more about your setup (include drawings and picture).
I have posted the wiring

Your code uses pin5 for the relay.
On your breadboard you have the relay connected to pin D1.
Move the relay wire to the pin arrowed.
No, the number in my code is GPIO
@rahimpuji
The ground (GND) of the external power supply need to be connected to the nodemcu ground (G) or it won't work
Hi, @rahimpuji
Welcome to the forum.
The number in your code is the D number on the controller PCB.
5 == D5.
TRY IT?
Use the 5V and gnd pins from the controller PCB to power the relay board.
Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.
Do you have a DMM? Digital MultiMeter?
Thanks.. Tom...
![]()
Let’s see a link to your relay module.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.


