chickenhouse/gate_guard/light_sensor.py
Thomas Klaehn 4646c7d7a6 project: reorder
Signed-off-by: Thomas Klaehn <thomas.klaehn@u-blox.com>
2018-08-27 11:26:31 +02:00

17 lines
415 B
Python

'''
Created on Mar 30, 2017
@author: tkla
'''
import smbus
class LightSensor(object):
def __init__(self, bus = 1, addr = 0x23):
self.__i2c_device = bus
self.__i2c_addr = addr
self.__i2c_device = smbus.SMBus(self.__i2c_device)
def read(self):
data = self.__i2c_device.read_i2c_block_data(self.__i2c_addr, 0x10)
return int(round((data[0] * 256 + data[1]) / 1.2, 0))