DHT Library Problems

Alright, so after my first Arduino Project ended with shorting my board, i decided to go for something simpler and replicated this
along with loading the suggested DHT Library. However now that i try verifying it, it just wont compile and throws this error:

C:\Users\vcds\AppData\Local\Temp\ccPbNIjY.ltrans0.ltrans.o: In function `setup':
C:\Users\vcds\AppData\Local\Temp\.arduinoIDE-unsaved2022925-10572-caygf3.scu1\sketch_oct25a/sketch_oct25a.ino:16: undefined reference to `DHT::begin(unsigned char)'
C:\Users\vcds\AppData\Local\Temp\ccPbNIjY.ltrans0.ltrans.o: In function `loop':
C:\Users\vcds\AppData\Local\Temp\.arduinoIDE-unsaved2022925-10572-caygf3.scu1\sketch_oct25a/sketch_oct25a.ino:28: undefined reference to `DHT::readHumidity(bool)'
C:\Users\vcds\AppData\Local\Temp\.arduinoIDE-unsaved2022925-10572-caygf3.scu1\sketch_oct25a/sketch_oct25a.ino:30: undefined reference to `DHT::readTemperature(bool, bool)'
C:\Users\vcds\AppData\Local\Temp\ccPbNIjY.ltrans0.ltrans.o: In function `__static_initialization_and_destruction_0':
C:\Users\vcds\AppData\Local\Temp\.arduinoIDE-unsaved2022925-10572-caygf3.scu1\sketch_oct25a/sketch_oct25a.ino:11: undefined reference to `DHT::DHT(unsigned char, unsigned char, unsigned char)'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

I'm just getting started at this kinda stuff, as previously i've only used full Software on my RPi's with only minor Software tweaks and Hardware installation necessary, so i hope someone here can help me troubleshoot this stuff

It looks like you are using a library that the code was not written for. There are many libraries for the DHTxx sensors. It may be a challenge to find the one that matches your code.

I would suggest that you try the example code that came with the library that you have installed.

Otherwise, post a link to where you got the library. Post a link to where you got that code. Post the code that generates those errors. Please read the forum guidelines to see how to properly post code and some information on making a good post.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Please post a diagram of your wiring. Hand drawn, photographed and posted is fine. Include all pin names/numbers, components, their part numbers and/or values and power supplies.

Hey,
thanks for the fast reply. the DHT Example code failed in the same way, and after tweaking the Unified DHT Tester to use the corret path, it also failed with the same error message. the code used, build and Lirary link can be fount in the original Hyperlink, but I'll include it here.

Project: https://create.arduino.cc/projecthub/ThothLoki/portable-arduino-temp-humidity-sensor-with-lcd-a750f4?ref=platform&ref_id=424_trending_part__&offset=4

DHT Library: GitHub - adafruit/DHT-sensor-library: Arduino library for DHT11, DHT22, etc Temperature & Humidity Sensors (this one was included with the original Project, so it should technically be compatible with the code)

the code itself:

// include the library code:
#include <LiquidCrystal.h>
#include "C:\Users\vcds\Desktop\DHT Library\DHT.h"

// set the DHT Pin
#define DHTPIN 8

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  dht.begin();
  
  // Print a message to the LCD.
  lcd.print("Temp:  Humidity:");
}

void loop() {
  delay(500);
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // read humidity
  float h = dht.readHumidity();
  //read temperature in Fahrenheit
  float f = dht.readTemperature(true);

  if (isnan(h) || isnan(f)) {
    lcd.print("ERROR");
    return;
  }

  lcd.print(f);
  lcd.setCursor(7,1);
  lcd.print(h);  
}

Hardware changes i made:
1.Skipped button for constant connection
2. skipped potentiometer for constant 10k Ohm connection
3. 4 Pin DHT Sensor on a 3 Pin Breakout board

Software changes i made:
included the correct filepath for DHT.h

However so far i dont even get to the point of testing my Hardware, as the Software isn't even running yet

There is a certain folder in which the IDE expects to find any libraries. Use the IDE library manager to install any library and the library will be installed in the right place.

image

alright. seems like i installed the right Library, as now it compiles and uploads. LCD is not showing anything, but i'll try figure that one out next

Is that the contrast on the LCD? Try just grounding pin 3 of the LCD (V0) or use a resistor of 470 or 1K to ground. 10K is way too much.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.