-->
Page 1 of 1

NodeMCU 12E + SRD-05VDC-SL-C Relay

PostPosted: Tue Mar 29, 2016 7:52 am
by okite
Hi, I am using SRD-05VDC-SL-C relay, using pin 14 (tested pin 4, the same results).
I use:

pinMode(14, OUTPUT);
digitalWrite(14, 0);

Then digitalWrite(14, 1); has no effect, relay do not switch.

What I should do - obviously I have problem to switch the relay pin... but with LED it does function
This sample does not function: http://tech.yeesiang.com/control-real-d ... ing-relay/

Thanks for any advice, Ota

Re: NodeMCU 12E + SRD-05VDC-SL-C Relay

PostPosted: Tue Mar 29, 2016 1:35 pm
by piersfinlayson
Are you driving directly or via a transistor with a separate 5v supply? That relay requires 5V to drive it - the ESP8266 will only output 3.3v which won't switch the relay.

I've successfully driven one of these relays through a transistor from the ESP8266.

Re: NodeMCU 12E + SRD-05VDC-SL-C Relay

PostPosted: Tue Mar 29, 2016 2:20 pm
by jra
If you're driving a bare relay you definitely need a transistor (and a clamping diode) because the esp8266 does not provide enough current. If you are driving an optoisolated relay along the lines of http://www.sainsmart.com/sainsmart-rela ... ry-pi.html you may need to either use a level shifter or perform some minor surgery on your relay, see viewtopic.php?f=13&t=8808 for details.

Re: NodeMCU 12E + SRD-05VDC-SL-C Relay

PostPosted: Tue Mar 29, 2016 2:25 pm
by martinayotte
That is true !
Some of those boards have LED and OptoCoupler in series, so 3.3V is not enough to drive those.
Provide 5V to the board and drive the input with a MOSFET will resolve any issue.