24VDC coil relay schematic

I normally use a really with 5VDC coil voltage, so I just copied the schematic from what I’ve used for that. Is there any reason this shouldn’t work?

Q1 (MMBT3904 ) TRANS NPN 40V 0.2A SOT-23

D1 (MBR0540-TP) DIODE SCHOTTKY 40V 500MA SOD123

Relay (ALF1T24) coil draws 37mA, 24Vdc RELAY GEN PURPOSE SPST 20A 24V

D1 & Q1 both have a voltage rating of 40V. That’s the only thing I know to watch for. The 24Vdc isn’t going to affect the LED1 indicator is it? Nor the Arduino pin?
Thanks.

If Q1 is simply a switching transistor and not a MOSFET you do not need R2.

Otherwise looks OK

Weedpharma

Looks fine, except ...

weedpharma:
If Q1 is simply a switching transistor and not a MOSFET you do not need R2.

True, and however you use it, R2 should go on the Arduino side of R3 because you do not want it to form a voltage divider. You only want it to pull the voltage down if the Arduino is not driving it at all (such as at reset, before your sketch starts).

Now, for 5V, R1 will limit the LED current to less than 5 mA, but for 24V, it will pass more than 20 mA, which is likely more than the LED is rated for, so you probably want to knock it down to 2k7.

Paul__B:
but for 24V, it will pass more than 20 mA, which is likely more than the LED is rated for, so you probably want to knock it down to 2k7.

I have always calculated my resistors on 20mA and I have seen many others work on the same.

A bigger R will not hurt but 20mA is OK.

Weedpharma

With 24V coil voltage being switched (even with the kickback diode), the proximity of the relay to electronics could become an issue if it's too close. Also, if switching an inductive AC load, may need a snubber or MOV across the load for contact arc suppression.

The resistor R2 is needed to ensure the transistor remains turned off during power down or power up of the Arduino while the control pin is at high impedance. With R2 being 10x higher in value than R3, it won't matter which side of R3 it is placed.

An advantage of creating a voltage divider would be to boost the noise immunity of the control circuit. Without R2, the 2N3904 begins conducting when the control signal approaches 0.65V. With R2, the transistor begins conducting when the control signal approaches 0.72V.

However, if R2 is changed to 1K, the transistor begins conducting when the control signal approaches 1.3V, which doubles the noise immunity. With the max base current being lowered to around 2mA, there will still be 120mA switched if we use hFE = 60.

There is a problem with the way you have the LED powered.
When the transistor is turned on it will turn on the relay, and light the LED, correctly.

But you need to consider what happens when the relay is off.

When the transistor isn't turned on there is 24V on it's collector.
This means that you have 24V on the cathode of the LED and 5V on the anode, which results in a reverse voltage of 19V. This is likely to be above the reverse voltage rating of the LED.

I think a better solution would be to increase the value of R1 and power the LED from the +24V supply.

JohnLincoln:
There is a problem with the way you have the LED powered.
...
I think a better solution would be to increase the value of R1 and power the LED from the +24V supply.

Ah yes, I was not noticing that obvious blunder in the circuit when I answered. The LED needs to be powered of course, from the 24V supply, with a 2k7 resistor. (The resistor will dissipate less than a quarter Watt.)

I don't see why that led is connected that way. A relay status led is typically across the relay coil. (with the cathode connected to the transistor collector and the resistor to the 1N4001 diode cathode.)