diff --git a/examples/all-in-one-no-pm.py b/examples/all-in-one-no-pm.py index d9b1069..959303e 100755 --- a/examples/all-in-one-no-pm.py +++ b/examples/all-in-one-no-pm.py @@ -14,7 +14,6 @@ from bme280 import BME280 from enviroplus import gas -from subprocess import PIPE, Popen from PIL import Image from PIL import ImageDraw from PIL import ImageFont @@ -91,9 +90,10 @@ def display_text(variable, data, unit): # Get the temperature of the CPU for compensation def get_cpu_temperature(): - process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE, universal_newlines=True) - output, _error = process.communicate() - 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 # Tuning factor for compensation. Decrease this number to adjust the diff --git a/examples/all-in-one.py b/examples/all-in-one.py index c0423e6..8b84a44 100755 --- a/examples/all-in-one.py +++ b/examples/all-in-one.py @@ -15,7 +15,6 @@ from bme280 import BME280 from pms5003 import PMS5003, ReadTimeoutError as pmsReadTimeoutError from enviroplus import gas -from subprocess import PIPE, Popen from PIL import Image from PIL import ImageDraw from PIL import ImageFont @@ -96,9 +95,10 @@ def display_text(variable, data, unit): # Get the temperature of the CPU for compensation def get_cpu_temperature(): - process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE, universal_newlines=True) - output, _error = process.communicate() - 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 # Tuning factor for compensation. Decrease this number to adjust the diff --git a/examples/luftdaten.py b/examples/luftdaten.py index d2d6562..3270f7d 100755 --- a/examples/luftdaten.py +++ b/examples/luftdaten.py @@ -71,11 +71,12 @@ def read_values(): return values -# Get CPU temperature to use for compensation +# Get the temperature of the CPU for compensation def get_cpu_temperature(): - process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE, universal_newlines=True) - output, _error = process.communicate() - 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 # Get Raspberry Pi serial number to use as ID