Table of Contents

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

Ambient Light Sensor (ALS)

Proximity Sensor (PS)

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