-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemperature_data.py
More file actions
31 lines (25 loc) · 1.02 KB
/
temperature_data.py
File metadata and controls
31 lines (25 loc) · 1.02 KB
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
import time
import serial
import clr # the pythonnet module.
clr.AddReference(r'E:\test_ann\compile_program\LibreHardwareMonitor\LibreHardwareMonitorLib')
# e.g. clr.AddReference(r'LibreHardwareMonitor\LibreHardwareMonitorLib'), without .dll
arduinoData = serial.Serial('com4', 115200)
# change 'com4' to your comport for arduino and make sure to match baud-rate
from LibreHardwareMonitor import Hardware
device = Hardware.Computer()
device.IsCpuEnabled = True
device.Open()
while True:
temps = []
core_number = 4 # change this to the number of cores present in CPU.
for d in device.Hardware:
d.Update()
if d.HardwareType == Hardware.HardwareType.Cpu:
for sensor in d.Sensors:
if sensor.SensorType == Hardware.SensorType.Temperature:
temps.append(sensor.Value)
data = str(temps[core_number])
print(data, ' ->', type(data))
data = data + '\r'
arduinoData.write(data.encode())
time.sleep(2)