ESP32 – Best Way to Drive 4 Relays and 4 MOSFETs (PWM)

esp32mosfetmosfet-driver

I have a project that will require switching of 4 x 5/12 V mini power relays and 4 MOSFETs (switching 12 V load up to 10 A maximum).

I'm quite new to circuit and PCB design and I have been scouring the forums for a solution.

  • ESP32 logic 3.3 V
  • I have two separate voltages on the board (12-14 V unregulated & 5 V 1 A regulated)
  • Open to using either 5 or 12 V coil relays not sure which would work better (considering voltage drop across ULN2004).
  • I would ideally like to have the option to PWM the MOSFETs
  • All grounds are common
  • The MOSFETS will be powering things such as a water pump, LED strips, solenoids

I had originally planned to use a ULN2004 as I thought I could drive the 4 relays and 4 MOSFETs from the same chip (ideal solution) however I now understand that the MOSFETs aren't ideally powered this way and could overrun the 500 mA max on the chip.

There are hundreds of gate drivers and I appreciate there are MOSFETs that can be driven from 3.3 V logic but they seem to all be surface mount and not suitable to carry 10 A with a 3.3 V gate-source.

Any help is appreciated

Best Answer

If you don't need isolation, MOSFETs will be cheaper than relays.

Since your switching frequency will be low, you can either drive the MOSFETs from the ESP32's 3V3 GPIO, or from a 3V3 to 5V level converter. This depends on what MOSFETs you use.

As you say in the question, it may be difficult to find a 10A MOSFET with 3V3 gate drive. In this case, a cheap solution is to use something like 74HCT245 as 8-way translator from 3V3 to 5V, then use 5V gate drive FETs, which should be easier to find.

It doesn't have to be 74HCT245, any logic chip like "octal buffer" or "octal line driver" like HCT240, HCT7541, HCT244, etc, will do the job just fine. In fact any HCT buffer logic chip would work, but if you use an octal buffer, you only need one chip.

It has to be HCT and not HC though. When powered from 5V, HCT chips are compatible with 3V3 logic levels on the input side, but they will output 5V logic levels, which makes them useful for logic level translation.

With the typical 4mA output current of 74HCT, and a MOSFET having 10nC gate charge, it will switch in about 2.5 µs which is not too fast and not too slow.

If you want more output current for faster switching, use 74ACT instead of 74HCT. But slower switching is nice to avoid EMI.

With high current, layout is important: all the high current connectors should be on the same side of the board, with wide copper connections, to make sure the load currents do not travel through the ground plane/tracks along the entire length of the board.

If the power input connector is on one side, and the output connectors are on the other side, then you have to be much more careful about your grounding.

Related Topic