You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is actually a problem with psutil and not your code but it does cause problems with the Fan SHIM. automatic.py won't work in some specific configurations.
The way psutil works for temperature sensors is that it'll check for /sys/class/hwmon/hwmon*/temp*_* and /sys/class/hwmon/hwmon*/device/temp*_. If no temperature sensor is found only then will it look for /sys/class/thermal/thermal_zone. On a RPi, the SoC temperature sensor is on that second code path for /sys/class/thermal/thermal_zone*.
The problem I've got is that I fitted a Fan SHIM to a RPi which has a DS3231 RTC attached to it which has an internal temperature sensor. The Linux driver exposes that temperature sensor in /sys/class/hwmon and causes psutil to never check /sys/class/thermal/thermal_zone* for the RPi SoC temperature sensor. automatic.py continually prints out "Warning: Unable to get CPU temperature!" because it can't find a cpu_thermal.
My workaround was to bypass psutil for reading the SoC temperature and directly read /sys/class/thermal/thermal_zone0/temp in get_cpu_temp()
def get_cpu_temp():
with open("/sys/class/thermal/thermal_zone0/temp", "r") as f:
return int(f.readline()) / 1000
The text was updated successfully, but these errors were encountered:
Thanks for the information @trejan. I added an Adafruit DS3231 and ran into this issue. Adding your code and removing the original CPU temp code from automatic.py fixed the CPU temp detection.
This is actually a problem with psutil and not your code but it does cause problems with the Fan SHIM. automatic.py won't work in some specific configurations.
The way psutil works for temperature sensors is that it'll check for /sys/class/hwmon/hwmon*/temp*_* and /sys/class/hwmon/hwmon*/device/temp*_. If no temperature sensor is found only then will it look for /sys/class/thermal/thermal_zone. On a RPi, the SoC temperature sensor is on that second code path for /sys/class/thermal/thermal_zone*.
The problem I've got is that I fitted a Fan SHIM to a RPi which has a DS3231 RTC attached to it which has an internal temperature sensor. The Linux driver exposes that temperature sensor in /sys/class/hwmon and causes psutil to never check /sys/class/thermal/thermal_zone* for the RPi SoC temperature sensor. automatic.py continually prints out "Warning: Unable to get CPU temperature!" because it can't find a cpu_thermal.
My workaround was to bypass psutil for reading the SoC temperature and directly read /sys/class/thermal/thermal_zone0/temp in get_cpu_temp()
The text was updated successfully, but these errors were encountered: