APDS-9960 Light Sensor
This documentation includes installation guidelines and sample code for your hardware.
Overall Info
The Broadcom APDS-9960 multifunctional sensor is capable of ambient light and RGB light sensing, proximity sensing, and gesture detection.
Sensor Connections
SCL: D12.
SDA: D11.
INT: D7.
POWER: 5V, VCC (+3.3V) and GND.
Specifications
APDS-9960's technical specifications are as follows:
IR LED Peak Wavelength: 950nm.
IR LED Spectrum Width: 30nm.
UV and IR Blocking filters.
32 Dataset storage FIFO for gesture sensing.
Arduino Library
Turta_ALSGesture_Sensor library is responsible for reading sensor data.
To use the library on Arduino IDE, add the following #include statement to the top of your sketch.
Then, create an instance of the Turta_ALSGesture_Sensor class.
Now you're ready to access the library by calling the als instance.
Initialization
To initialize the module, call the begin method.
This method configures the I2C bus and INT pin to read sensor data.
Basic Members
Read Ambient Light
Returns the ambient light value.
Parameters
None
Returns
Int: Ambient light value
Read Ambient and RGB Light
Returns the ambient and RGB light.
Parameters
Int: a out
Int: r out
Int: g out
Int: b out
Returns
None
Read Proximity
Returns the raw proximity value.
Parameters
None
Returns
Short: Proximity value
Examples
You can open the examples from Arduino IDE > File > Examples > Examples from Custom Libraries > Turta MKR Sensor Shield > ALS Gesture Sensor. There are two examples of this sensor.
ARGB
This application demonstrates reading ambient light and RGB light values from the sensor.
To run the example:
Open the ARGB sketch from the examples menu.
Select your Arduino MKR series board from the Tools > Board menu.
Select your device's COM port from Tools > Port menu.
Open Serial Monitor from Tools > Serial Monitor.
Select 115.200 baud from the Serial Monitor's status bar.
Upload the code to your device.
Sample Code
Result
After the application is uploaded to the device, it writes ambient light and RGB light values to the Serial Monitor. The example output should be like this:
The application runs forever until you clear it from memory.
Proximity
This application demonstrates reading proximity data from the sensor.
To run the example:
Open the Proximity sketch from the examples menu.
Select your Arduino MKR series board from the Tools > Board menu.
Select your device's COM port from Tools > Port menu.
Open Serial Monitor from Tools > Serial Monitor.
Select 115.200 baud from the Serial Monitor's status bar.
Upload the code to your device.
Sample Code
Result
After the application is uploaded to the device, it writes proximity data to the Serial Monitor. The example output should be like this:
The application runs forever until you clear it from memory.
Troubleshooting
If you're experiencing difficulties while working with your device, please try the following steps.
Problem: When running with battery, proximity and gesture detection functions does not work. Cause: APDS-9960's LED power input requires a high amount of current to operate. Therefore the LED driver is connected to the 5V output of Arduino for proper operation. When you're using a battery, Arduino does not power the 5V output, so the LEDs does not lit. Solution: The proximity and gesture detection functionality does not work with battery power to protect Arduino from Voltage spikes. It is not a malfunction.
Last updated