Reference
APDS9960
Gesture, proximity, RGB color sensor.
- Connects over
- I²C
- Address
- 0x39
- Made by
- Avago / Broadcom
- Datasheet
- docs.broadcom.com
Use it
hardware {
device apds9960: APDS9960
}
every 1s {
let value: int = apds9960.proximity()
log("apds9960", "proximity={value}")
}
On its own, the declaration puts the APDS9960 on the first I²C bus (SDA 21, SCL 22 on the ESP32) at 0x39. To choose the pins or the address, declare the bus and attach the device: device apds9960: APDS9960 on i2c0 at 0x39 with i2c i2c0(sda: 21, scl: 22).
Methods
-
apds9960.proximity() -> int
Proximity value 0-255
-
apds9960.red() -> int
Red channel
-
apds9960.green() -> int
Green channel
-
apds9960.blue() -> int
Blue channel
Wiring
| Pin | Connect to |
|---|---|
VCC | 3.3V ONLY — 5V damages the chip |
GND | Ground |
SDA | Pull-up to 3.3V |
SCL | Pull-up to 3.3V |
INT | Optional interrupt — falls when threshold crossed |
Specifications
- Voltage
- 2.4V – 3.6V (NOT 5V tolerant)
- Current
- 1 μA sleep, 38 μA active
- Modes
- Proximity, Gesture, RGB color, Ambient light
- Proximity range
- 0–100 mm
- Interface speed
- I²C up to 400 kHz
Tips
- Use a level shifter on SDA/SCL if your MCU is 5V — chip is 3.3V only.
- Gesture engine needs a few ms of training; expect noisy first reads.
- Sun or strong IR sources confuse the gesture detector.
Alternatives worth knowing:
- VL53L0X: Time-of-flight, true distance up to 2 m, no ambient/color.