Example #1
0
 def get_resolutions(self):
     user_reg = self.bus.transaction(
         i2c.writing_bytes(self.ADDR, self.CMD_READ_USER_REG),
         i2c.reading(self.ADDR, 1),
     )
     user_reg_int = int.from_bytes(user_reg[0], byteorder="big")
     return self.RESOLUTIONS[user_reg_int >> 6, user_reg_int & 0x1]
Example #2
0
    def get_temp(self):
        self.bus.transaction(i2c.writing_bytes(self.ADDR, self.CMD_READ_TEMP_NOHOLD))
        time.sleep(self.temp_timing)
        results = self.bus.transaction(i2c.reading(self.ADDR, 3))

        raw_reading = results[0]
        if self.debug:
            print(binascii.hexlify(raw_reading))

        raw_temp = int.from_bytes(raw_reading, byteorder="big")
        self.check_crc(raw_temp)
        return -46.85 + (175.72 * ((raw_temp >> 8) / float(2**16)))
Example #3
0
    def get_rel_humidity(self):
        self.bus.transaction(i2c.writing_bytes(self.ADDR, self.CMD_READ_HUM_NOHOLD))
        time.sleep(self.rh_timing)
        results = self.bus.transaction(i2c.reading(self.ADDR, 3))

        raw_reading = results[0]
        if self.debug:
            print(binascii.hexlify(raw_reading))

        raw_hum = int.from_bytes(raw_reading, byteorder="big")
        self.check_crc(raw_hum)
        return -6 + (125 * ((raw_hum >> 8) / float(2**16)))