I would like to run the shell command;
Code: Select all
vcgencmd measure_temp Code: Select all
cpu_temp = subprocess.check_output("vcgencmd measure_temp", shell=True)
b"temp=52.6'C/n"
Could someone offer some advice please, many thanks.
Code: Select all
vcgencmd measure_temp Code: Select all
cpu_temp = subprocess.check_output("vcgencmd measure_temp", shell=True)
Code: Select all
with open("/sys/class/thermal/thermal_zone0/temp", "r") as file:
temp = float(file.read())
tempC = temp/1000
print (tempC)
Code: Select all
with open("/sys/class/thermal/thermal_zone0/temp", "r") as file:
temp = float(file.read())
tempC = temp/1000
tempC = str(tempC)
output = "temp=" + tempC + "'C"
print (output)
Code: Select all
import subprocess
# execute the command using Popen
sb = subprocess.Popen(['vcgencmd', 'measure_temp'], stdout=subprocess.PIPE)
# get the command output
cmd_out = sb.communicate()
# convert from byte string to string
temp = cmd_out[0].decode()
print(temp)
Code: Select all
pi@RPi3BP:~ $ python3 pop.py
temp=44.0'C