10-16-2019, 05:09 PM
(This post was last modified: 10-17-2019, 05:32 PM by botswanabub.)
I did this with a small python script with I registrated as auto start service.
this script renews the value in the pi_temp.txt every 3 sec. (could be modified) and start on boot.
Script
Service
Textfile
this script renews the value in the pi_temp.txt every 3 sec. (could be modified) and start on boot.
Script
#!/usr/bin/env python
import time
import subprocess
CPU="/sys/class/thermal/thermal_zone0/temp"
while True:
f = open(CPU, "r")
f1 = f.read()
f.close()
stringX = "t="+f1.strip('\n')
fileHandle=open('/home/pi/OAP/cpu_temp_savefile.txt', 'w')
fileHandle.write(stringX)
fileHandle.close()
time.sleep(3.0)
Service
[Unit]
Description=SetCPUTemp2TXTfile
[Service]
Type=simple
ExecStart=python /home/pi/cpu_temp.py
[Install]
WantedBy=multi-user.target
Textfile
t=54530