Code Issue with DHT11 and Thinger - Noob

Hi There, I’m a bit of a noob to Arduino so apologies if this is simple.

I’m getting the following error codes when compiling code to monitor TEMP/HUM readings on Thinger.io

Error is:

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: “Arduino/Genuino Uno”
In file included from C:\Users\user\Documents\Arduino\libraries\libraries\thinger_trial_1.2\thinger_trial_1.2.ino:2:0:
C:\Users\user\Documents\Arduino\libraries\libraries\libraries\DHT_sensor_library/DHT_U.h:25:29: fatal error: Adafruit_Sensor.h: No such file or directory
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.

Code is:

#include <DHT.h>
#include <DHT_U.h>
#include <SPI.h>
#include <Ethernet.h>
#include <ThingerEthernet.h>

#define USERNAME “haggis77”
#define DEVICE_ID “Arduino”
#define DEVICE_CREDENTIAL “minibeast123”

// thinger.io config
ThingerEthernet thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

// dht config
#define DHTPIN 7
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

void setup() {
dht.begin();

thing[“dht11”] >> (pson& out){
out[“humidity”] = dht.readHumidity();
out[“celsius”] = dht.readTemperature();
out[“fahrenheit”] = dht.readTemperature(true);
};
}

void loop() {
thing.handle();
}

Thanks in advance for any help :slight_smile:

When you see a "No such file or directory" error it almost always means you need to install the library that contains the missing file.

Often the code you're compiling will come with documentation (either a comment or separate document) that tells you where to get the library dependencies.

In other cases the author of the code will not have been so kind and you'll need to go on a hunt for the missing library.

A good place to start is the Arduino IDE's Library Manager:

  • Sketch > Include Library > Manage Libraries...
  • In the "Filter your search..." box, type some keywords you have gleaned from the missing file name.
  • Scroll through the results for the right library. Click on it.
  • Click "Install".
  • Wait for installation to finish.
  • Click "Close".
  • Try compiling your code again.

If you have no luck in Library Manager then load up your favorite search engine and do a search for the missing filename. You will often get multiple results. If you have a lot of results you might add "arduino" as an additional search keyword. I will usually prefer results on github.com since that is where most Arduino libraries are hosted and downloading from there is fast and easy. In some cases there will be multiple libraries that contain the given filename and you'll need to do some evaluation to determine which seems the most appropriate, then try it out. After downloading the library you found you'll need to install it. This requires a different process than the Library Manager installation. You will find instructions here:

Thanks I found the missing library.

Looks like there are some issue with the code however:

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino/Genuino Uno"

Build options changed, rebuilding all
thinger_trial_1.2:18:1: error: 'DHT' does not name a type
DHT dht(DHTPIN, DHTTYPE);
^
C:\Users\user\Documents\Arduino\libraries\libraries\thinger_trial_1.2\thinger_trial_1.2.ino: In function 'void setup()':
thinger_trial_1.2:21:6: error: expected unqualified-id before '.' token
dht.begin();
^
C:\Users\user\Documents\Arduino\libraries\libraries\thinger_trial_1.2\thinger_trial_1.2.ino: In lambda function:
thinger_trial_1.2:24:26: error: expected primary-expression before '.' token
out["humidity"] = dht.readHumidity();
^
thinger_trial_1.2:25:25: error: expected primary-expression before '.' token
out["celsius"] = dht.readTemperature();
^
thinger_trial_1.2:26:28: error: expected primary-expression before '.' token
out["fahrenheit"] = dht.readTemperature(true);
^
exit status 1
'DHT' does not name a type

The code you are using is written for a different DHT library than the library you're using. Please study the examples for the library you are using. You should find them under the File > Examples > DHT sensor library menu.

Thanks, I tried an earlier version of the library and it worked.

Just in case anyone needs this in future with the code the Library is DHT sensor library v 1.2.3 not the latest

Problem solved Cheers

Haggis77:
Thanks, I tried an earlier version of the library and it worked.

Just in case anyone needs this in future with the code the Library is DHT sensor library v 1.2.3 not the latest

Problem solved Cheers

Why would you use an early version of the Library? Please understand that new version are created for a reason.

  1. Bug fixes.
  2. New functionality.
  3. Performance Improvements.

Why not take a few minutes, and examine what you need to do different to use the newer version.