The reason your fan continues to run is because the +5V supply remains connected to your RPi, and therefore to your fan. If you wired the fan IAW the instructions, and executed the setup outlined for the
Raspberry Pi Configuration tool in the instructions, then one of the following is true:
- you are a victim of faulty/shoddy product design by the RPi Organization,
- your fan has failed, or
- you have not allowed sufficient time for your RPi 4B to cool after
You should know this: Issuing a
shutdown command (or
poweroff) stops the processor, but it does not remove 5V power from the RPi. Consequently, power is still being consumed by the RPi, and therefore heat continues to be produced.
You may want to return the fan as defective - you may (or may not) get a replacement that functions properly. If you elect to keep this fan, you can cure the "always on" problem as follows:
Follow the schematic below to wire your fan. Note the fan lead connected to the GPIO should be left unconnected - as per the schematic below.
simulate this circuit – Schematic created using CircuitLab
To control the fan, you may use a
device tree overlay which is easily configured in the folder
/boot/config.txt. If you are following the schematic here, you may open the file
/boot/config.txt in your text editor, and add this one line at the top of the file:
Save the file, and
reboot (pull the power plug & re-insert).
The fan will turn on when its temperature reaches 60 deg C, and will remain on until until the temperature falls to 55 deg C. With fan off, the temperature may rise again to 60 deg C - at which point it will turn on again, and the cycle repeats; i.e. the fan is controlled by the temperature of the CPU within a 5 deg C hysteresis loop.