Skip to content
Snippets Groups Projects

BME680 Refactor

Merged 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:
env.close()

Closes #107 (closed)

cc @chris007

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading