We can retrieve our hardware’s fan speed using the psutil
module in Python.
psutil
module?psutil
(Python system and process utilities) is a Python package that retrieves information on ongoing processes and system usage (CPU, memory, storage, network, and sensors). It is mostly used for system monitoring, profiling, restricting process resources, and process management.
The module can be installed via pip
as follows:
pip install psutil
sensors_fans
methodThe sensors_fans
method returns the available fans and their respective speed in revolutions per minute (RPM).
psutil.sensors_fans()
This method has no parameters.
import psutilprint("The hardware fan speed is:")print(psutil.sensors_fans())# If there are no fan sensors in the machine,# then the output would be an empty dictionary.# If there are fan sensors,# then the fan speed would be displayed.
psutil
module.sensors_fans()
method.