This code is based on temp_sensor.m by fermion-star which was in turn was based on sensors.m by freedomtan
The purpose of this tool is to quickly retrieve temperature information on macOS arm64 / Apple Silicone, either for use in other applications. The output can be modified with arguments for specific readings or average temperatures.
To run the application, either download the binary from Releases, or compile yourself. Run with the following command:
./macos-temp-tool [options]
-a
: Calculate average temperature.-f [property]
: Filter data by property.-r [interval]
: Repeat the operation with a specified interval.-p
: Print thermal pressure, not compatible with the other arguments.-m
: Print maximum temperature, not compatible with -a or -p or -array.-array
: Print as two arrays, one with names, and one with values instead of a table. Not available with-a
.-h
: Print help message.-l
: Print license information.
All arguments can be combined in whatever order.
Get thermal pressure
./macos-temp-tool -p
Calculate average temperature:
./macos-temp-tool -a
Filter data by sensors with a name containing "PMU tdev":
./macos-temp-tool -f "PMU tdev"
Calculate average temperature from sensors filtered by "PMU tdev":
./macos-temp-tool -f "PMU tdev -a"
Repeat operation with a 5-second interval:
./macos-temp-tool -r 5
- Xcode
Run the following command to compile the code, use the Makefile (run make
) or use the provided compile.sh
script.
clang -Wall -v temp_sensor.m -framework IOKit -framework Foundation -o macos-temp-tool
For better names (e.g. what is PMU TP3w
?) for the sensors, please refer to
https://github.com/exelban/stats/blob/master/Modules/Sensors/values.swift
https://github.com/acidanthera/VirtualSMC/blob/master/Docs/SMCSensorKeys.txt
Here is a similar code in swift for getting sensor values using IOKit (for intel Mac)
https://github.com/exelban/stats/blob/master/Modules/Sensors/values.swift