Skip to content

BME680 Refactor

rahix requested to merge rahix/bme680-refactor into master

Add a sensor-class interface for the BME680 which is more pythonic than access through raw functions. This class also functions as a context-manager to automatically turn off the sensor once it is no longer needed.

The new interface allows a number of different ways to access the sensor:

import bme680

with bme680.Bme680() as environment:
    # Do a measurement, just for temperature
    t = environment.temperature

    # Do a measurement, just for humidity
    h = environment.humidity

    # Get all measurements in a single call; this is faster
    d = environment.get_data()
    t = d.temperature
    h = d.humidity

# Without context-manager
env = bme680.Bme680()
t = env.temperature
# Turn off manually:

Closes #107 (closed)

cc @chris007

Merge request reports