Hey, this looks very similar to my question here, which was about driving a similar relay board with the same relay on it.
I used a 2N2222 transistor with a 2.2k resistor connected to its base pin. This is sufficient to drive either the relay on its own, or the input pin on this board, from 3.3V.
Put the other end of the resistor on a Spark Core digital pin, and connect the transistorâs emitter pin to ground.
Youâll have one pin left on the transistor, the collector. When Spark Core digital pin is on, this collector pin will pull to ground.
If you just care about the module, connect âINâ to the collector and youâre done. The module itself can then be connected to the Spark Coreâs Vin pin (which will be the required 5V if youâre using USB power), with the third connection to Gnd.
If you want to do away with the module altogether and use raw components, the connections are one side of the coil to Vin (5V) and the other side to the transistorâs collector pin. Youâll also need a flyback diode in this arrangement (I had a 1N4004 handy) which goes across the two coil pins, with its bar end on the one that goes to Vin.
With either arrangement, you donât need to change your code, the pin can be used as OUTPUT and when you write a 1, that means âon.â
Note, you do need the relay itself (or the module if youâre using that) connected to 5V as I described â the coils in this particular model do not fire reliably at 3.3V.
âŚYour optoisolator should be fine to sink the current on IN with the module (the onboard PNP transistors base current), but I had trouble finding one that could sink the coil current when moving to raw components.
Hereâs the datasheet for that relay: https://www.ghielectronics.com/downloads/man/20084141716341001RelayX1.pdf