We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c1cfb8d commit 10d8135Copy full SHA for 10d8135
examples/compensated-temperature.py
@@ -2,7 +2,6 @@
2
3
import time
4
from bme280 import BME280
5
-from subprocess import PIPE, Popen
6
7
try:
8
from smbus2 import SMBus
@@ -24,10 +23,10 @@
24
23
25
# Get the temperature of the CPU for compensation
26
def get_cpu_temperature():
27
- process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE)
28
- output, _error = process.communicate()
29
- output = output.decode()
30
- return float(output[output.index('=') + 1:output.rindex("'")])
+ with open("/sys/class/thermal/thermal_zone0/temp", "r") as f:
+ temp = f.read()
+ temp = int(temp) / 1000.0
+ return temp
31
32
33
# Tuning factor for compensation. Decrease this number to adjust the
0 commit comments