PWM speaker

I got this little 2w speaker

Using the Tone Buzzer fezzer code here

When just connecting speaker to Di5 and gnd, works fine. Just can’t hear it because of low power.

So I tried to connect to straight 3.3v line via Mosfet breakout like below.

However it only clicks a few times and domino reboots in a loop. What am I connecting wrong here? tia

Can you try using an external power supply for the MosFet ?
Or adding a big capacitor (220uF ?) between GND and +3V3 ?

Forgot my Maf. Added a 6ohm resistor to limit watts <2W and 550mA max draw. Works good.
Writeup here