-
Notifications
You must be signed in to change notification settings - Fork 0
Installation Light sensor apds9301
Connecting To The Ports Before we get into the configuration and software examples, lets locate the pins used by each of these interfaces. If you’re directly connecting to the pins on the Pi, they’re a little disorganized. I2C.1 is near one end, while SPI and I2C.0 are in the middle of the header. If you’re connecting to these pins, be sure to count carefully.
SPI on Pi Configuration The I2C peripheral is not turned on by default. To enable it, do the following.
- Run sudo raspi-config.
- Use the down arrow to select 9 Advanced Options
- Arrow down to A7 I2C.
- Select yes when it asks you to enable I2C,
- Also select yes when it asks about automatically loading the kernel module.
- Use the right arrow to select the button.
- Select yes when it asks to reboot.
Raspi-config for i2c
The system will reboot.
APDS 9301
Avago APDS-9301 ambient light photosensor with I2C interface. The address for this sensor is 0x29 and default Lux value is 500 Example Python code to use APDS-9301 is available at apds9301.py in our github project.
Create a file testApds9301.py and write the next code import apds9301 luxes = 0 try: light = apds9301.adps9300() luxes = light.read_lux() print luxes except: print "notligth"
sudo ./ testApds9301.py
If your sensor and assembly is ok, you should get back ligth in luxes from the sensor/s.
NOTE:
If you see "notligth", then try again few times.
If still nothing, re-check that you typed in the right GPIO.
If gpio is for sure right, check your assembly again. E.g. Apds9301 gets power, ground and i2c bus is connected correctly.
If nothing from above works, it is always possible that your APDS9301 is broken. :(