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 ...
simulate this circuit – Schematic created using CircuitLab
With both relays off or both on, both motor terminals are connected to the same voltage, so the motor doesn't run. Operate either relay to connect its end of the motor to the other voltage to make the motor run in the desired direction.
The "3.75V" types are designed for 5V nominal so forget those. They need about 4V to operate reliably and the RPi will give less than 3.3V.
The 3V nominal types have a 137 ohm coil and will draw about 20-24mA from a 3.3V supply. That's too much to drive safely from the Raspberry Pi GPIO output. You could use a CMOS buffer but it would make a lot more ...
Your original question was confusing. I have edited your question, hopefully to make it clear. So what you are building is a transistor inverting switch, and you want to turn the LED (D2) on and off by shorting it via the transistor, and the transistor is controlled by an output pin of an Arduino or Raspberry Pi.
There are several potential problems,
Generically, I would work the problem right to left.
1) Start with the current that's required to pull in the relay.
2) Divide that current by the worst case (minimum) current gain of the 2N5551; Mutiply that current by 2X or 3X to ensure the transistor is in saturation. Call this Ib, which is the base current needed to drive the transistor.
3) Divide Ib ...
I know this would be a fairly simple logic circuit to make, ... but I'm wondering if such a product already exists, ...
It probably doesn't exist.
When you have the luxury of one or more wires you'd typically use a versatile or robust solution.
One which offers more than just unsolicited command shouting, such as I2C.
One that isn't as susceptible to noise ...
There are a number of ways to do this, the most generic is an R-C quench circuit.
You can even get them in one package. People often use 0.1 uF and 100 ohms, but you may want to use trial and error to get the best results for your application.
If the load is at line voltage you might use an X2 for the capacitor for safety. One capacitor company used to ...
What you missed is that threshold voltage for IRF520 is 4V. A MOSFET won't start conducting heavily (or completely turn ON) until threshold voltage is reached.
You are using 3.3 volts which is obviously less than that.You need a separate drive circuit or just use another transistor with a lower threshold voltage, say 3 volts.
1) You chose the 5V Relay and not the correct 3V Relay.
It should be 137 Ω and thus on low side drive + 22 Ω = 159 Ω so 3.3V/159Ω= 21 mA and Pd =21mA*3.3V = 68 mW of which 22/159Ω 14% is dissipated by the CPU GPIO port. The minimum voltage Umin = 2.25V, Umax= 8.8V so safe.
These Relays are designed for 3V, 5V CMOS logic "Directly triggerable with TTL ...
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.