LCD does not print Temp/Humidity Value

Hello, I am a beginner Arduino user with standard C++/C programming and circuitry knowledge.

[SENSORS/PRODUCTS I AM USING]
Sensors:

  • LCD 16x2
  • DHT11 Temperature & Humidity Sensor
  • HC-SR04 Ultrasonic Sensor
  • A random LED bulb pin
    Products:
  • Arduino UNO
  • Breadboard

[THE PROJECT]
I am using both the Ultrasonic and DHT sensor.

  1. The Ultrasonic sensor will make my LED light up if the object is more than 10cm away and will print the distance and its active status onto the serial monitor (this is mainly for checking/troubleshooting purposes)
  2. The DHT sensor’s Temperature and Humidity values are to be printed onto my 16x2 LCD screen and will print its active status onto the serial monitor (this is mainly for checking/troubleshooting purposes).

[THE PROBLEM]
I am having an issue with printing out the Temperature and Humidity values onto my LCD screen when I combine its codes into one main program that also contains the Ultrasonic sensor’s codes.
I am using 2 separate functions for each sensor (to “run” them) and calling them inside the void loop().
When I compiled and uploaded the individual codes into the Arduino UNO, each sensor worked fine on its own, and the LCD could print the Humidity and Temperature values perfectly.
However, after combining these 2 sensors’ codes together into a single program, the LCD is no longer able to print the Humidity and Temperature values, but prints “UUUUUUUUUUUUUU” instead.
And, though I am having an issue with printing out the Humidity and Temperature values onto the 16x2 LCD, when I run and upload the full program with the Ultrasonic, LED, DHT sensor, and the LCD screen’s codes together, all the other sensors and outputs work perfectly and my DHT sensor is also able to read the Humidity and Temperature (this is all checked via the serial monitor).
I am only having the sole issue with being unable to print the Humidity and Temperature values onto my 16x2 LCD.

My codes by themselves are correct, the sensors run perfectly and I get the exact results intended.
My circuit(s) is also correct because I have tried out these sensors individually and, as mentioned, have gotten the intended results.
For the program below, I have connected the Ultrasonic and LED bulb onto my breadboard, while the 16x2 LCD and DHT sensor only have attachments to the breadboard for 5V and Ground purposes. The other pins required are connected straight onto my Arduino UNO.

Is there any way I can solve this? Thank you in advance.

[THE CODES/PROGRAM]

//1. DHT_LCD Definitions and Libraries
#include <LiquidCrystal.h>
#include <dht.h>
dht DHT;
#define DHT11_PIN 6
// LCD pins connected are RS, E, D4, D5, D6, D7. 
//Separately, VCC connected to 5V on breadboard and RW connected to GROUND.
LiquidCrystal lcd(0, 1, 2, 3, 4, 5);


//2. ULTRASONIC_LED Echo, Trig and LED Declarations
const int echo = 8;
const int trig = 9;
const int LED1 = 7;
long duration = 0;
int distance = 0;

// Setup
void setup()
{
  //1.DHT_LCD SETUP
  lcd.begin(16, 2);
  
  //2.ULTRASONIC_LED SETUP
  pinMode(trig, OUTPUT);
  pinMode (echo, INPUT);
  pinMode (LED1, OUTPUT);
  Serial.begin(9600);
}


void loop()
{
  
// Declare "dht" as float; just using this to call the DHT function and to print on serial monitor
  float dht = 0.0;
  dht = dhtloop();
  Serial.print("\t\tACTIVE: DHTLCD\n");

// Declare "ultra" as float; just using this to call the Ultrasonic-LED function and to print on serial monitor
  int ultra = 0;
  ultra = ultraloop();
  Serial.print("ACTIVE: ULTRASONIC\n");
}


//DHT sensor loop to print the Humidity & Temperature values on the 16x2 LCD and serial monitor
float dhtloop ()
{
  int chk = DHT.read11(DHT11_PIN);
  lcd.setCursor(0,0);
  lcd.print("Temperature:");
  lcd.println(DHT.temperature);
  lcd.print(" C");
  lcd.setCursor(1,1);
  lcd.print("Humidity :");
  lcd.println (DHT.humidity);
  lcd.print(" %");
  Serial.print("\t\tTemperature = ");
  Serial.println(DHT.temperature);
  Serial.print("\t\tHumidity = ");
  Serial.println(DHT.humidity);
  delay (500);
}

// Loop for ultrasonic sensor. If object is 10cm or more away, the LED bulb will light up.
int ultraloop()
{
  //2.ULTRA_LED LOOP
  digitalWrite (trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig, LOW);
  duration = pulseIn(echo, HIGH);
  distance = (duration/2) / 28.5;
  Serial.print("Distance is: ");
  Serial.println(distance);  
  if (distance>10)
  { 
    digitalWrite (LED1, HIGH);
    delay (3000);
  }
  else
  {
    digitalWrite (LED1, LOW);
  }


}

LiquidCrystal lcd(0, 1, 2, 3, 4, 5);

will not work together with Serial which will also occupy 0 and 1.

Hello, thank you for your reply.
I have just removed all of the Serial.print lines in my program.
However, though the LCD no longer prints “UUUUUUUUUUU”, it is still unable to print the Temperature and Humidity values.
Is there anything else I could change?

[THE PROGRAM WITH NO Serial.print]

//1. DHT_LCD
#include <LiquidCrystal.h>
#include <dht.h>
dht DHT;
#define DHT11_PIN 6
LiquidCrystal lcd(0, 1, 2, 3, 4, 5);


//2. ULTRA_LED
const int echo = 8;
const int trig = 9;
const int LED1 = 7;
long duration = 0;
int distance = 0;

//3. WATER_5V_BUZZ

//4. TILT_7


void setup()
{
  //1.DHT_LCD SETUP
  lcd.begin(16, 2);
  
  //2.ULTRA_LED SETUP
  
  pinMode(trig, OUTPUT);
  pinMode (echo, INPUT);
  pinMode (LED1, OUTPUT);
  Serial.begin(9600);

  //3.WATER_5V_BUZZ SETUP

  //4. TILT_7 SETUP
}


void loop()
{
  float dht = 0.0;
  dht = dhtloop();
 

  int ultra = 0;
  ultra = ultraloop();
  
  
  //3.WATER_5V_BUZZ LOOP

  //4. TILT_7 LOOP
}


float dhtloop ()
{
  //1.DHT_LCD LOOP
  int chk = DHT.read11(DHT11_PIN);
  lcd.setCursor(0,0);
  lcd.print("Temperature:");
  lcd.println(DHT.temperature);
  lcd.setCursor(1,1);
  lcd.print("Humidity :");
  lcd.println (DHT.humidity);
  delay (500);
}

int ultraloop()
{
  //2.ULTRA_LED LOOP
  digitalWrite (trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig, LOW);
  duration = pulseIn(echo, HIGH);
  distance = (duration/2) / 28.5;
    
  if (distance>10)
  { 
    digitalWrite (LED1, HIGH);
    delay (3000);
  }
  else
  {
    digitalWrite (LED1, LOW);
  }
}

Get rid of serial.begin.

wildbill:
Get rid of serial.begin.

This has solved my issues! Along with the advice from the first reply! ;D
Deeply appreciate the help from you both so much, I am very grateful!