To use SHT30 with pigpio
Project description
# Installing
Stable library from PyPi:
Just run pip install pisht30
# PiSht30’s Methods
## Constructor(config={})
‘config’ is dictionary type.
### ‘address’
Configure I2C address of SHT30.
- Address.LOW.value
I2C address is 0x44
Default
- Address.HIGH.value
I2C address is 0x45
### ‘mode’
Configure measurement mode of SHT30.
- Mode.SINGLE_SHOT_CLOCK_STRETCH_OFF_LOW.value
Single Shot Data Acquisition Mode
Clock stretching : Disabled
Repeatability : Low
Default
- Mode.SINGLE_SHOT_CLOCK_STRETCH_OFF_MIDDLE.value
Single Shot Data Acquisition Mode
Clock stretching : Disabled
Repeatability : Middle
- Mode.SINGLE_SHOT_CLOCK_STRETCH_OFF_HIGH.value
Single Shot Data Acquisition Mode
Clock stretching : Disabled
Repeatability : High
- Mode.SINGLE_SHOT_CLOCK_STRETCH_ON_LOW.value
Single Shot Data Acquisition Mode
Clock stretching : Enabled
Repeatability : Low
- Mode.SINGLE_SHOT_CLOCK_STRETCH_ON_MIDDLE.value
Single Shot Data Acquisition Mode
Clock stretching : Enabled
Repeatability : Middle
- Mode.SINGLE_SHOT_CLOCK_STRETCH_ON_HIGH.value
Single Shot Data Acquisition Mode
Clock stretching : Enabled
Repeatability : High
- Mode.PERIODIC_MPS_0_5_LOW.value
Periodic Data Acquisition Mode
Measurements per second: 0.5
Repeatability : Low
- Mode.PERIODIC_MPS_0_5_MIDDLE.value
Periodic Data Acquisition Mode
Measurements per second: 0.5
Repeatability : Middle
- Mode.PERIODIC_MPS_0_5_HIGH.value
Periodic Data Acquisition Mode
Measurements per second: 0.5
Repeatability : High
- Mode.PERIODIC_MPS_1_0_LOW.value
Periodic Data Acquisition Mode
Measurements per second: 1
Repeatability : Low
- Mode.PERIODIC_MPS_1_0_MIDDLE.value
Periodic Data Acquisition Mode
Measurements per second: 1
Repeatability : Middle
- Mode.PERIODIC_MPS_1_0_HIGH.value
Periodic Data Acquisition Mode
Measurements per second: 1
Repeatability : High
- Mode.PERIODIC_MPS_2_0_LOW.value
Periodic Data Acquisition Mode
Measurements per second: 2
Repeatability : Low
- Mode.PERIODIC_MPS_2_0_MIDDLE.value
Periodic Data Acquisition Mode
Measurements per second: 2
Repeatability : Middle
- Mode.PERIODIC_MPS_2_0_HIGH.value
Periodic Data Acquisition Mode
Measurements per second: 2
Repeatability : High
- Mode.PERIODIC_MPS_4_0_LOW.value
Periodic Data Acquisition Mode
Measurements per second: 4
Repeatability : Low
- Mode.PERIODIC_MPS_4_0_MIDDLE.value
Periodic Data Acquisition Mode
Measurements per second: 4
Repeatability : Middle
- Mode.PERIODIC_MPS_4_0_HIGH.value
Periodic Data Acquisition Mode
Measurements per second: 4
Repeatability : High
- Mode.PERIODIC_MPS_10_0_LOW.value
Periodic Data Acquisition Mode
Measurements per second: 10
Repeatability : Low
- Mode.PERIODIC_MPS_10_0_MIDDLE.value
Periodic Data Acquisition Mode
Measurements per second: 10
Repeatability : Middle
- Mode.PERIODIC_MPS_10_0_HIGH.value
Periodic Data Acquisition Mode
Measurements per second: 10
Repeatability : High
## read()
Read temperature and humidity. Return value is dictionary type.
### ‘temperature’
- OK
Type: float
Celsius temperature value [℃]
- NG
Type: False
### ‘humidity’
- OK
Type: float
Relative humidity value [%]
- NG
Type: False
# Sample
Run sudo pigpiod before running the sample.
## Simple
# -*- coding: utf-8 -*-
import pisht30 as SHT30
import time
obj = SHT30.PiSht30()
try:
while True:
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)
except KeyboardInterrupt:
pass
## Modify config
‘address’ is HIGH and ‘mode’ is PERIODIC_MPS_1_0_HIGH.
# -*- coding: utf-8 -*-
import pisht30 as SHT30
import time
config = {
'address' : SHT30.Address.HIGH.value.
'mode' : SHT30.Mode.PERIODIC_MPS_1_0_HIGH.value
}
obj = SHT30.PiSht30(config)
try:
while True:
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)
except KeyboardInterrupt:
pass
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pisht30-1.0.0.tar.gz
.
File metadata
- Download URL: pisht30-1.0.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2df28c838bdb790f94bf45f1b828f78f09bca15a66ab573748cc329e6cf3e7cc |
|
MD5 | 26478ff7db9e4520632d55907b09a9ac |
|
BLAKE2b-256 | 5372f06e36dbbfefd34e7223b4feeca28e5a04d997c4d59de8941ee1b57a74eb |
File details
Details for the file pisht30-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: pisht30-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b7e77e5293168eeda84a77a5749e1d5c69ecff64850d5a3d2fb54823edc9c39 |
|
MD5 | d25b236e14744e6500ad6eca80c80a02 |
|
BLAKE2b-256 | 50f9f29b1d6176f4373d55afba6e6800fca88d1093cdb3c502d2c54bb4c37a33 |