APDS-9960 Light Sensor
This documentation includes installation guidelines and sample code for your hardware.
Python Library
Turta_APDS9960 library is responsible for communicating with the APDS-9960 sensor.
To install the library from the (PyPI) Python Package Index, enter the following command to the console.
Add the following statement to the top of your Python code.
Then, create an instance of the Turta_APDS9960 class.
Now you're ready to access the library by calling the apds9960 instance.
Initialization
The library automatically initializes the required components when its instance is being created, so there is no need to do a manual initialization.
Basic Members
Read Ambient Light
Reads the ambient light value.
Parameters
None
Returns
Int: Ambient light.
Read RGB Light
Reads the RGB light values.
Parameters
None
Returns
Int[]: Red, green and blue light values respectively.
Read Proximity
Reads the proximity value.
Parameters
None
Returns
Int: Proximity value.
Advanced Members
Set Mode
Toggles the sensor modes.
Parameters
Bool ambient_and_rgb_light_enabled: Ambient light and RGB light sense.
Bool proximity_detection_enabled: Proximity detection.
Bool gesture_recognition_enabled: Gesture recognition. (Not implemented.)
Returns
None
Samples
You can copy the example code from https://github.com/Turta-io/IoTHAT/tree/master/Samples/Raspbian/Python address, and then copy it to the Raspberry Pi. There is one example of this library.
APDS9960 Sample App
This application demonstrates ambient light, RGB light, and proximity readings.
To run the example:
Copy the library and sample code to a folder on the Raspberry Pi.
Open terminal, and go to the folder you copied the codes.
Run the sample with the following command:
Sample Code
Result
When you run the sample, it prints ambient light, RGB light and proximity readings to the terminal. The example output should be like this:
To stop the Python script, just press CTRL + C.
Last updated