Ejemplo n.º 1
0
 def get_humidity(self):
     """Reads the humidity from the sensor. This call blocks
     for 250ms to allow the sensor to return the data"""
     self.transaction(
         writing_bytes(self._I2C_ADDRESS,
                       self._CMD_HUMIDITY_NO_HOLD))
     time.sleep(0.250)
     data = self.transaction(reading(self._I2C_ADDRESS, 3))[0]
     if _calculate_checksum(data, 2) != data[2]:
         raise ChecksumFailedError("Humidity checksum failed.")
     else:
         return _get_humidity_from_buffer(data)
Ejemplo n.º 2
0
 def get_temperature(self):
     """Reads the temperature from the sensor. This call blocks
     for 250ms to allow the sensor to return the data.
     """
     self.transaction(
         writing_bytes(self._I2C_ADDRESS,
                       self._CMD_TEMPERATURE_NO_HOLD))
     time.sleep(0.250)
     data = self.transaction(reading(self._I2C_ADDRESS, 3))[0]
     if _calculate_checksum(data, 2) != data[2]:
         raise ChecksumFailedError("Temperature checksum failed.")
     else:
         return _get_temperature_from_buffer(data)