bme280-python
bme280-python copied to clipboard
Binho Nova adapter instructions
Not submitting this as a PR to the documentation as I'm not confident in it at all, but wanted to capture this atrocity I've just cooked up, to read a BME280 via the Binho Nova host adapter's Python library:
class BinhoSmbusShim:
def __init__(self, host_adapter):
self.binho = host_adapter
def read_i2c_block_data(self, i2c_address, register, length):
return self.binho.i2c.transfer(i2c_address, [register], length)
def write_i2c_block_data(self, i2c_address, register, values):
self.binho.i2c.transfer(i2c_address, [register] + values, 0)
Usage instructions:
binho = binhoHostAdapter()
binho.operationMode = "I2C"
bme280 = BME280(i2c_dev=BinhoSmbusShim(binho))
bme280.setup()
# you can now follow examples/
Fairly confident this glosses over a lot of details (like register width?), but this was enough to get temperature/humidity/pressure out of the sensor so I can carry on with software.
I'm also aware you're no longer stocking Binho Nova, so no worries if you don't want to add in support/documentation for use — this note is just to capture this info in the public domain for next time I need it 🙈
I'm surprised their libraries don't just shim common i2c interface libraries. This looks pretty reasonable, though, and I will leave it here for posterity. Thank you.