Skip to content

[Bug] DHT.h : Incorrect COUNT value for Arduino Uno R3 (16 MHz) causes sensor communication failure #27

@SNT-RABELAIS

Description

@SNT-RABELAIS

The latest version of the Grove_Temperature_And_Humidity_Sensor library (via DHT.h) does not work correctly with an Arduino Uno R3 (16 MHz). The DHT11 sensor fails to return valid data, which appears to be caused by an incorrect COUNT macro value for 16 MHz microcontrollers.

The latest version of the Grove_Temperature_And_Humidity_Sensor library (via DHT.h) does not work correctly with an Arduino Uno R3 (16 MHz). The DHT11 sensor fails to return valid data, which appears to be caused by an incorrect COUNT macro value for 16 MHz microcontrollers.

The DHT11 sensor should work correctly with an Arduino Uno R3, as it did with previous versions of the library.

Actual Behavior:
Communication with the sensor consistently fails.

Root Cause :
In the DHT.h file, the COUNT value for 16 MHz microcontrollers is set to 2 (line 17):
#elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000L)
#define COUNT 2
This value is incorrect for the Arduino Uno R3. In previous versions of the library, COUNT was set to 6 for 16 MHz, which allowed proper operation.

Proposed fix:
Change the COUNT value for 16 MHz microcontrollers in DHT.h:
#elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000L)
#define COUNT 6

Additional Information:
The previous version of the library (with COUNT = 6 for 16 MHz) works correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions