A lightweight Python utility for monitoring CPU temperature in real-time with data logging and moving average calculation.
- Real-time monitoring: Smooth console updates using ANSI escape codes (no flickering or scrolling).
- Smart logging: Buffered I/O logic that writes to disk every 10 entries to save disk lifespan.
- Moving average: Calculates the average temperature over a sliding window (last 60 seconds/10 samples).
- Safe shutdown: Graceful interruption handling with
try...finallyto ensure all buffered logs are saved onCtrl + C.
| Technology | Usage |
|---|---|
| Python 3.x | Core logic and execution |
| Pathlib | Robust cross-platform path management |
| Collections (deque) | Memory-efficient sliding window for AVG |
| Linux Sysfs | Direct reading from the kernel thermal zone |
If you see incorrect data or errors, it might be due to a different thermal zone index on your hardware.
- Open
main.py. - Locate the
temperature()function (around line 14). - Change
/thermal_zone1/to/thermal_zone0/or check your/sys/class/thermal/directory to find the correct path.