Hello I wish to control a 24V contactor from a Raspberry Pi with no HAT as I need access to pins for sensors and other parts of the project.

I want to use an optocoupler for safety. I am led to believe by my research as I will be switching a 240V 16Amp induction motor a contactor is better suited than a solid state relay.

I have found this schematic for driving a 12V relay so how would I adapt it to 24V contactor apart from changing the external power supply to 24V?

enter image description here

I plan on instructing an electrician to install the 240V side of the circuit.

This is the contactor I plan to use

I have researched posts on this forum but cant find an example with both 24 volts, a contactor and an optocoupler.

  • You are asking a EE question which should be asked on an EE site as this has nothing to do with Pi. It should work although the use of a P channel MOSFET seems unusual. You would need to consult the data sheets for the devices you plan to use. Frankly I wouldn't use a MOSFET to switch a simple relay.
    – Milliways
    Oct 16, 2023 at 21:45
  • Sorry this is my first post here. I will post on EE next time
    – daniel
    Oct 16, 2023 at 22:00
  • Would you use a design using a BC547 or similar instead of a MOSFET? I’m struggling to read the datasheets as I’m unsure which parameters are important for transistors. Any resources would you recommend to get me up to speed?
    – daniel
    Oct 16, 2023 at 22:04
  • You're going to have to tell us how much current is required for the relay/contactor coil. The spec sheet for the contactor doesn't give that.
    – Seamus
    Oct 17, 2023 at 5:53

1 Answer 1


You should probably make R1 47k (or even larger) to limit the current through the optocoupler. The mosfet should probably be an SRF9024. But for the rest the circuit is ok for 24 V.

  • The change of resistor makes intuitive sense to me. But I’m unclear why a change of transistor is required to SRF9024. Also this transistor appears to not be widely available?
    – daniel
    Oct 16, 2023 at 16:29
  • To be honnest, I'm a bit out of touch with the mosfet market. From the datasheet of the IRFR9024, I saw that the absolute maximum for Gate-source voltage is 20V. That may become a problem. So I suggested a mosfet that allows a larger value. Oct 16, 2023 at 17:47
  • Thanks for sharing your criteria. Would a FQU11P06 be suitable as well. It has a gate source voltage of 30V
    – daniel
    Oct 16, 2023 at 21:59
  • Should be sufficient. A slight margin is always a good idea, but the original 12V circuit had a comparable margin. Oct 17, 2023 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.