add AM2120 device type (#6115)

This commit is contained in:
alexbuit 2024-01-19 03:50:00 +01:00 committed by GitHub
parent 1fef769496
commit 6561746f97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 1 deletions

View file

@ -91,7 +91,7 @@ bool HOT IRAM_ATTR DHT::read_sensor_(float *temperature, float *humidity, bool r
delayMicroseconds(40); delayMicroseconds(40);
} else if (this->model_ == DHT_MODEL_DHT22_TYPE2) { } else if (this->model_ == DHT_MODEL_DHT22_TYPE2) {
delayMicroseconds(2000); delayMicroseconds(2000);
} else if (this->model_ == DHT_MODEL_AM2302) { } else if (this->model_ == DHT_MODEL_AM2120 || this->model_ == DHT_MODEL_AM2302) {
delayMicroseconds(1000); delayMicroseconds(1000);
} else { } else {
delayMicroseconds(800); delayMicroseconds(800);

View file

@ -11,6 +11,7 @@ enum DHTModel {
DHT_MODEL_AUTO_DETECT = 0, DHT_MODEL_AUTO_DETECT = 0,
DHT_MODEL_DHT11, DHT_MODEL_DHT11,
DHT_MODEL_DHT22, DHT_MODEL_DHT22,
DHT_MODEL_AM2120,
DHT_MODEL_AM2302, DHT_MODEL_AM2302,
DHT_MODEL_RHT03, DHT_MODEL_RHT03,
DHT_MODEL_SI7021, DHT_MODEL_SI7021,
@ -27,6 +28,7 @@ class DHT : public PollingComponent {
* - DHT_MODEL_AUTO_DETECT (default) * - DHT_MODEL_AUTO_DETECT (default)
* - DHT_MODEL_DHT11 * - DHT_MODEL_DHT11
* - DHT_MODEL_DHT22 * - DHT_MODEL_DHT22
* - DHT_MODEL_AM2120
* - DHT_MODEL_AM2302 * - DHT_MODEL_AM2302
* - DHT_MODEL_RHT03 * - DHT_MODEL_RHT03
* - DHT_MODEL_SI7021 * - DHT_MODEL_SI7021

View file

@ -23,6 +23,7 @@ DHT_MODELS = {
"AUTO_DETECT": DHTModel.DHT_MODEL_AUTO_DETECT, "AUTO_DETECT": DHTModel.DHT_MODEL_AUTO_DETECT,
"DHT11": DHTModel.DHT_MODEL_DHT11, "DHT11": DHTModel.DHT_MODEL_DHT11,
"DHT22": DHTModel.DHT_MODEL_DHT22, "DHT22": DHTModel.DHT_MODEL_DHT22,
"AM2120": DHTModel.DHT_MODEL_AM2120,
"AM2302": DHTModel.DHT_MODEL_AM2302, "AM2302": DHTModel.DHT_MODEL_AM2302,
"RHT03": DHTModel.DHT_MODEL_RHT03, "RHT03": DHTModel.DHT_MODEL_RHT03,
"SI7021": DHTModel.DHT_MODEL_SI7021, "SI7021": DHTModel.DHT_MODEL_SI7021,