nodmcu V3 (Lolin) DHT11 #1
#include “DHT.h”
#define DHTPIN D4 // ขา Out ของ Sensor ต่อเข้าขา D4 ของ Esp8266
#define DHTTYPE DHT11 // DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
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(“Current humidity = “);
Serial.print(h);
Serial.print(“% “);
Serial.print(“temperature = “);
Serial.print(t);
Serial.println(“C “);
delay(800);
}
credit:https://roboindia.com/tutorials/DHT11-NodeMCU-arduino