DHT20 and DHT22 problem

I'm trying to compile example sketches for the accelerometer in the Arduino Sensor Kit. Both my installation of the Arduino IDE (newest) and the Web based compiler give the same error. What's going on here?
The error:

c:\Users\johan\Documents\Arduino\libraries\Arduino_Sensorkit\src\Arduino_SensorKit.cpp:6:21: error: 'DHT20' was not declared in this scope
 DHT Environment_I2C(DHT20);
                     ^~~~~
c:\Users\johan\Documents\Arduino\libraries\Arduino_Sensorkit\src\Arduino_SensorKit.cpp:6:21: note: suggested alternative: 'DHT22'
 DHT Environment_I2C(DHT20);
                     ^~~~~
                     DHT22
Multiple libraries were found for "DHT.h"
  Used: C:\Users\johan\Documents\Arduino\libraries\DHT_sensor_library
  Not used: C:\Users\johan\Documents\Arduino\libraries\Grove_Temperature_And_Humidity_Sensor
exit status 1

Compilation error: exit status 1

You have two DHT libraries and the "DHT20" is unknown for those DHT libraries (they are for the DHT11 and DHT22).

Do you really have a DHT20, such as this one: https://www.adafruit.com/product/5183
Adafruit has a library for the AHT20.

I have no idea. DHT20 is not written all over the device, is it?

Hi @Johan_Ha

The "Arduino_Sensorkit" library has a dependency on the "Grove Temperature And Humidity Sensor" library for its DH20 sensor support. This library contains a header file named DHT.h and the "Arduino_Sensorkit" library has an #include directive for that file.

As indicated by this message, you have two libraries installed on your computer which contain the header file DHT.h:

Under these conditions, the Arduino sketch build system must decide which of the two libraries to use. The sophisticated algorithm is usually able to pick the right one, but not always. Unfortunately this is a case where it picked the wrong library of the two.

So you will need to force the Arduino build system to use the correct library. Different techniques are available for doing this with Arduino IDE and Arduino Cloud, so I'll provide separate advice for each:

Arduino IDE

If you aren't using the "DHT sensor library" library in any of your other sketches, the simple solution will be to uninstall it. Once that is done the build system will correctly use the "Grove Temperature And Humidity Sensor" library.

If you aren't sure why the "DHT sensor library" is installed on your computer in the first place, the explanation is probably that older versions of the "Arduino_Sensorkit" library actually had a dependency on the "DHT sensor library" instead of "Grove Temperature And Humidity Sensor". The Arduino IDE Library Manager automatically installs the dependencies of a library along with the library, so previously installing "Arduino_Sensorkit" also installed "DHT sensor library", setting up the very conditions that make it painful to use the latest version of "Arduino_Sensorkit" :person_facepalming:. The "Arduino_Sensorkit" library no longer has a dependency on "DHT sensor library", so uninstalling "DHT sensor library" won't cause any harm.

I'll provide instructions you can follow to uninstall the "DHT sensor library":

  1. Select Sketch > Include Library > Manage Libraries... from the Arduino IDE menus to open the "Library Manager" view in the left side panel.
  2. In the "Filter your search" field, type DHT sensor library
  3. Scroll down through the list of libraries until you see the "DHT sensor library" entry.
  4. Hover the mouse pointer over the "DHT sensor library" entry.
  5. You will see a ●●● icon appear near the top right corner of the library entry. Click on that icon.
    A context menu will open.
  6. Select "Remove" from the context menu.
    An "Uninstall" dialog will open.
  7. Click the "YES" button in the "Uninstall" dialog to confirm that you want to uninstall the library.
  8. Wait for the uninstall process to finish.

Arduino Cloud

Every one of the thousands of libraries in the Arduino Library Manager are pre-installed in Arduino Cloud. Since the "DHT sensor library" is in Library Manager, this means the problematic conditions are in place in Arduino Cloud from the start.

Library Manager libraries are installed for all users in Arduino Cloud, so the technique of uninstalling the unused problematic library is not available to us there as it was when using Arduino IDE. So a different technique is used in this case:

  1. If it is not already open, select "Libraries" from the menu on the left side of the "Arduino Web Editor" window to open the Libraries panel.
  2. Click the "LIBRARY MANAGER" button in the Libraries panel.
  3. Type Grove Temperature And Humidity Sensor in the "SEARCH LIBRARY" field.
  4. If it is not already favorited, click the icon ("Favorite Library") at the right of the "Grove Temperature And Humidity Sensor" library entry in the search results.
  5. Click the "DONE" button.
  6. Select the "FAVORITES" tab from the libraries side panel.
  7. Find the "Grove Temperature And Humidity Sensor" library entry in the favorites list.
  8. Hover the mouse pointer over the "Grove Temperature And Humidity Sensor" library entry.
    You will see a downward pointing triangle icon appear to the right of the library name.
  9. Click the downward pointing triangle icon.
    A context menu will open.
  10. Select "Download Library" from the menu from the context menu.
    A download of the library will start.
  11. Wait for the download to finish.
  12. Click the upward pointing arrow button ("Import") to the right side of the "Library Manager" button.
  13. If you get a popup about importing your sketchbook, click the "Import" button.
    A dialog will open that allows you to select a file on your computer to import to your Arduino Cloud account.
  14. Select the "ZIP" file that was downloaded to your computer by the previous step.
  15. Click the "Open" button.
  16. Wait for Arduino Web Editor to display the notification that the library was successfully imported.
  17. Click the "OK" button.

The libraries you import to your Arduino Cloud account are given higher priority by the Arduino sketch build system, so now when you compile your sketch you will find that the "Grove Temperature And Humidity Sensor" library was selected and the error will no longer occur.


Please let me know if you have any questions or problems while following those instructions.

It worked, ptillisch. Thanks. I only did the thing for Arduino IDE.

You are welcome. I'm glad it is working now.

Regards,
Per