# Is there an easier way to signal this active low relay module for the pi?

Two parts to this question:

Part 1:

I am planning on setting up this relay module with my pi (which afaik has gpio pins set to LOW at startup).

1.) Does this mean if I hook it up as the picture suggests on that page, that all the relay sub-modules will be on at startup?

2.) Does this mean if I want the relays to be off at startup, I need some sort of transistor outside the relay module to provide the HIGH signal constantly so that I can use a HIGH GPIO to turn on the relay (by making the transistor go from HIGH to LOW)? Is there an easier way to do this than to use an external transistor?

Part 2:

After briefly looking for other relay modules, many seem to have this active low behavior. What is the reasoning behind this? Especially if they are meant for microcontroller usage (being a module and not just a relay), wouldn't it make more sense to have the modules be active high?

• You already have a good answer for first part of your question. Regarding the second question, there could be many reasons. First, some MCUs have pins with drain capacity higher than source. Second, active low input is compatible with both push-pull and open drain outputs. I am sure there are other reasons as well. – Maple Dec 29 '19 at 5:48
• this module has a LED in series with the opto-isolator meaning it needs about 2.5 to 3V to turn on... having the inputs active low allows the use of a higher VCC for the relay module (eg 4V) giving enough headroom to drive the inputs from 2.5V GPIO etc... – Jasen Dec 29 '19 at 6:20

A Raspberry Pi has a well-defined GPIO configuration on startup: all GPIOs are inputs, 0-8 have weak pullups, and 9-27 have weak pulldowns.

You can use a suitable pullup resistor to ensure that the pin goes high when not driven (when using 9-27 take care to ensure that the resulting voltage is high enough).

As a result, the pins will have a logic-high voltage, until you a) configure them as output and b) drive them low.

• Take a look that the relay module is powered from 5V, not 3.3V . Of course, we have voltage drop on each LED and B-E junction of each channel on module, so the voltage on RPi output probably will not exceed 3.3V in open state, anyway this is not too elegant... What in the case of short circuit of the LED? Unfortunatelly, this is possible - LED, like any other electronics element, can stop working without the visible reason... This is only technology. – VillageTech Dec 29 '19 at 5:46
• "relay module is powered from 5V, not 3.3V" ... not really. The input LEDs are powered from VCC. Considering 200 Ohm resistors I'd say there is a lot of leeway there. The relays are powered from JD-VCC which, from relay datasheet, should be OK in 3.75-6V range. If you keep a jumper connecting the two and share grounds then yes, you are powering everything from same 5V. Which coincidentally makes optical isolation pointless. – Maple Dec 29 '19 at 6:09
• Thanks! To clarify, I don't need yet another pullup resistor if I'm using pins 0-8 right? In the case that I do add another pullup resistor to pin 0-8, does that mean I have now 2 resistors in parallel (effectively lowering resistance and drawing in more current)? Also what is the effect of pulling up to 2 different Vcc in this case (3v3 internally and 5v externally)? – user947659 Dec 29 '19 at 14:56
• @user947659 the module uses two LEDs and a resistor in series to its 5V rail, which shouldn't pose a large issue for your application. When the gpio is pulled to 3v3, there's a 1.7v drop available, while the voltage drop of an LTV817 and a visible LED combined is above that. I wouldn't suspect any issue but confirming it with a multimeter in operation wouldn't hurt. – Reinstate Monica - ζ-- Dec 29 '19 at 16:25
• @user947659 you also don't need an external pull-up resistor for pins 0-8. The existing built in pullup (or even a high-impedance floating output) ought to suffice. – Reinstate Monica - ζ-- Dec 29 '19 at 16:27

Simply use ULN2803 - it cointains 8 inverters with open collector output. There is no need to provide Vcc in such application, simply connect pins 1...8 to RPi outputs, pin 9 to GND, and pins 11...18 to inputs of your relay module. The pin 10 should be left not connected.

• Thanks for the tip! Don't you need Vcc for the LOW(in) -> HIGH(out)? Edit: Nvm, answered my own question...the Vcc is to prevent kick-back and protect the IC edaboard.com/… – user947659 Dec 29 '19 at 4:59
• Nope. There are simply eight darlington transistors inside - so doesn't need the Vcc. Each transistor has own input resistors, making them capable to be driven from 3...5V source without any external components (resistors etc) - so these inputs can be safely connected directly to the RPi I/O pins without any risk of burning-out the RPi. And open collector outputs of each darlington are ideal to sink current incoming from connected relay module. BTW: I'm using similar solution in my home automation controller - the difference is I have 4 relay module, and I'm using ULN2003 (it's enough for me). – VillageTech Dec 29 '19 at 5:07
• The pin 10 is useable in case of direct driving inductive loads (relays, motors, fans) - but in your aplication it is absolutely unnecessary (ULN drives your module, not the relays indirectly). – VillageTech Dec 29 '19 at 5:09
• A darlington topology is really NOT a good choice for this task at all. The relay already has its own driver, this is a LOGIC signal not a power one, and the relatively high saturation voltage is probably a bad idea when what it is driving is an optocoupler LED. An ordinary logic inverter or a single transistor (vs Darlington) would be more appropriate. – Chris Stratton Dec 29 '19 at 5:15
• You are right. But using discrete transistors (+resistors) requires much larger area on the PCB. The high saturation voltage is no problem in this specific case too. Some time ago I was looking for more elegant solution and didn't find nothing as simple as ULN ;) Typical logic inverter IC contains only 6 inverters, and the pin topology is simply uncomfortable ;) Finally, it seems that there is no ready-to-use solution, similar to ULN2803, but created using "normal" (it means: no darlington) transistors... So, using here the ULN2803 (or 2003) is maybe not elegant, but works like a hell :) – VillageTech Dec 29 '19 at 5:36