Problem Displaying DHT11 and pH Sensor to my ST7920 Display

Hi! I need some help here with my code. I'm trying to code DHT11 Sensor, pH Level Sensor and LCD Display (ST7920) for my project the day after tomorrow!

The problem is when I try to compile it, there are too many errors in my code. :frowning:

I use Arduino Uno to build my project. Here is the code:

#include <U8g2lib.h>
#include <U8x8lib.h>

#include "dht.h"
#include "u8g2lib.h"
#define DHT11_PIN 7 // what digital pin we're connected t
#define DHTTYPE DHT11
#define LDR_PIN A3        // The LDR is connected to the analog 3 pin
#define PH_PIN A5
#define GROW_LIGHT 6
#define FOG_PUMP 5
int LightLevel ;
int pH ;
DHT dht (DHT11_PIN, DHTTYPE);                 // These are the instances of DHT11

// Here will be the code for the pattern of the logo 
U8GLIB_ST7920_128X64 u8g(4, 12, 6, U8G_PIN_NONE);

bool first;
float hum = 0.0;
double T = 0.0;
void dht_test (float * humPerc);
void setup (void)  {
  pinMode (GROW_LIGHT, OUTPUT);
  pinMode (FOG_PUMP, OUTPUT);
  digitalWrite (GROW_LIGHT, HIGH);

  // Here is the intro of the LCD Display

  first = true;
  // assign default colour value
U8GLIB_ST7920_128X64 u8g(4, 12, 6, U8G_PIN_NONE);
  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
    u8g.setColorIndex (255);                // WHITE
  }
  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
    u8g.setHiColorIndex (3);                // MAX INTENSITY
  }
  else if ( u8g.getMode() == U8G_MODE_BW ) {
    u8g.setHiColorIndex (1);                // PIXEL ON
  }
  else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
    u8g.setHiColorByRGB (255,255,255);
  }
  
}
void RefreshDisplay(float * humPerc, double *T, int *WL, int *LL, int *pH_value) {
  u8g.setFont(u8g_font_fub11);
  u8g.setFontRefHeightExtendedText();
  u8g.setDefaultForegroundColor();
  u8g.setFontPosTop();
  u8g.drawStr( 4, 0, "Hum%");
  u8g.setPrintPos( 68, 0);
  u8g.print( *humPerc);
  u8g.drawStr( 4, 15, "Temp");
  u8g.setPrintPos( 68, 15);
  u8g.print( *T); 
   u8g.drawStr( 4, 30, "Wlvl");
  
  if (*WL == 0){
     u8g.drawStr (68, 30,"EMPTY!");
     digitalWrite (FOG_PUMP, LOW);
  }
  else{ 
  
    if (*WL < 800)
     u8g.drawStr (68, 30,"LOW");
     else {
      digitalWrite(FOG_PUMP, HIGH);
      u8g.drawStr (68, 30,"HIGH");
     }
     
  }
   if (*LL < 100) {
    u8g.drawStr (68, 45,"Dark");
  } else if (*LL < 200) {
    u8g.drawStr (68, 45,"Dim");
  } else if (*LL < 500) {
    u8g.drawStr (68, 45, "Light");
  } else if (*LL < 800) {
    u8g.drawStr (68, 45,"Bright");
  } else {
    u8g.drawStr (68, 45,"2Bright");
  }
  double voltage = 5.0 / 1024.0 * (*pH_value);
  float Po = 7 + ((2.5 - voltage) / 0.18);
  u8g.drawStr (4, 45,"pH");
  u8g.setPrintPos( 28, 45);
  u8g.print( Po);
  
}
void loop(void) {
LightLevel = analogRead(LDR_PIN);
pH = analogRead (PH_PIN);
char status;
int chk = DHT.read11(DHT11_PIN);
hum = DHT.humidity;
  
dht_test(&hum);
  if(first)
  {
    first = false;
  }
 
 
}
void dht_test(float * humPerc) {
  // Wait a few seconds between measurements.
  delay(1000);
}

Here are the error messages:

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

"C:\\Users\\Acer\\AppData\\Local\\Temp\\arduino_build_467446\\sketch\\Final_code.ino.cpp" -o "C:\\Users\\Acer\\AppData\\Local\\Temp\\arduino_build_467446\\sketch\\Final_code.ino.cpp.o"
Final_code:14:1: error: 'DHT' does not name a type

 DHT dht (DHT11_PIN, DHTTYPE);                 // These are the instances of DHT11

 ^

Final_code:17:1: error: 'U8GLIB_ST7920_128X64' does not name a type

 U8GLIB_ST7920_128X64 u8g(4, 12, 6, U8G_PIN_NONE);

 ^

C:\Users\Acer\AppData\Local\Temp\arduino_modified_sketch_229924\Final_code.ino: In function 'void setup()':

Final_code:32:1: error: 'U8GLIB_ST7920_128X64' was not declared in this scope

 U8GLIB_ST7920_128X64 u8g(4, 12, 6, U8G_PIN_NONE);

 ^

Final_code:33:8: error: 'u8g' was not declared in this scope

   if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {

        ^

Final_code:33:25: error: 'U8G_MODE_R3G3B2' was not declared in this scope

   if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {

                         ^

Final_code:36:30: error: 'U8G_MODE_GRAY2BIT' was not declared in this scope

   else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {

                              ^

Final_code:39:30: error: 'U8G_MODE_BW' was not declared in this scope

   else if ( u8g.getMode() == U8G_MODE_BW ) {

                              ^

Final_code:42:30: error: 'U8G_MODE_HICOLOR' was not declared in this scope

   else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {

                              ^

C:\Users\Acer\AppData\Local\Temp\arduino_modified_sketch_229924\Final_code.ino: In function 'void RefreshDisplay(float*, double*, int*, int*, int*)':

Final_code:48:3: error: 'u8g' was not declared in this scope

   u8g.setFont(u8g_font_fub11);

   ^

Final_code:48:15: error: 'u8g_font_fub11' was not declared in this scope

   u8g.setFont(u8g_font_fub11);

               ^

C:\Users\Acer\AppData\Local\Temp\arduino_modified_sketch_229924\Final_code.ino: In function 'void loop()':

Final_code:96:11: error: 'DHT' was not declared in this scope

 int chk = DHT.read11(DHT11_PIN);

           ^

Using library U8g2 at version 2.26.14 in folder: C:\Users\Acer\Documents\Arduino\libraries\U8g2 
Using library DHT in folder: C:\Users\Acer\Documents\Arduino\libraries\DHT (legacy)
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI 
Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire 
exit status 1
'DHT' does not name a type

There must be a simple solution to these errors. I'm new in learning Arduino. Any help is much appreciated!

Case matters. I get this error

Arduino: 1.8.10 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Alternatives for dht.h: []
ResolveLibrary(dht.h)sketch_feb11a:4:10: error: dht.h: No such file or directory


  -> candidates: [] #include "dht.h"


          ^~~~~~~

compilation terminated.

exit status 1
dht.h: No such file or directory

If you look at the examples, there is a "DHT.h" file

#include "dht.h"

I guess you're using the DHTlib by Rob Tillaart. That library's class is called "dht", not DHT.

Did you install the libraries? The errors indicate that the references libraries are not installed in your IDE. The IDE has a library manager that makes it very easy to install the needed libraries. Have you done that?