meta data for this page
LamaPLC: CJMCU-3216 / AP-3216 integrated digital ambient light and proximity sensor module/IC with I²C 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
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 |
Arduino wiring
| 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 |
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