from machine import I2C, Pin,ADC
import esp8266_i2c_lcd as esp8266_lcd
from time import sleep
adc32 = ADC(Pin(32))
adc32.atten(ADC.ATTN_11DB)
adc32.width(ADC.WIDTH_10BIT)
i2c = I2C(0)
lcd = esp8266_lcd.I2cLcd(i2c, esp8266_lcd.DEFAULT_I2C_ADDR, 2, 16)
lcd.clear()
output=dict(zip(range(330),["Direct sunlight"]*13+["Deep twilight"]*55+["Overcast day"]*
91+["Office lighting"]*165+["Stairway lighting"]*204+["Computer minitor"]*
275+["Twilight"]*318+["Deep twilight"]*327+["Full moon"]))
while True:
lcd.move_to(0,0)
adc_value = adc32.read()
volts = (3.3*adc_value)/1023
lcd.putstr("ADCvalue: %d" % (adc_value))
lcd.move_to(0,1)
lcd.putstr("volts: %.2f" % (volts) )
print("output {}".format(output[int(volts*100)]),end="\r")