My LCD isnt reading temperature from my DHT11. Can anyone help?

#include<dht.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <LCD.h>

#define I2C_ADDR 0x27
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

dht DHT;

#define DHT11_PIN A0 //define DHT pin

#define dht_apin A0

//======variables
int h;
int t;
int lswo=2;//limit switch 1 window open
int lswc=3;//limit switch 1 window close
int lsbo=4;//limit switch 2 blind open
int lsbc=5;//limit switch 2 blind close
//==========motor driver
int window_p=7;
int window_n=6;

int blind_p=11;
int blind_n=12;
//==================Functions
void DHT11(void);

void window_open(void);
void windw_close(void);

void blind_open();
void blind_close();

void setup() {
// put your setup code here, to run once:
//=============limit switches
pinMode(lswo,INPUT_PULLUP);
pinMode(lswc,INPUT_PULLUP);
pinMode(lsbo,INPUT_PULLUP);
pinMode(lsbc,INPUT_PULLUP);
//-----------------------
//=============motor driver pins
pinMode(window_p,OUTPUT);
pinMode(window_n,OUTPUT);

pinMode(blind_p,OUTPUT);
pinMode(blind_n,OUTPUT);
//----------------------
Serial.begin(9600);
delay(2000);//wait before accessing the sensor
}

void loop() {
// put your main code here, to run repeatedly:
window_open();
blind_open();

while(1)
{
delay(100);
DHT11();
if(h>89)
{
window_close();
}
else
{
if(t>29)
{
window_close();
delay(2000);
blind_close();
}
else
{

window_open();
blind_open();
}
}

}
}

//function definition
void window_open()
{
while(digitalRead(lswo))
{
digitalWrite(window_p,HIGH);
digitalWrite(window_n,LOW);
}
digitalWrite(window_p,LOW);
digitalWrite(window_n,LOW);
}

void window_close()
{
while(digitalRead(lswc))
{
digitalWrite(window_p,LOW);
digitalWrite(window_n,HIGH);
}
digitalWrite(window_p,LOW);
digitalWrite(window_n,LOW);
}
void blind_open()
{
while(digitalRead(lsbo))
{
digitalWrite(blind_p,HIGH);
digitalWrite(blind_n,LOW);
}
digitalWrite(blind_p,LOW);
digitalWrite(blind_n,LOW);
}

void blind_close()
{
while(digitalRead(lsbc))
{
digitalWrite(blind_p,LOW);
digitalWrite(blind_n,HIGH);
}
digitalWrite(blind_p,LOW);
digitalWrite(blind_n,LOW);
}
void DHT11()
{

lcd.clear();
lcd.setCursor(0,0);
int chk = DHT.read11(DHT11_PIN);
lcd.print(“Temp: “);
lcd.print(DHT.temperature);
lcd.print(” C”);
lcd.setCursor(0,1);
lcd.print(“Hum: “);
lcd.print(DHT.humidity);
lcd.print(” %”);
delay(1000);
}

Double-check your wiring, code, and installed libraries with this Arduino DHT11 LCD tutorial

I suggest that you read https://forum.arduino.cc/index.php?topic=148850.0 and pay specific attention to point #7 about posting code using code tags; next edit your post and apply what you read.

Next I suggest that you start very simple and leave the LCD out and test using serial monitor.

Lastly, using pins 0 and 1 is usually not a good idea when you also use Serial; maybe it works if you remove the call to Serial.begin().

sterretje:
Next I suggest that you start very simple and leave the LCD out and test using serial monitor.

Lastly, using pins 0 and 1 is usually not a good idea when you also use Serial; maybe it works if you remove the call to Serial.begin().

He isn't using Arduino pins #0 and #1 :wink:
The 0 and 1 are for the pin mappings for the PCF8574 output port pins.

The bigger question is what is the real issue?
From the title I have no idea what is happening / not happening since the LCD doesn't read anything from the DHT11

Is the issue that reading from the DHT11 is not working
or is the issue that the LCD isn't working or displaying anything?
or is the issue that the LCD is working but not displaying the expected values?

There isn't enough information about the issue to be able to comment about it.

--- bill

Thanks for the correction.

hi fancysushii

my impression is that the sketch is created to close the window if temp > 29 and/or to close the blind when humidity > 89 per cent

what I do not understand is in void DHT11()

here it instructs:

int chk = DHT.read11(DHT11_PIN);

shouldn't this be:
int chk = DHT.read(DHT11_PIN);
??

I assume that your lcd does not show any temerature or humidity at all (nor woukld serial Monitor if you send the DHT data to that service). No data from the DHT11