#include <DHTesp.h>
#define dhtpin 15
#define LDR 36
const float GAMMA=0.7;
const float RL10=50;
DHTesp dhtsensor;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
dhtsensor.setup(dhtpin,DHTesp::DHT22);
Serial.println("Hello, ESP32!");
}
void loop() {
// put your main code here, to run repeatedly:
TempAndHumidity data=dhtsensor.getTempAndHumidity();
Serial.println("Temperature :"+String(data.temperature)+"C");
Serial.println("Humidity :"+String(data.humidity)+"%");
int cahaya=analogRead(LDR);
float voltage=cahaya*5/4095.0;
float resistance=2000*voltage/(1-voltage/5);
float lux=pow(RL10*1e3*pow(10,GAMMA)/resistance,(1/GAMMA));
Serial.println("Intensitas Cahaya :"+String(lux));
delay(1000); // this speeds up the simulation
}