I want to connect a relay to the GPIOs, what are the things a can use to do that? I read it could be transistors or diodes. Can I use resistors too?
I actually have this same relay, but in single relay package, not the 4x package.
Anyway, from the testing I've done, I've concluded:
- The relay's 5V source cannot be powered by the 3V3 rail (not surprising)
- When powering the relay's source from the 5V rail:
- Signal driven by 5V rail, current draw is 14.5 mA and relay operates
- Signal driven by 3V3 rail, current draw is 4 mA and relay operates
And, since we know that the RPi has no current limiting and will (try to) deliver as much current as a device wants to draw, since the max output for any single GPIO should be ~16 mA (reference), this 4 mA draw seems to be safe for the pi. Just keep in mind, max total current draw should not exceed 50 mA, so four of these relays together will draw 16 mA total. Depending on what else you have connected to the Pi, this might be something to be careful of.
You should really do your own testing for longevity, etc. But, to me, it seems perfectly safe to run it at 5V source and 3V3 signal.
On a (somewhat) side note, you mention the use of transistors and resistors and all that good stuff. Your board appears to have all these components required for relay operation already built into it. But, if you're curious as to the electronics in use, I found this schematic for a single relay online:
If you have minimal electronics knowledge, work up to understanding the exact reason that all those components are there. For only 4 components, there is a lot of electronics theory there! (Namely, that diode. Look up "inductive kickback" and be amazed at what you will learn of relays and inductors in general)