1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-22 18:48:14 +00:00

DHT platform now supports modules with inbuilt external resistor (#8257)

This commit is contained in:
Ali Jafri 2025-02-17 03:35:54 +05:30 committed by Jesse Hills
parent e89603fe3b
commit 9ee5227fe0
No known key found for this signature in database
GPG Key ID: BEAAE804EFD8E83A
2 changed files with 3 additions and 2 deletions

View File

@ -23,6 +23,7 @@ void DHT::dump_config() {
} else {
ESP_LOGCONFIG(TAG, " Model: DHT22 (or equivalent)");
}
ESP_LOGCONFIG(TAG, " Internal Pull-up: %s", ONOFF(this->pin_->get_flags() & gpio::FLAG_PULLUP));
LOG_UPDATE_INTERVAL(this);
@ -101,7 +102,7 @@ bool HOT IRAM_ATTR DHT::read_sensor_(float *temperature, float *humidity, bool r
} else {
delayMicroseconds(800);
}
this->pin_->pin_mode(gpio::FLAG_INPUT | gpio::FLAG_PULLUP);
this->pin_->pin_mode(this->pin_->get_flags());
{
InterruptLock lock;

View File

@ -34,7 +34,7 @@ DHT = dht_ns.class_("DHT", cg.PollingComponent)
CONFIG_SCHEMA = cv.Schema(
{
cv.GenerateID(): cv.declare_id(DHT),
cv.Required(CONF_PIN): pins.internal_gpio_input_pin_schema,
cv.Required(CONF_PIN): pins.internal_gpio_input_pullup_pin_schema,
cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
unit_of_measurement=UNIT_CELSIUS,
accuracy_decimals=1,