-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArduinoPCTemps.pyw
More file actions
33 lines (25 loc) · 819 Bytes
/
ArduinoPCTemps.pyw
File metadata and controls
33 lines (25 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import time
import serial
import wmi
w = wmi.WMI(namespace="root\OpenHardwareMonitor")
cpu = 0
gpu = 0
# Put your COM port here
port = "COM5"
arduino = serial.Serial(port, 9600, timeout=1)
while True:
hw_infos = w.Sensor()
if hw_infos:
for sensor in hw_infos:
if sensor.SensorType == "Temperature":
if sensor.Name == "GPU Core":
gpu = ("G%dP" % sensor.Value)
elif sensor.Name == "CPU Package":
cpu = ("C%dS" % sensor.Value)
arduino.write(gpu.encode() + cpu.encode())
# print(gpu.encode() + cpu.encode())
time.sleep(0.5)
else:
arduino.write("ErrorS".encode())
# print("Error".encode())
time.sleep(2)