Today I "played" with a relay for the first time.
I only had an N-channel MOSFET available (an IRLZ44N) and wanted to control the relay from an ESP8266's GPIO pin - i.e. use a 3.3V signal to control the relay's input pin, which expects 0 or 5V.
I had a 10K resistor handy, so I used it to current-limit the fet's Gate. To my understanding, MOSFETs only care about voltage, not current - so a "big" current limiter at the gate shouldn't matter anyway.
When the IRLZ44N is off, the relay's input is connected to the 5V over R1 - and when it's on, the input goes to ground. At that operational mode a resistor is needed; without it, the 5V would end up going directly to ground.
The circuit works - I tested it and the relay responds as expected. But measuring voltages, I saw that the voltage after R1 is not 5V; it's less, since some current goes in the relay's input. In doing so, the voltage drops from 5V to 3.5V; there's approximately 5mA going in the relay's input, and 1.5V ends up being wasted on R1.
It seems that if I had used a larger R1, the circuit wouldn't work - the voltage would drop too far. And as-is, 3.5V may be a marginal situation for the relay. EDIT: Using the 3.3V signal from the ESP directly on the IN1 input doesn't trigger the relay - so it seems the 3.5V we reach with this circuit is indeed borderline
Another disappointing thing about this circuit: when the relay is off, we waste current through R1.
Can you guys recommend a better circuit to use with my IRLZ44N, to turn the ESP8266's 3.3V to 5V and optimally control my relay?
Thanks in advance.