zephyr/drivers/sensor/aosong/dht/dht.h
John Shelton 3b2103f5f7 sensor: dht: Fix multi-instance type handling
The DHT driver incorrectly assumes all sensor instances are the same
type as the first instance (dht@0). The data parsing logic uses a
hardcoded check of the devicetree property for instance 0, which
causes incorrect readings when different sensor models (e.g., DHT11
and DHT22) are used together.

This change stores the model type in each per-instance config struct
during initialization. The data parsing logic is updated to use this
per-instance flag, ensuring each sensor is handled correctly
according to its specific model.

Signed-off-by: John Shelton <moosery@gmail.com>
2025-06-18 17:48:58 -04:00

25 lines
474 B
C

/*
* Copyright (c) 2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_DRIVERS_SENSOR_DHT_DHT_H_
#define ZEPHYR_DRIVERS_SENSOR_DHT_DHT_H_
#include <zephyr/device.h>
#define DHT_START_SIGNAL_DURATION 18000
#define DHT_SIGNAL_MAX_WAIT_DURATION 100
#define DHT_DATA_BITS_NUM 40
struct dht_data {
uint8_t sample[4];
};
struct dht_config {
struct gpio_dt_spec dio_gpio;
bool is_dht22; /* true for DHT22, false for DHT11 */
};
#endif