I'm working with a pre-existing piece of consumer hardware that has an open collector GPIO output, as shown below:

enter image description here

The Open Collector is able to source up to 100 mA.

I'd like to switch a relay (a SRD type Sanyo relay with +, Signal, and -; like this https://www.velleman.eu/products/view/?id=435570), with a simple circuit like this:

enter image description here

(apologies for image error, I'm using the 5VDC that the relay is rated for as the power)

And I'm rather surprised to see that it doesn't work! I thought adding a pull-up resistor would allow me to switch the RelayInput node to +5V or 0V by switching the GPIO on and off. I'm finding that the voltage at that node stays constant (~1.8 V) regardless of what I do with the GPIO. I'm much more used to working with Open Drain / MOSFETs and digital logic, so I think I'm missing a crucial insight here based on transistors and how the logic will be current-driven.

I've tried swapping the pull-up resistor to lower values (1k and 4.7k) and the behavior is exactly the same.

Can someone help me understand what the issue is here?

thank you!

  • \$\begingroup\$ Why do you have three lines to the relay? They normally have two leads used to power the coil. Not three. I'm confused. Is there a datasheet for it? \$\endgroup\$
    – jonk
    Commented Mar 4, 2020 at 19:52
  • \$\begingroup\$ Is the "relay" really a relay mounted on a small PC board with and opto-isolator or other drive crcuit (like the relay modules often used with Arduinos), rather than a bare relay? \$\endgroup\$ Commented Mar 4, 2020 at 19:55
  • \$\begingroup\$ It's a SRD-05VDC-SL-C 5V Relay, definitely one used with Arduino modules. It has its own drive circuitry -- is there a better way to connect it with the open collector GPIO? \$\endgroup\$ Commented Mar 4, 2020 at 19:59
  • \$\begingroup\$ @nathanlachenmyer Well, that explains a lot. That middle contact point is NOT how you activate the relay. It's one of the contact points for the switch. (Either you are confused or I am.) \$\endgroup\$
    – jonk
    Commented Mar 4, 2020 at 20:05
  • \$\begingroup\$ @nathanlachenmyer Just connect your "open collector" output to the ground pin of the relay. Leave the +12 connected to the relay power. Disconnect everything from that middle pin (for now.) As others will tell you, you may want to add a normally reverse-biased diode across the two coil contact pins. \$\endgroup\$
    – jonk
    Commented Mar 4, 2020 at 20:08

1 Answer 1


Sounds like you confused with the relay datasheet. It has coil, which drives the "central" contact of the switch, and the coil's current is about 90 mA in "on" condition (within spec for your transistor). Coil is 5V powered for SRD-05VDC-SL-C, thus one of coil's contacts must be connected to the open collector output, and another to +5V (not +12V).

Are you sure that GPIO pin it 12V tolerant? Pulling it up to +12V may fry the transistor. Anyway it is wrong to connect to +12V here anyway.

The coil itself will serve as "pull-up resistor". Three things to consider: flyback diode, probably small resistor in series with the relay if current needs to be limited, and heat sink for transistor (if it is external).

Look at this tutorial.

Then, you are free to connect anything rated by the datasheet to the other 3 contacts of the relay (the switch).

Update: thanks for the info on the board being used (VMA406). It is a shame that they do not publish circuit diagram for the module; I can see that it already contains flyback diode, and driving transistor with, most probably, series resistor at the input.

Researching for the circuit diagram I found the following here:

enter image description here

This is wrong circuit diagram, as flyback diode is wrongly connected. Here's the right circuit from here:

enter image description here

You problem with open collector can relate to the series resistor in the module: if you choose too big value for the pull-up resistor, it will form voltage divider with the series resistor, and transistor may not operate properly.

You actually do NOT need open collector output to drive the circuit of this VMA406 module, it does already contain open-collector circuit for you. You can connect GPIO directly to the input of the module.

You need the following wires to the module from your controller MCU board: ground, +5V, and logical input to operate the relay. You can see this information in the datasheet for the module in "Overview" section.

To rephrase it, using my open collector output, I want to be able to apply +5V to the signal pin on the relay unit.

The VMA406 and its internals are powered by +5V, not +12V. Pulling it up to, and powering it from +12V you may damage the relay board, or even module's output transistor (not much because of high voltage [transistor is rated for 40V], but because of current [rated to 200 mA]).

Datasheet states that control input is 5 to 12 VDC, and it is strange because even CMOS would have tough times having exactly 5V output at 5V supply, not even sayng about the Arduino logic.

If you do not have +5V supply from your MCU board, then it is bad luck and you will not be able to use the relay module properly.

Could it be that the internal transistor is fried? It seems that having a pull-up resistor of 1k or so on the GPIO pin should work from what you're saying.

You can check the output of transistor using multimeter in voltrop mode (diode sign), or simply measuring the output voltage with pull-up attached.

What I would do in this situation: take a NOT gate (e.g. CMOS 74HC04), power it from +5V, connect its input to the 2N3904 with 4.7k pull-up to 5V, and connect its output to the module's "signal" pin - and see if it will improve the situation. Of course relay behavior will be mirrored, but it will show if module is able to accept logical 1 from signal pin (output of HC04). I suspect it will be switching properly. If it will you can replace the gate with LVC1G04 in the final design.

Alternatively, you may remove Q1 from the relay board, and use that internal 2N3904 instead of it (using second circuit of the module as a reference, but ensuring that relay's current is within spec for the transistor and there's enough power dissipation to cool it in ON state).

  • \$\begingroup\$ I'm using a Velleman board for the SRD-05VDC relay that has onboard circuitry for switching: velleman.eu/products/view/?id=435570 It requires power, ground, and then the relay signal -- the problem is that I can't use my open collector GPIO to trigger the signal input of the relay board. \$\endgroup\$ Commented Mar 4, 2020 at 20:44
  • \$\begingroup\$ Thanks for the info, edited answer. \$\endgroup\$
    – Anonymous
    Commented Mar 4, 2020 at 21:19
  • \$\begingroup\$ Very much appreciate your answer here. Though my predicament is that my GPIO is an open collector output (it's a 2N3904 inside the unit); when I connect the GPIO pin to the SIGNAL pin on the VMA406 directly, it can't switch the unit. I assume that this is because there's no power available to drive current through R1 into Q1? To rephrase it, using my open collector output, I want to be able to apply +5V to the signal pin on the relay unit. \$\endgroup\$ Commented Mar 4, 2020 at 21:24
  • \$\begingroup\$ As I said you must connect GND, +5V and signal to the module's input (to the coil circuitry). Without +5V (power for the transistor on the board) it will not operate. You connect to +12V and it is wrong for this board, as it is rated for +5V. You even risk frying internal unit's transistor (2N3904) by pulling it up to +12V. \$\endgroup\$
    – Anonymous
    Commented Mar 4, 2020 at 21:27
  • \$\begingroup\$ I have access to +5V to power it; however, even with +5V power, the GPIO is unable to switch the signal pin. Could it be that the internal transistor is fried? It seems that having a pull-up resistor of 1k or so on the GPIO pin should work from what you're saying. \$\endgroup\$ Commented Mar 4, 2020 at 21:59

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.