#include <DHT.h>
#define DHTPIN 4
#define DHTTYPE DHT22 // Định nghĩa loại cảm biến DHT
DHT dht(DHTPIN, DHTTYPE); //Set up cảm biến nhiệt độ
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
dht.begin();
Serial.println("Hello, ESP32!");
Serial.println("suytdeptrai");
}
void loop() {
// put your main code here, to run repeatedly:
delay(2000); // Đợi 2 giây trước khi đọc dữ liệu
float h = dht.readHumidity(); // Đọc độ ẩm từ cảm biến
float t = dht.readTemperature(); // Đọc nhiệt độ từ cảm biến
Serial.println(h);
Serial.println(t);
delay(10); // this speeds up the simulation
}