import smbus class light_sensor: def __init__(self, bus = 1, addr = 0x23): self.bus = bus self.addr = addr self.bus = smbus.SMBus(self.bus) def read(self): data = self.bus.read_i2c_block_data(self.addr, 0x10) lx = int(round((data[0] * 256 + data[1]) / 1.2, 0)) return lx