Chouffy / python_sensor_aht20

Standalone I2C driver for AHT20 sensor written in Python
The Unlicense
19 stars 5 forks source link

Suggestion to change fixed SMBus bus address. #2

Closed PedanticAvenger closed 2 years ago

PedanticAvenger commented 2 years ago

Lots of SBCs out there are NOT bus 1 for the default I2C bus. Can I suggest changing:

def __init__(self):
    # Initialize AHT20
    self.cmd_soft_reset()

to

def __init__(self, I2CBusNum=1):
    # Initialize AHT20
    self.I2CBusNum = I2CBusNum
    self.cmd_soft_reset()

and all SMBus(1) to SMBus(self.I2CBusNum) ? That should maintain backwards compatibility for anyone using this module and flexibility for people using boards like the Rock Pi 4

Chouffy commented 2 years ago

Hi @PedanticAvenger , thanks for your idea! I've made the necessary changes in a separate branch: https://github.com/Chouffy/python_sensor_aht20/tree/change-fixed-SMBus-bus-address

I don't have access to the AHT20 at the moment, could you please check it on your side and tell me if it's OK so I can merge this?

PedanticAvenger commented 2 years ago

It seems to work great. Thanks!