12V 4-pin Noctua NF-A8 on Raspberry Pi 4B
2N2222 VCE can go beyond 20V so this circuit should work, based on your intent. You can use which ever viable RPi pin you have for both the PWM output and the RPM input pins.