DeanG
June 17, 2019, 7:21pm
1
so my DHT11 shows a constant 0 on the temp and humidity i really dont know what to do (Im a beginner) Also the text on the lcd screen is in white boxes dont know why
Here's the code
#include <dht.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
dht DHT;
#define DHT11_PIN 7
void setup(){
Serial.begin(9600);
lcd.begin(16, 2);
}
void loop()
{
int sz = DHT.read11(DHT11_PIN);
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(DHT.temperature);
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Humidity: ");
lcd.print(DHT.humidity);
lcd.print("%");
delay(1000);
Serial.print("Temperature = ");
Serial.println(DHT.temperature);
Serial.print("Humidity = ");
Serial.println(DHT.humidity);
delay(1000);
}
everything was taken from here
http://www.circuitbasics.com/how-to-set-up-the-dht11-humidity-sensor-on-an-arduino/
LarryD
June 17, 2019, 7:31pm
2
Show us a good schematic of your circuit.
Show us a good image of your wiring. <———<<<<
Give links to components.
Posting images:
https://forum.arduino.cc/index.php?topic=519037.0
system
June 17, 2019, 7:32pm
3
I would also suggest that you output the values to the Serial Monitor. Lets make sure you are even reading a value.
@OP
Upload the following sketch in your Arduino (UNO/NANO/MEGA) and check that the Serial Monitor shows reasonable values of Temp and Humidity.
#include <dht.h>
dht DHT;
#define DHT11_PIN 7
void setup()
{
Serial.begin(9600);
}
void loop()
{
int sz = DHT.read11(DHT11_PIN);
Serial.print("Temp: ");
Serial.print(DHT.temperature);
Serial.print(" degC");
Serial.print(" ");
//--------------------------
Serial.print("Humidity: ");
Serial.print(DHT.humidity);
Serial.println("%");
delay(1000);
//--------------------------
Serial.println("===========================");
}