示例#1
0
   def __init__(self, address=0x18, bus=-1, debug=False):
      self.isDebug = debug
      self.debug("Initialising LIS3DH")

      self.i2c = I2C.Device(address, busnum=bus)
      self.address = address

      try:
         val = self.i2c.readU8(self.REG_WHOAMI)
         if val!=self.DEVICE_ID:
            raise Exception("Device ID incorrect - expected 0x%X, got 0x%X at address 0x%X" % (self.DEVICE_ID, val, self.address))
         self.debug("Successfully connected to LIS3DH at address 0x%X" % (self.address))
      except Exception as e:
         print ("Error establishing connection with LIS3DH")
         print (e)

      # Enable all axis
      self.setAxisStatus(self.AXIS_X, True)
      self.setAxisStatus(self.AXIS_Y, True)
      self.setAxisStatus(self.AXIS_Z, True)

      # Set 400Hz refresh rate
      self.setDataRate(self.DATARATE_400HZ)

      self.setHighResolution()
      self.setBDU()

      self.setRange(self.RANGE_2G)
示例#2
0
    def __init__(self):
        """
		Initializes the accelerometer and magnetomter chip in hybrid mode. Both Accel and mangnetometer functionality are available.
		
		
		param none: 
		:returns: none
		"""
        self._address = FXOS8700CQR1_ADDRESS
        self._device = I2C.Device(self._address, 1)

        #self._device.writeList(CTRL_REG2, [RST_MASK])						#Reset sensor, and wait for reboot to complete

        time.sleep(1)
        self.standbyMode()
        while ((self._device.readU8(CTRL_REG2) & RST_MASK) == True):
            pass
        self._device.write8(M_CTRL_REG1,
                            (HYBRID_ACTIVE | M_OSR2_MASK | M_OSR1_MASK
                             | M_OSR0_MASK))  #OSR=max, Hybrid Mode
        self._device.write8(
            M_CTRL_REG2, M_HYB_AUTOINC_MASK
        )  #Enable Hyb Mode Auto Increments  in order to read all data
        self._device.write8(
            CTRL_REG4,
            INT_EN_DRDY_MASK)  #Enable interrupts for DRDY (TO, Aug 2012)
        self._device.write8(XYZ_DATA_CFG, FULL_SCALE_2G)  #Full Scale of +/-2g
        self._device.write8(
            CTRL_REG1, (HYB_ASLP_RATE_25HZ | HYB_DATA_RATE_50HZ)
        )  #System Output Data Rate of 200Hz (5ms), Sleep Mode Poll Rate of 50Hz (20ms)
    def __init__(self, address=BME680_ADDR, i2c_ch=I2C_CHANNEL):
        """Initialise BME680 sensor instance and verify device presence.
        :param address: i2c address of BME680
        :param i2c_device: Optional SMBus-compatible instance for i2c transport
        """
        BME680Data.__init__(self)

        self.address = address
        self._device = I2C.Device(address, i2c_ch)

        self.chip_id = self._get_regs(BME_CONST.CHIP_ID_ADDR, 1)
        if self.chip_id != BME_CONST.CHIP_ID:
            raise RuntimeError(
                'BME680 Not Found. Invalid CHIP ID: 0x{0:02x}'.format(
                    self.chip_id))

        self.soft_reset()
        self.set_power_mode(BME_CONST.SLEEP_MODE)

        self._get_calibration_data()

        self.set_humidity_oversample(BME_CONST.OS_2X)
        self.set_pressure_oversample(BME_CONST.OS_4X)
        self.set_temperature_oversample(BME_CONST.OS_8X)
        self.set_filter(BME_CONST.FILTER_SIZE_3)
        self.set_gas_status(BME_CONST.ENABLE_GAS_MEAS)
        self.set_temp_offset(0)
        self.get_sensor_data()

        self.set_gas_heater_temperature(320)
        self.set_gas_heater_duration(150)
        self.select_gas_heater_profile(0)
        self.get_sensor_data()
示例#4
0
    def __init__(self, address=SI1145_ADDR, busnum=I2C.get_default_bus()):

        self._logger = logging.getLogger('SI1145')

        # Create I2C device.
        self._device = I2C.Device(address, busnum)

        #reset device
        self._reset()

        # Load calibration values.
        self._load_calibration()
    def __init__(self, address=SI1145_ADDR, i2c_ch=I2C_CHANNEL):

        self._logger = logging.getLogger('SI1145')

        # Create I2C device.
        self._device = I2C.Device(address, i2c_ch)

        # reset device
        self._reset()

        # Load calibration values.
        self._load_calibration()
示例#6
0
	def  __init__(self):
		"""
		Configure sensor for capacitive touch.
		
		
		:param none: 
		:returns: none 
		"""
		self._address = CAP1203ADDR	
		self._logger = logging.getLogger('CAP1203')
		# Create I2C device.
		self._device = I2C.Device(self._address, 1)
		self.Initialize()
示例#7
0
    def __init__(self):
        """
		Initializes I2C bus if not initizalized and configures sensor in active mode.
		
		
		:param none: 
		:returns none:
		"""
        self._address = MPL3115A2_ADDRESS

        self._logger = logging.getLogger('MPL3115A2')
        # Create I2C device.
        self._device = I2C.Device(self._address, 1)
        self.initialize()
示例#8
0
 def __init__(self, address=SI1145_ADDR, busnum=I2C.get_default_bus()):
     self._logger = logging.getLogger('SI1145')
     self._device = I2C.Device(address, busnum)
     self._reset()
     self._load_calibration()