Proper use of open collector to switch an output
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:



This is wrong circuit diagram, as flyback diode is wrongly connected. Here's the right circuit from 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).