Package: pisht30
# InstallingStable library from PyPi:Just runpip install pisht30# PiSht30’s Methods## Constructor(config={})‘config’ is dictionary type.### ‘address’Configure I2C address of SHT30.Address.LOW.valueI2C address is 0x44DefaultAddress.HIGH.valueI2C address is 0x45### ‘mode’Configure measurement mode of SHT30.Mode.SINGLE_SHOT_CLOCK_STRETCH_OFF_LOW.valueSingle Shot Data Acquisition ModeClock stretching : DisabledRepeatability : LowDefaultMode.SINGLE_SHOT_CLOCK_STRETCH_OFF_MIDDLE.valueSingle Shot Data Acquisition ModeClock stretching : DisabledRepeatability : MiddleMode.SINGLE_SHOT_CLOCK_STRETCH_OFF_HIGH.valueSingle Shot Data Acquisition ModeClock stretching : DisabledRepeatability : HighMode.SINGLE_SHOT_CLOCK_STRETCH_ON_LOW.valueSingle Shot Data Acquisition ModeClock stretching : EnabledRepeatability : LowMode.SINGLE_SHOT_CLOCK_STRETCH_ON_MIDDLE.valueSingle Shot Data Acquisition ModeClock stretching : EnabledRepeatability : MiddleMode.SINGLE_SHOT_CLOCK_STRETCH_ON_HIGH.valueSingle Shot Data Acquisition ModeClock stretching : EnabledRepeatability : HighMode.PERIODIC_MPS_0_5_LOW.valuePeriodic Data Acquisition ModeMeasurements per second: 0.5Repeatability : LowMode.PERIODIC_MPS_0_5_MIDDLE.valuePeriodic Data Acquisition ModeMeasurements per second: 0.5Repeatability : MiddleMode.PERIODIC_MPS_0_5_HIGH.valuePeriodic Data Acquisition ModeMeasurements per second: 0.5Repeatability : HighMode.PERIODIC_MPS_1_0_LOW.valuePeriodic Data Acquisition ModeMeasurements per second: 1Repeatability : LowMode.PERIODIC_MPS_1_0_MIDDLE.valuePeriodic Data Acquisition ModeMeasurements per second: 1Repeatability : MiddleMode.PERIODIC_MPS_1_0_HIGH.valuePeriodic Data Acquisition ModeMeasurements per second: 1Repeatability : HighMode.PERIODIC_MPS_2_0_LOW.valuePeriodic Data Acquisition ModeMeasurements per second: 2Repeatability : LowMode.PERIODIC_MPS_2_0_MIDDLE.valuePeriodic Data Acquisition ModeMeasurements per second: 2Repeatability : MiddleMode.PERIODIC_MPS_2_0_HIGH.valuePeriodic Data Acquisition ModeMeasurements per second: 2Repeatability : HighMode.PERIODIC_MPS_4_0_LOW.valuePeriodic Data Acquisition ModeMeasurements per second: 4Repeatability : LowMode.PERIODIC_MPS_4_0_MIDDLE.valuePeriodic Data Acquisition ModeMeasurements per second: 4Repeatability : MiddleMode.PERIODIC_MPS_4_0_HIGH.valuePeriodic Data Acquisition ModeMeasurements per second: 4Repeatability : HighMode.PERIODIC_MPS_10_0_LOW.valuePeriodic Data Acquisition ModeMeasurements per second: 10Repeatability : LowMode.PERIODIC_MPS_10_0_MIDDLE.valuePeriodic Data Acquisition ModeMeasurements per second: 10Repeatability : MiddleMode.PERIODIC_MPS_10_0_HIGH.valuePeriodic Data Acquisition ModeMeasurements per second: 10Repeatability : High## read()Read temperature and humidity.
Return value is dictionary type.### ‘temperature’OKType: floatCelsius temperature value [℃]NGType: False### ‘humidity’OKType: floatRelative humidity value [%]NGType: False# SampleRunsudo pigpiodbefore running the sample.## Simple# -*- coding: utf-8 -*-importpisht30asSHT30importtimeobj=SHT30.PiSht30()try:whileTrue:value=obj.read()if(isinstance(value['temperature'],float)):print(round(value['temperature'],2))if(isinstance(value['humidity'],float)):print(round(value['humidity'],2))time.sleep(10)exceptKeyboardInterrupt:pass## Modify config‘address’ is HIGH and ‘mode’ is PERIODIC_MPS_1_0_HIGH.# -*- coding: utf-8 -*-importpisht30asSHT30importtimeconfig={'address':SHT30.Address.HIGH.value.'mode':SHT30.Mode.PERIODIC_MPS_1_0_HIGH.value}obj=SHT30.PiSht30(config)try:whileTrue:value=obj.read()if(isinstance(value['temperature'],float)):print(round(value['temperature'],2))if(isinstance(value['humidity'],float)):print(round(value['humidity'],2))time.sleep(10)exceptKeyboardInterrupt:pass