1
0
mirror of https://github.com/cmur2/python-bme680.git synced 2024-12-22 22:54:29 +01:00

Minor linting fixes to examples

This commit is contained in:
Phil Howard 2020-03-20 15:38:31 +00:00
parent 90fabf53fa
commit 45eeba9bb4
2 changed files with 4 additions and 4 deletions

View File

@ -4,10 +4,6 @@ import time
import bme680 import bme680
from subprocess import PIPE, Popen from subprocess import PIPE, Popen
try:
from smbus2 import SMBus
except ImportError:
from smbus import SMBus
print("""compensated-temperature.py - Use the CPU temperature to compensate temperature print("""compensated-temperature.py - Use the CPU temperature to compensate temperature
readings from the BME680 sensor. Method adapted from Initial State's Enviro pHAT readings from the BME680 sensor. Method adapted from Initial State's Enviro pHAT
@ -31,12 +27,14 @@ sensor.set_pressure_oversample(bme680.OS_4X)
sensor.set_temperature_oversample(bme680.OS_8X) sensor.set_temperature_oversample(bme680.OS_8X)
sensor.set_filter(bme680.FILTER_SIZE_3) sensor.set_filter(bme680.FILTER_SIZE_3)
# Gets the CPU temperature in degrees C # Gets the CPU temperature in degrees C
def get_cpu_temperature(): def get_cpu_temperature():
process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE) process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE)
output, _error = process.communicate() output, _error = process.communicate()
return float(output[output.index('=') + 1:output.rindex("'")]) return float(output[output.index('=') + 1:output.rindex("'")])
factor = 1.0 # Smaller numbers adjust temp down, vice versa factor = 1.0 # Smaller numbers adjust temp down, vice versa
smooth_size = 10 # Dampens jitter due to rapid CPU temp changes smooth_size = 10 # Dampens jitter due to rapid CPU temp changes

View File

@ -22,6 +22,7 @@ sensor.set_pressure_oversample(bme680.OS_4X)
sensor.set_temperature_oversample(bme680.OS_8X) sensor.set_temperature_oversample(bme680.OS_8X)
sensor.set_filter(bme680.FILTER_SIZE_3) sensor.set_filter(bme680.FILTER_SIZE_3)
def display_data(offset=0): def display_data(offset=0):
sensor.set_temp_offset(offset) sensor.set_temp_offset(offset)
sensor.get_sensor_data() sensor.get_sensor_data()
@ -32,6 +33,7 @@ def display_data(offset=0):
print(output) print(output)
print('') print('')
print('Initial readings') print('Initial readings')
display_data() display_data()