コード例 #1
0
ファイル: sht21.py プロジェクト: heximcz/rack-monitoring
 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)
コード例 #2
0
ファイル: sht21.py プロジェクト: heximcz/rack-monitoring
 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)
コード例 #3
0
ファイル: sht21.py プロジェクト: heximcz/rack-monitoring
 def reset(self):
     """Resets the SHT12."""
     self.transaction(
         writing_bytes(self._I2C_ADDRESS, self._CMD_SOFTRESET))
     time.sleep(0.050)