#include <DHTesp.h>
int dp = 18;
int t1 = 14;
int e1 = 27;
DHTesp ds;
TempAndHumidity th;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
ds.setup(dp,DHTesp::DHT22);
pinMode(t1, OUTPUT);
pinMode(e1, INPUT);
Serial.println("Hello, ESP32!");
}
void loop() {
// put your main code here, to run repeatedly:
th = ds.getTempAndHumidity();
Serial.println("Humidity : "+String(th.humidity,1));
Serial.println("Temperature : "+String(th.temperature,2));
digitalWrite(t1, HIGH);
delay(500);
digitalWrite(t1, LOW);
int input = pulseIn(e1,HIGH);
int output = input*0.034/2;
Serial.println(output);
delay(10); // this speeds up the simulation
}