I2C drivers for the lux sensor

The drivers are available from the GitHub repository for the Sensorian hardware (https://github.com/sensorian/sensorian-firmware.git). Let's clone the repository from the command-line terminal:

    git clone https://github.com/sensorian/sensorian-firmware.git 

Let's make use of the drivers (which is available in the  ~/sensorian-firmware/Drivers_Python/APDS-9300 folder) to read the values from the two ADC channels of the sensor:

import time 
import APDS9300 as LuxSens
import sys

AmbientLight = LuxSens.APDS9300()
while True:
time.sleep(1)
channel1 = AmbientLight.readChannel(1)
channel2 = AmbientLight.readChannel(0)
Lux = AmbientLight.getLuxLevel(channel1,channel2)
print("Lux output: %d." % Lux)

With the ADC values available from both the channel, the ambient light value can be calculated by the driver using the following formula (retrieved from the sensor datasheet):

Ambient light levels calculated using the ADC values

This calculation is performed by the attribute getLuxLevel. Under normal lighting conditions, the ambient light level (measured in lux) was around 2. The measured output was 0 when we covered the lux sensor with the palm. This sensor could be used to measure ambient light and adjust the room lighting accordingly.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.23.130