ESP32 - connecting two circuits to the same PWM pin?

I have two LEDs, connected to two different MOSFET circuits that need to be controlled simultaneously. The LEDs can’t be connected to the same MOSFET circuit (already burned one trying that) and I only have one PWM pin available.
Is it OK if I connect that pin to control both MOSFET circuits in parallel? Would it damage the ESP32?

In principle, I don’t see why not, because MOSFETs draw almost no current on the gate. BUT, I think we’ll need to see your circuit diagrams. I have a suspicion you’re doing something else wrong. There are a number of factors that are unclear from your post, such as the specs of the MOSFETs and LEDs used, how you’re powering everything, other components such as resistors and/or capacitors on the gate, etc. As a qualified but non-practicing electronic engineer I’m a little rusty, but I’ll try to help.

Thanks, Pieter!
Here are the specs of the MOSFET board: It is one of those IRF540, 4-channel boards (schematic below). The LEDs are DRP-10WGJ24WW (10W, 9-12V, 540-675 mA) I’m powering the ESP32 from a USB charger and the MOSFET from a ATX power supply, used also for another LED project). I’m connecting 10 LEDs in parallel and when I tried to connect all of them to the same MOSFET it worked fine for about 1h, then started flickering, then went off in about 30 sec. It should tolerate up to 33A (as advertised by the seller), but got fried with much less. The other channels in the same board are still working normally (powering other LEDs, much less power). If I connect just two LEDs to the damaged channel, it works only at a very low intensity, but flickering a lot. If I connect the same LEDs to another channel (or another board) they work fine.
As I have another MOSFET board, then I considered splitting the 10 LEDs in 3 groups (4,4,2), as I know that 4 of such LEDs work fine with that board (from another project, implemented a while ago). The limitation is that I have only one PWM pin available in this ESP32, so I considered connecting at least two (maybe all three?) LED groups to the same pin. Then came the question for this topic.
Thanks for helping, it is quite nice to have a word from someone with a background in the field.

IRF540_MOSFET4_schematic
CaptureMOSFET

Your circuit looks fine.

33A is the maximum the MOSFET can conduct if a few other parameters are taken into account. Otherwise it will be much, much less.

You may be exceeding the MOSFET safe thermal operating area. There is no way that board will allow repeated switching (as with PWM) at high currents without a heatsink.

When off the MOSFET is dissipating no power.

When on the MOSFET is dissipating: RDS(ON) x I, = 0.077 x ~0.6A x 10 = about 0.5W. This is fine for an un-heatsinked MOSFET in a TO-220 case (as you have). see edit below.

However, when switching the MOSFET between on and off it dissipates a lot more power. Especially if the transition is not fast enough. Calculating this is not simple but a quick test would be to carefully touch the case of one of the MOSFETS when you have it at 10%, 50% and 90% dimmed. If it is too hot to touch after a few minutes you need more heatsinking.

Looking at pictures of these boards on the internet there does not even seem to be any copper fill under the MOSFETS and they are not attached to the PCB. So no heatsinking at all.

EDIT: I made a mistake.

The power when on = RDS(ON) x I2 = 0.077 x (~0.6A x 10)2 = about 3W, This is pushing it for an un-heatsinked TO-220 case (max is about 1.5 to 2W). Especially when combined with switching losses.

Thanks for the advice!
I did not know about this increased dissipation during switching. In the article you linked, they suggest decreasing the frequency, but I think in my case that would not be feasible, as I’m already working at 100 Hz. Lower than that I would probably get a noticeable flickering…

  - platform: ledc
    pin: GPIO4
    id: gpio_4
    frequency: 100 Hz
    max_power: 90%

I did the temperature test you mentioned (touching the cases), using 4 LEDs in parallel. The temperature did not increase at all at the dimming rates you suggested, after about 10 minutes usage. Looking at the calculations you made, that is quite unexpected, as it would be at about 12W, so I would expect at least some heating detectable “by hand”.

4 LEDs would give you 0.5W which is perfectly acceptable for a TO-220 part without a heatsink.

Power = RDS(ON) x I2 = 0.077 x (~0.6A x 4)2 = about 0.5W

Allowing for 1W dissipation you should connect no more than 6 LEDs.