How to drive a relay with an esp8266 - http://arduinotronics.blogspot.com/2018/08/driving-relays-with-esp8266.html

esp8266
gplus
(Steve Spence) #1

How to drive a relay with an esp8266 - http://arduinotronics.blogspot.com/2018/08/driving-relays-with-esp8266.html

(Justin Mitchell) #2

or simpler version, just throw a 2N7000 n-channel logic mosfet in there instead of the opto-isolator+bipolar transistor. a little less isolation, a lot less components, and the relay doesnt need to be a 5v one

(Steve Spence) #3

@Justin_Mitchell Great idea, thanks! just ordered 50 … https://amzn.to/2PTR3HO

(Steve Spence) #4

Like this?

missing/deleted image from Google+

(Justin Mitchell) #5

I’ve seen plenty of arguments that the gate resistor isn’t necessary, but I often use them anyway. I also use a 1k or more pull-down resistor on the gate to ensure its off unless actively driven

(Steve Spence) #6

@Justin_Mitchell a gate to ground resistor would be good if the input was disconnected. I have a gate to esp8266 resistor to protect the gpio pin in case of mosfet failure.

(Justin Mitchell) #7

On power up if the pin goes tri-state/input then the floating level might be high enough to trigger the MOSFET and engage the relay, for that fraction of a second until your code reconfigures it. as I discovered on one of my projects :slight_smile:

(Steve Spence) #8

@Justin_Mitchell I’ll add a 10k from gate to ground.