I'm completely new to this platform. I've just tested my NodeMCU if it can read sensor data or not. I've used DHT11 Humidity and Temperature sensor for this. After uploading the following basic code to my NodeMCU board, it shows 0 values for both Temperature and Humidity.
#include "DHT.h"
#define DHTTYPE DHT11
#define dht_dpin 2
DHT dht(dht_dpin, DHTTYPE);
void setup(void) {
dht.begin();
Serial.begin(9600);
Serial.println("humidity and Temperature/n/n");
delay(700);
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print("H = ");
Serial.print(h);
Serial.print("% ");
Serial.print("T = ");
Serial.print(t);
Serial.println("C ");
delay(800);
}
I've uploaded the same code for Arduino Uno and it shows values for Temperature and Humidity.
Do I have to conclude that my board is not working? Or is there any other way to fix this?
Please Help me out!
Thank you!
(and sorry for my bad english)