from machine import I2C, Pin, ADC
import esp8266_i2c_lcd as esp8266_lcd
from time import sleep
#declaring ADC
adc32 = ADC(Pin(32))
adc32.atten(ADC.ATTN_11DB)
adc32.width(ADC.WIDTH_10BIT)
i2c = I2C(0) # creating an object Using hardware I2C channel 0
lcd = esp8266_lcd.I2cLcd(i2c, esp8266_lcd.DEFAULT_I2C_ADDR, 2, 16)#declare an variable making use of esp8266_lcd module
lcd.clear()#clear memory just in case there was data stored in
row = dict(zip(range(1016),["'Direct sunlight'"] *39+["'Full daylight'"]*131+["'Overcast day'"] *111+["'Office lighting'"] *341+["'Stairway lighting'"]*121+["'Computer monitor'"]*221+["'Twilight'"]*132+["'Deep Twilight'"]*30+["'Full moon'"] ))
while True:
Analogue = adc32.read()
volts = (3.3* Analogue)/1023
if Analogue>=1015:
Analogue =1015
lcd.move_to(0,0)#starting point when placing an object or variable
lcd.putstr("ADCvalue: %s" %(row[adc32.read()]))
lcd.move_to(0,1)
lcd.putstr("Voltage: %0.2f" %(volts))
sleep(1)
#input_voltage = "The raw analogue is {} and condition is {}"
#print(input_voltage.format(val,row[val]),end = "\r")