I'm new to electronics so I have almost no idea what I'm doing. I hope you guys can help.
Basically I have two relays with 24VDC coils that I would like to be able to turn on via GPIO. If I connect the relay directly to ground, I can hear it "pop" which means the relay works. The schematic below is how I have it wired up. Via code I know the GPIO is working because I have replaced the relay with an LED and the LED lights up via code (that is not displayed, I use the green LED to show me that the decide is "Ready" by lighting up after boot)
I feel like I'm missing something very easy here. Any ideas? Thanks for your help! I hope this helps others eventually.
You have no series resistor in series with your LED, that will damage the PI eventually. Put a 220 Ohm resistor in series.
You wire 3V3 to the breadboard. Why?
The most probably cause for the Mosfets not working is that they probably are not rated for the low 3.3V gate voltage, and need more (like 4 Volt) to go open. Choose a different type of FET, one that fully opens with a gate voltage as low as 3.0V.
Looks like you were exactly right about the gate voltage. I got one of those step down DC devices with the rheostat and fired 4V to the gate and the relay popped right open. I then adjusted the output to 3.7V and put that on the gate. No "pop".
Might be a dumb question but does it have anything to do with the amount of voltage I'm attempting to ground (24V relay) when drain and source are connected?
I'm using Radio Shack IRF510. Any suggestions of a more appropriate FET N-channel with a gate that GPIO will trigger? Thanks!
Have a look at npn darlington transistors like TIP120 instead of mosfets. You will need a resistor (1K)between your gpio output and the base of the darlington transistor. A darlington only needs 1.4 - 1.5V to conduct. It's current driven while mosfet gates are voltage driven. Due to the fact it's a darlington, the current amplification is very high, so you hardly need any current from the pi gpio's.
A mosfet can switch like 10 Amps. This current is much less with a darlington, but you don't need that for a relay.
You could connect the led with a decent serie resistor on the 24V relais voltage as well. Due to the high voltage drop over those resistors, they will heat up a little.
Assume you want 8mA passing trough your led.
R = 24 - 1.2 / 0.008 = 2850 Ohm
P = I * I * R = 0.008 * 0.008 * 2850 = 0.18W
So basically, a 0.25W resistor should still be fine.
A 2700 Ohm resistor is what you can easily find.
The led current will be a little higher with a 2700 Ohm resistor.
The 1.2V is the voltage standing on the led when approx. 8mA is passing trough it.
It depends upon the type of led and it's color, but is not that important in the equation.
8mA is an average current, enough for most leds to give decent light.
I hope this example isn't too difficult to tell what I'm trying to do. Basically I have a 24V relay that I'm controlling with the TIP120. I would like the same TIP120 to make a 5V LED light up when the relay is on.
Would this example work or blow something up? Any suggestions? Thanks again - it's fun learning this stuff.