gpio.sensor.dht
Platypush documentation
gpio.sensor.dht
- class platypush.plugins.gpio.sensor.dht.GpioSensorDhtPlugin(sensor_type: str, pin: int, retries: int = 5, retry_seconds: int = 2, **kwargs)[source]
Bases:
GpioSensorPlugin
Plugin to interact with a DHT11/DHT22/AM2302 temperature/humidity sensor through GPIO.
Requires:
Adafruit_Python_DHT
(pip install git+https://github.com/adafruit/Adafruit_Python_DHT.git
)
- __init__(sensor_type: str, pin: int, retries: int = 5, retry_seconds: int = 2, **kwargs)[source]
- Parameters:
sensor_type – Type of sensor to be used (supported types: DHT11, DHT22, AM2302).
pin – GPIO PIN where the sensor is connected.
retries – Number of retries in case of failed read (default: 5).
retry_seconds – Number of seconds to wait between retries (default: 2).
- get_measurement() Dict[str, float] [source]
Get data from the sensor.
- Returns:
A mapping with the measured temperature and humidity. Example:
{ "humidity": 30.0, "temperature": 25.5 }
- read(sensor_type: Optional[str] = None, pin: Optional[int] = None, retries: Optional[int] = None, retry_seconds: Optional[int] = None, **__) Dict[str, float] [source]
Read data from the sensor.
- Parameters:
sensor_type – Default
sensor_type
override.pin – Default
pin
override.retries – Default
retries
override.retry_seconds – Default
retry_seconds
override.
- Returns:
A mapping with the measured temperature and humidity. Example:
{ "humidity": 30.0, "temperature": 25.5 }