const float GAMMA = 0.7;
const float RL10 = 50;

void setup() {
  
  Serial.begin(115200);
  Serial.println("Hello, ESP32!");
  pinMode(12, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  // These constants should match the photoresistor's "gamma" and "rl10" attributes

// Convert the analog value into lux value:
  
  int analogValue = analogRead(33);
  Serial.println(analogValue);
  float voltage = float(analogValue) / 4095.0 * 3.3;
   float i = ((3.3 - voltage) / 10000); 
   float resistance = voltage*10000.0/(3.3 - voltage);
   Serial.println(resistance);
 
   float lux = pow(RL10 * 1e3 * pow(10.0, GAMMA) / resistance, (1.0 / GAMMA));
   if(isfinite(lux))
   {
    Serial.print("The brightness is ");
    Serial.print(lux);
    Serial.println(" lx");
   }
   else
   {
     Serial.println("Too bright to measure");
   }
  delay(300); 
}