4-pin GPIO PWM Fan Connect To rpi4

i have a PC fan of foxconn nearly the size of the pi itself… i have been using this as a normal pi fan just makeshifted and adjusted it to put it on the pi

it really does the job well… it has 4-pin outlet as shown below
4wirefanconn
till now i was powering it with 12-v power supply externally (not connect to pi but it sat on it)
i was not satisfied by this because i was not able to control the speed of the fan as i have overclocked my pi
i will keep powering the fan externally, i just wanted to know that how would i connect PWM wire and Tach wire to the GPIO pins on the pi to control the speed of the fan. and also wanted to know that what i have to change in the Boot config things or whatever…

BTW, I am using DietPi (and i am also very new to this all things so please help me :cry: )
Please give me some suggestions.
:)
Thank you. Sorry for bad english

I just want to warn you about connecting things directly to the Pi’s GPIO pins, be careful as if the device draws to much current then you can be in for a very bad day and it could destroy the Pi.

I have modified a standard Noctua NF-A20 5V to run directly from a Pi and while it is not PWM it does swtich on and off via a transistor based on temperature using this command ‘dtoverlay=gpio-fan,gpiopin=14,temp=60000’ within the config.txt file.

Sorry I have no experience as far as adapting an existing 12v PWM fan to be controlled via the Pi’s GPIO pins.I am sure it is possible though but like I said just be careful.