Skip to content

Commit 3b2c9f9

Browse files
Merge pull request avinashkranjan#430 from Sloth-Panda/b5
added cpu tempearture script
2 parents f652e15 + e8516e1 commit 3b2c9f9

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

CPU temperature/Readme.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# CPU Temperature
2+
3+
This python script is used to get cpu temperature
4+
5+
- psutil (process and system utilities) is a cross-platform library.
6+
- It is used for retrieving information on running processes and system utilization (CPU, memory, disks, network, sensors) in Python.
7+
8+
## Explanation of the script
9+
10+
- Using psutil library's inbuilt function "sensors_temperatures()" to measure temperature of CPU
11+
12+
## Setup instructions
13+
14+
- Clone the repo to your machine
15+
- Head over to the required folder (Cpu Temperature folder)
16+
- Install psutil using
17+
```bash
18+
pip install psutil
19+
```
20+
- Run the script
21+
```bash
22+
python temp.py
23+
```
24+
25+
## Output
26+
27+
<img src="https://raw.githubusercontent.com/gavinlyonsrepo/raspberrypi_tempmon/master/screenshots/main_screen.jpg">
28+
29+
## Disclaimer
30+
31+
This does not work on a windows machine

CPU temperature/temp.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# importing the psutil library
2+
import psutil
3+
4+
# Note: It is not for windows user
5+
6+
data = psutil.sensors_temperatures()
7+
print("Current Temperature of CPU (celcius): ",data['coretemp'][0][1])

0 commit comments

Comments
 (0)