Skip to content

Latest commit

 

History

History
125 lines (94 loc) · 5.26 KB

File metadata and controls

125 lines (94 loc) · 5.26 KB

  • I2C interface
  • gesture sensing
  • RGB color sensing
  • ambient light sensing
  • proximity sensing:allows to measure the distance an object is from the front of the sensor(up to a few centimeters)with 8 bit resolution

Overview

  1. APDS9960 wired to Raspberry Pi with I2C
  2. Install Libraries
  3. Using APDS9960 with Adafruit library
  4. Single Page Reference

APDS9960 Raspberry Pi
VIN 3V3
GND GND
SCL SCL
SDA SDA

Raspberry Pi GPIO Pin

  • 3V3:1、17
  • GND:6、9、14、20、25、30、34、39
  • SCL:5
  • SDA:3

Check the I2C devices

  • APDS99600x39
pi@raspberrypi:~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- 39 -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Install Libraries

pip3 install adafruit-circuitpython-apds9960
pip3 install adafruit-circuitpython-busdevice
pip3 install adafruit-circuitpython-register
import time
import board
from adafruit_apds9960.apds9960 import APDS9960
from adafruit_apds9960 import colorutility

i2c = board.I2C()
apds = APDS9960(i2c)
apds.enable_color = True

while True:
    # create some variables to store the color data in

    # wait for color data to be ready
    while not apds.color_data_ready:
        time.sleep(0.005)

    # get the data and print the different channels
    r, g, b, c = apds.color_data
    print("red: ", r)
    print("green: ", g)
    print("blue: ", b)
    print("clear: ", c)

    print("color temp {}".format(colorutility.calculate_color_temperature(r, g, b)))
    print("light lux {}".format(colorutility.calculate_lux(r, g, b)))
    time.sleep(0.5)

Docs

Single Page Reference