Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with psutil - Doesn't detect SoC temperature sensor if another temperature sensor exists. #13

Closed
trejan opened this issue Jul 12, 2019 · 2 comments · May be fixed by #88
Closed
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@trejan
Copy link

trejan commented Jul 12, 2019

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
@Gadgetoid
Copy link
Member

D'oh!

I guess I could add this as a failover if the other two cases don't succeed, I don't see it doing any harm.

Sorry I've not had any kernel-driver temperature sensors hooked up before, so I hadn't a hope in catching this. Thanks for posting a solution!

@Gadgetoid Gadgetoid self-assigned this Jul 12, 2019
@Gadgetoid Gadgetoid added bug Something isn't working enhancement New feature or request labels Jul 12, 2019
@wkelley70
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants