LamaPLC: CJMCU-3216 / AP-3216 integrated digital ambient light and proximity sensor module/IC with I²C communication

CJMCU-3216 / AP-3216 integrated digital ambient light and proximity sensor module/IC with I2C communication The AP-3216 (commonly found on the CJMCU-3216 module) is an integrated digital ambient light sensor and proximity sensor with a built-in infrared (IR) LED, communicating via an I²C interface. It is designed for applications such as mobile devices and smart home systems to manage screen brightness and detect nearby objects.

Key Features and Specifications

  • Chip: AP3216C
  • Interface: I²C (Fast Mode, up to 400kHz), default I²C address: 0x1E
  • Operating Voltage: 2.8V to 3.8V DC (Note: the module typically has no internal voltage regulator, so do not use 5V directly).
  • Operating Temperature: -30°C to +80°C.

Ambient Light Sensor (ALS)

  • Output: 16-bit effective linear output (0 to 65535).
  • Dynamic Range: Four user-selectable ranges are available: 365, 1460, 5840, and 23360 lux.
  • Features: Includes anti-flicker rejection (for 50/60Hz sources) and high sensitivity for use behind darkened glass.

Proximity Sensor (PS)

  • Output: 10-bit effective linear output (0 to 1023).
  • Features: Incorporates high ambient light suppression, cross-talk compensation, and programmable IR LED current control to handle low-reflective objects like black hair.

Module Pinout

CJMCU-3216 / AP-3216 integrated digital ambient light and proximity sensor module/IC with I2C communication The CJMCU-3216 module is typically a 6-pin board:

PinDescription
VCCPower supply input (2.8V-3.8V)
GNDGround connection
SCLI²C Clock line
SDAI²C Data line
VLUsed to turn on the integrated IR LED on the module
INTInterrupt pin to improve system efficiency

Arduino wiring

CJMCU-3216 PinArduino Pin (Uno/Nano)Notes
VCC3.3VDo not use 5V; the chip may be damaged
GNDGNDCommon ground
SCLA5I²C Clock
SDAA4I²C Data
VLED3.3V (via resistor)Powers the IR LED; use a ~330Ω resistor for protection

Arduino code

Install the AP3216_WE library via the Arduino Library Manager (Tools > Manage Libraries).

#include <Wire.h>
#include <AP3216_WE.h>
 
AP3216_WE myAP3216 = AP3216_WE();
 
void setup() {
  Serial.begin(9600);
  Wire.begin();
 
  if (!myAP3216.init()) {
    Serial.println("AP3216 not found!");
    while (1);
  }
 
  // Set mode to Ambient Light and Proximity Sensor continuous
  myAP3216.setMode(AP3216_ALS_PS); 
  delay(200); 
}
 
void loop() {
  float als = myAP3216.getAmbientLight(); // Light in Lux
  unsigned int prox = myAP3216.getProximity(); // Proximity value (0-1023)
 
  Serial.print("Lux: ");
  Serial.print(als);
  Serial.print(" | Proximity: ");
  Serial.println(prox);
 
  delay(500);
}

This page has been accessed for: Today: 2, Until now: 2