-2
\$\begingroup\$

I was under impression that you can drive 5V relay with no problems, but now it seems you need additional components to do that, which makes it no longer simple. The setup I think now is the following:

schematic

simulate this circuit – Schematic created using CircuitLab

I know I'm probably missing some resistors? But I have no idea what values and why.

Relay: Relay

\$\endgroup\$
5
  • \$\begingroup\$ What on Earth are you trying to do??? \$\endgroup\$
    – EM Fields
    Commented May 31, 2016 at 11:12
  • \$\begingroup\$ Using NodeMCU to trigger a relay, which turns on and off a power cord. \$\endgroup\$
    – Yan
    Commented May 31, 2016 at 11:21
  • \$\begingroup\$ It looks to me like that relay module already has a transistor - many do so you can connect them straight to a microcontroller. But you can either check the docs or measure the input current to make sure it's not too high for that controller. \$\endgroup\$
    – PeterJ
    Commented May 31, 2016 at 11:38
  • \$\begingroup\$ Yes, but signal coming from NodeMCU is 3.3V, which is not enough to trigger this relay. \$\endgroup\$
    – Yan
    Commented May 31, 2016 at 11:39
  • \$\begingroup\$ I think this board is used to trigger the relay using signal IN thorough MOSFET or Transistor and Vcc is the supply voltage which need to given from the uC board power supply for operating the MOSFET or Transistor which is used for trigger the Relay to ON and OFF. \$\endgroup\$ Commented May 31, 2016 at 11:50

3 Answers 3

1
\$\begingroup\$

Just for starters, it looks like 5V goes directly to ground through the MOSFET

enter image description here

But, if I understand what you're trying to do, this should work:

That is, if the NodeMCU runs on 5 volts.

enter image description here

\$\endgroup\$
7
  • \$\begingroup\$ @Yan: Part 1. Sure. I don't know anything about the relay board's front end except that there's something in there driving the relay and that 5 volts on the Vin pin will turn the relay ON. So, I use R2 to pull Vin down to GND and be sure that when Q1 is OFF Vin isn't left floating. 1000 ohms is a nice low impedance and it only costs about 5mA extra from the 5V supply when the relay's ON, so I use that instead of 10k so I can sleep better. \$\endgroup\$
    – EM Fields
    Commented May 31, 2016 at 16:57
  • 1
    \$\begingroup\$ @Yan: Part 2. Aargh!!! I just realized I made a mistake with R1 in that since Q1 emitter is at +5 volts and the voltage out of D7 is 3.3 volts, at its highest, Q1 will never turn OFF. I'll fix it and be back in a while. \$\endgroup\$
    – EM Fields
    Commented May 31, 2016 at 17:49
  • \$\begingroup\$ @Yan: It's fixed, but now it's a different ball game. :) I'll post a circuit description tomorrow, if I can, just to tie up the loose ends, and thanks for asking the question which caused me to see my error. \$\endgroup\$
    – EM Fields
    Commented May 31, 2016 at 18:24
  • \$\begingroup\$ @Yan: Since the schematic has changed, your earlier comments may no longer be relevant, and I think they're not archived, so you may want to delete them and start over. \$\endgroup\$
    – EM Fields
    Commented May 31, 2016 at 19:00
  • \$\begingroup\$ Sure, thanks for corrections! Different or not, the most important thing is for it to be safe and efficient. I'll test it as soon as I get my hands on 2n2222. \$\endgroup\$
    – Yan
    Commented May 31, 2016 at 19:02
1
\$\begingroup\$

To drive the relay you simply connect your 3.3V signal to 'In' (with common ground) Base current will be about 2.3mA with 3V drive, so it should drive the ~95mA coil + LED okay.

Not as much margin as I'd like, but it's a cheap hobby Chinese thing, and it should work okay in a benign environment.

The IRZ44 is not necessary and it won't work anyway- you need to source current into Vin to make it work. If you did need to add a transistor you would use something like this (where low = on and high= off because the transistor inverts the signal):

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
9
  • \$\begingroup\$ It does not trigger by simply connecting one of the boards output to "in" on a relay with common ground and a separate power source for relay/board. Also connecting a 10k resistor in between MCU 3.3v output and "no" on the relay, doesn't seem to do it. \$\endgroup\$
    – Yan
    Commented May 31, 2016 at 12:33
  • \$\begingroup\$ The relay module needs 5V power on Vcc and 3.3V or 5V on Vin relative to GND. To test it just connect 5V power only (nothing else connected to the module) and touch Vin to +5. It should click. Don't leave the VIN connected to your 'node' when you do this, or you'll destroy it. \$\endgroup\$ Commented May 31, 2016 at 12:41
  • \$\begingroup\$ Yes it does click once, but you can't switch it using micro-controller. It will always be in one position. 5V on Vin does operate the switch, 3.3V on Vin, only let's it click once. \$\endgroup\$
    – Yan
    Commented May 31, 2016 at 12:45
  • \$\begingroup\$ Then your microcontroller is not outputting 3.3V... I'm not that familiar with the chip- if it is open drain you may need a pullup resistor or to select another mode- or use the circuit I suggested. \$\endgroup\$ Commented May 31, 2016 at 12:48
  • 1
    \$\begingroup\$ Much smaller, much cheaper, and guaranteed to work, unlike a TO-220 N-channel MOSFET that might take 4V to start to turn on. But if you're happy with it, I won't argue. \$\endgroup\$ Commented May 31, 2016 at 15:33
1
\$\begingroup\$

Got similar problem with NodeMCU and relays and after spending some time figured out another way of doing it.

Simply connect 5V to your Vcc and the ground to GRD. Just connect 22k resistor to your GPIO to Vin wire and it should work fine.

\$\endgroup\$
4
  • \$\begingroup\$ How did you get to this 22k value? \$\endgroup\$ Commented Jul 26, 2017 at 14:49
  • \$\begingroup\$ First, the problem was that the relay was turning on when the GPIO was on and even was off. So I started to put some resistors and found that 22k works. \$\endgroup\$ Commented Jul 26, 2017 at 20:13
  • \$\begingroup\$ For me a 10k worked fine. Where with the 22k it wouldn't work \$\endgroup\$
    – jLynx
    Commented Sep 19, 2017 at 6:21
  • \$\begingroup\$ I think it depends on the relay. It just needs some resistance to drop the voltage. \$\endgroup\$ Commented Sep 19, 2017 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.