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)
The CJMCU-3216 module is typically a 6-pin board:
| Pin | Description |
|---|---|
| VCC | Power supply input (2.8V-3.8V) |
| GND | Ground connection |
| SCL | I²C Clock line |
| SDA | I²C Data line |
| VL | Used to turn on the integrated IR LED on the module |
| INT | Interrupt pin to improve system efficiency |
| CJMCU-3216 Pin | Arduino Pin (Uno/Nano) | Notes |
|---|---|---|
| VCC | 3.3V | Do not use 5V; the chip may be damaged |
| GND | GND | Common ground |
| SCL | A5 | I²C Clock |
| SDA | A4 | I²C Data |
| VLED | 3.3V (via resistor) | Powers the IR LED; use a ~330Ω resistor for protection |
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