Is using a nodemcu esp8266, correct ?. usually the relay modules are actuated by transistors in conjunction with optoisolators, you can power the module with 5v but you must power the control pins of the module with 5v if the module is designed as such. As far as I know the esp8266 has a logic level of 3.3v this could weakly trigger the optoisolator and consequently the relay
Yes, that is a good point there. I
may have overlooked the fact that it was actually an ESP8266 in use.
In the event, it does not matter though. The relay board contains a green LED whose threshold voltage is probably about 2.1 V, in series with the IR emitter (1.3 V) in the optocoupler, so the combined threshold voltage is indeed, around 3.3 V and the relay board may well not work if fed 3.3 V.
There is a trick however; since the input common to the relay board is the
positive supply, if it is actually connected to the
5 V before the on-board 3.3 V regulator, then a 3.3 V HIGH will put 1.7 V across the LEDs which being well below the combined threshold, will definitely
not actuate the optocoupler, but a LOW will apply the full 5 V.
The only concern that may be raised about this arrangement is that if the 5 V was being supplied but not the 3.3 V, the ESP8266 could be "phantom powered" through the LEDs (and cause spurious activation of the relay), but since the 3.3 V is supplied
from the 5 V by the regulator, it is most unlikely to fail on its own.