def __init__(self, name, addr, i2c_helper, config={}): I2CSensor.__init__(self, name, i2c_helper) max_current = float(config['max_current']) if 'max_current' in config else None self.device = ina219.INA219(0.1, address=addr, max_expected_amps=max_current) self.device.configure() self.device.sleep() self.readData()
def __init__(self, name, addr, i2c_helper, config={}): #pylint: disable=dangerous-default-value I2CSensor.__init__(self, name, i2c_helper) max_current = float(config['max_current']) if 'max_current' in config else None self.device = ina219.INA219(0.1, address=addr, max_expected_amps=max_current, busnum=i2c_helper.get_i2c_busnum()) self.device.configure() self.device.sleep() self.readData()
def discover(config, i2c_helper, *args, **kwargs): sensors = [] supported_bme280_addrs = [0x76, 0x77] for addr in supported_bme280_addrs: url = I2CSensor.url(addr) sensor_config = config.get(url, {}) name = sensor_config.get('name', url) try: sensors.append(BME280Sensor(name, addr, i2c_helper)) logger.info("BME280 found at address {0}".format(addr)) except IOError: logger.info("No BME280 at address {0}".format(addr)) return sensors
def discover(config, i2c_helper, *args, **kwargs): sensors = [] supported_ina219_addrs = [0x40, 0x41, 0x44, 0x45] for addr in supported_ina219_addrs: url = I2CSensor.url(addr) sensor_config = config.get(url, {}) name = sensor_config.get('name', url) try: sensors.append(INA219Sensor(name, addr, i2c_helper, sensor_config)) logger.info("INA219 found at address {0}".format(addr)) except IOError: logger.info("No INA219 at address {0}".format(addr)) return sensors
def discover(idxOffset, config, *args, **kwargs): if 'i2c_helper' not in kwargs: return [] sensors = [] i2c_helper = kwargs['i2c_helper'] supported_bme280_addrs = [0x76, 0x77] for addr in supported_bme280_addrs: url = I2CSensor.url(addr) sensor_config = config.get(url, {}) name = sensor_config.get('name', url) try: sensors.append(BME280Sensor(name, addr, i2c_helper)) print "BME280 found at address {0}".format(addr) except IOError: print "No BME280 at address {0}".format(addr) return sensors
def discover(config, *args, **kwargs): if 'i2c_helper' not in kwargs: return [] sensors = [] i2c_helper = kwargs['i2c_helper'] supported_ina219_addrs = [0x40, 0x41, 0x44, 0x45] for addr in supported_ina219_addrs: url = I2CSensor.url(addr) sensor_config = config.get(url, {}) name = sensor_config.get('name', url) try: sensors.append(INA219Sensor(name, addr, i2c_helper, sensor_config)) print "INA219 found at address {0}".format(addr) except IOError: print "No INA219 at address {0}".format(addr) return sensors
def __init__(self, name, addr, i2c_helper): I2CSensor.__init__(self, name, i2c_helper) self.address = addr self.readData()