enter image description hereI need the RPI3 B+ GPIO to drive a 24V relay that turns on an AC resistive load.

Update:I hope the block diagram I attached earlier is now showing.

part numbers listed, but the mosfet is not working as expected. I think my implementation is incorrect because -the relay should be connected to the drain of the mosfet and not the source -even then the mosfet will not switch 2A, 24V to the relay, because then 24V will always be going to the relay

Question: How do I switch on/off 24V, 1A to the EM relay based on the RPI GPIO output?

Update: The 24V relay is fixed, I cannot replace it with a relay module with built in optocoupler.

Concept: Double the 12V suppply to 24V using voltage doubler.

1)'244 buffer from RPI GPIO to increase current

2)opto isolator module from sparkfun datasheet at https://www.sparkfun.com/products/9118 for DC/AC decoupling

3)N channel MOSFET datasheet at https://www.mouser.com/datasheet/2/196/Infineon_IRLB8721_DataSheet_v01_01_EN-1228534.pdf

4)12V to 24 V voltage doubler module datasheet at https://www.amazon.com/Voltage-Regulator-Converter-Waterproof-Transformer/dp/B07V7F93JP/ref=sr_1_4?dchild=1&gclid=CjwKCAjwrPCGBhALEiwAUl9X03GnzvJ8ZT_VVP-ML0_LN_-DjpyOVnPXw9QF5003Lh_7ovsw4Q3bXRoCDQcQAvD_BwE&hvadid=232502440548&hvdev=c&hvlocphy=9032020&hvnetw=g&hvqmt=e&hvrand=9930756018523692093&hvtargid=kwd-302991713261&hydadcr=18917_9698850&keywords=12v%2Bto%2B24v%2Bdc%2Bdc%2Bconverter&qid=1625075949&sr=8-4&th=1

5)24V relay Specifications: Relay Type: General Purpose Coil Voltage: 24VDC Switching Voltage: (250VAC, 30VDC) Max Contact Form: SPDT Contact Rating (Current): 30A Coil Type: Non Latching

datasheets at

  • without seeing how you wired it up, the answer is a pineapple
    – Bravo
    Jan 6, 2022 at 23:02
  • 1
    (1) Your expensive voltage doubler and HC244 look like an overkill, (2) A cheappy 5/12/24 relay module with optoisolation should do the job. (3) Ref: Relay module - electronics.stackexchange.com/questions/505318/…. (4) I have the feeling that you are making simple things very complicated, with inappropriate components.
    – tlfong01
    Jan 7, 2022 at 1:30
  • Frankly you would be better to get a suitable relay module.
    – Milliways
    Jan 8, 2022 at 0:33
  • You have asked a question about a circuit, but your picture shows a block diagram. It would really help clarify your question if you added a schematic using the built-in tool we have here
    – Seamus
    Jan 8, 2022 at 10:21

1 Answer 1


Welcome Nerd5! From what I can see your MOSFET will not work, it has a minimum Vgs of 4V. Nice part but not guaranteed to turn on. Pick a MOSFET that will turn on at about 2 volts, that should have it enhanced enough to drive your boost converter. Connect the + of the converter to the +12V, and the other side - to the drain of the MOSFET. The source of the is connected to the ground of the pi and 12V power supply The grounds have to be connected together. It would be best to add a 10K resistor from the port pin, that is connected to the gate, to ground. Several of your links did not work for me so I am guessing on several parts. Without a schematic it is hard to accurately diagnose your problem. I would take a SWAG and say you did not properly power the relays and or connect them properly.

  • Thank-you...The datasheet has a Fig 3 curve that shows Vgs vs Ids at 2V. So I thought it would turn on at 2V min. Vgs spec also shows +/- 20V. So did I misunderstand ? I also was able to attach the block diagram finally in my original post.
    – Nerd5
    Jan 7, 2022 at 15:44
  • You are making a great attempt to understand these complicated MOSFETs. You had the correct starting point. This process will help you understand why we sometimes ask all the questions. Yes it will turn on but it will not conduct your load. Look at Fig 12. Since you did not specify the load for the converter I assumed about 2 Amps at 24V requiring 4A + loss at 12V.
    – Gil
    Jan 7, 2022 at 22:30
  • Correct answer! In general, it is never a good idea to drive a MOSFET from a GPIO pin. Even if you find one with a low Vgs, the Gate capacitance will slow things down. Use a bipolar transistor instead. If you need to switch a lot of current, get a Darlington.
    – Seamus
    Jan 9, 2022 at 7:39

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.