from machine import ADC, Pin
import time
import math
GAMMA = 0.7
RL10 = 33
V_in = 3.3 # ESP32 operates at 3.3V
R_fixed = 2000 # Fixed resistor value (2kΩ)
ldr = ADC(Pin(2))
while True:
dig_value = ldr.read()
print(dig_value )
voltage = dig_value * (3.3 / 4095)
print(voltage)
resistance = R_fixed * voltage / (1 - voltage / V_in)
lux = math.pow((RL10 * 1e3 * math.pow(10, GAMMA) / resistance), (1 / GAMMA))
print("Lux value:", lux)
time.sleep(.5)