diff --git a/keywords.txt b/keywords.txt index 69841fd..41e354d 100644 --- a/keywords.txt +++ b/keywords.txt @@ -25,3 +25,4 @@ get_Humidity KEYWORD2 AM2302_READ_OK LITERAL1 AM2302_ERROR_CHECKSUM LITERAL1 AM2302_ERROR_TIMEOUT LITERAL1 +AM2302_ERROR_READ_FREQ LITERAL1 diff --git a/library.json b/library.json index 7fee38d..e81618e 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "AM2302-Sensor", - "version": "1.3.0", + "version": "1.3.1", "repository": { "type": "git", diff --git a/library.properties b/library.properties index d6ce020..b99b2ca 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=AM2302-Sensor -version=1.3.0 +version=1.3.1 author=Frank Häfele maintainer=Frank Häfele sentence=This library read temperature and humidity from the AM2302 (aka DHT22) senor. diff --git a/src/AM2302-Sensor.cpp b/src/AM2302-Sensor.cpp index f2bcc91..bd6e415 100644 --- a/src/AM2302-Sensor.cpp +++ b/src/AM2302-Sensor.cpp @@ -157,7 +157,7 @@ int8_t AM2302::AM2302_Sensor::read_sensor_data(uint8_t *buffer, uint8_t size) { // count wait for state time while ( !digitalRead(_pin) ) { ++wait_counter; - delayMicroseconds(1.0); + delayMicroseconds(1U); if (wait_counter >= READ_TIMEOUT) { return AM2302_ERROR_TIMEOUT; } diff --git a/src/AM2302-Sensor.h b/src/AM2302-Sensor.h index bf08aea..4f728b7 100644 --- a/src/AM2302-Sensor.h +++ b/src/AM2302-Sensor.h @@ -22,6 +22,8 @@ namespace AM2302 { // define timeout in 100 µs constexpr uint8_t READ_TIMEOUT {100U}; + + // define maximum sensor read frequency in milliseconds (2 s) constexpr uint16_t READ_FREQUENCY {2000U}; class AM2302_Sensor {