iam using the dht sensor example
but i cant send any thing to hte serial moniter
also when i test it say dht test failed
i have this problem in every code
plz hellp
the code is down
So the code, can you post it so others can see it and perhaps find the issue?
You'd want to post your well formatted code in code tags.
Also what type of MCU are you using?
And could you post a schematic and an image of your setup?
this is the code
#include "DHT.h"
#define DHTPIN 53
//#define DHTTYPE DHT11
#define DHTTYPE DHT22
//#define DHTTYPE DHT21
char receivedChar;
boolean newData = true;
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println(F("DHTxx test!"));
dht.begin();
}
void loop() {
uint8_t i;
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
float hif = dht.computeHeatIndex(f, h);
float hic = dht.computeHeatIndex(t, h, false);
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
Serial.print(f);
Serial.print(F("°F Heat index: "));
Serial.print(hic);
Serial.print(F("°C "));
Serial.print(hif);
Serial.println(F("°F"));
}
its a normal dht example
Which Core Debug level are you using?
What baud rate have you selected?
You mean you get this message: Serial.println(F("Failed to read from DHT sensor!"));?
first quatiopn i dont know what that is
9600
yes
Try using
#define DHTPIN 2 // Digital pin connected to the DHT sensor
instead of 53 and connect the DHT sensor to pin2
and also add to the top of setup()
void setup() {
Serial.begin(9600);
for (int i = 10; i > 0; i--) {
Serial.print(' '); Serial.print(i);
delay(500);
}
Serial.println();
Serial.println(F("DHTxx test!"));
Then see if you monitor shows the count down and DHTxx test!
if not you need to fix that first.
after that you can look at the dht connection
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.