Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By okite
#44245 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
User avatar
By piersfinlayson
#44263 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.
User avatar
By jra
#44266 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.