Skip to content

Commit 10d8135

Browse files
committed
Switch temp comp method for #28
1 parent c1cfb8d commit 10d8135

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

examples/compensated-temperature.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import time
44
from bme280 import BME280
5-
from subprocess import PIPE, Popen
65

76
try:
87
from smbus2 import SMBus
@@ -24,10 +23,10 @@
2423

2524
# Get the temperature of the CPU for compensation
2625
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("'")])
26+
with open("/sys/class/thermal/thermal_zone0/temp", "r") as f:
27+
temp = f.read()
28+
temp = int(temp) / 1000.0
29+
return temp
3130

3231

3332
# Tuning factor for compensation. Decrease this number to adjust the

0 commit comments

Comments
 (0)