kbrownlees / bme280

Python Driver for the BME280 Temperature/Pressure/Humidity Sensor from Bosch
Other
39 stars 15 forks source link

bme280.setup should avoid exposing bme280_i2c #6

Closed jscheidtmann closed 7 months ago

jscheidtmann commented 1 year ago

Looking at the read_bme280 script, the minimal script to read a sensor data from Python is:

from bme280 import bme280, bme280_i2c

bme280_i2c.set_default_i2c_address(0x76)
bme280_i2c.set_default_bus(1) 
bme280.setup()
data = bme280.read_all()

Instead I would expect the following minimal script, which would make it honor Python unspoken standards (cf. import statistics):

import bme280

bme280.setup() # or bme280.setup(0x76, 1)
data = bme280.read_all()

This avoids exposing the i2c class, so that once a SPI class becomes available as a backend, it'll be easier to switch.

kbrownlees commented 7 months ago

Released as 0.7. Unfortunately I no longer have this setup so I am unable to test it, please let me know if it doesn't work for some reason.