LamaPLC: CJMCU-3901/PMW-3901 compact optical flow sensor module/IC by PixArt with SPI communication

CJMCU-3901/PMW3901 compact optical flow sensor module/IC by PixArt with SPI communication The CJMCU-3901 is a compact optical flow sensor module that integrates the PixArt PMW3901 chip. It is mainly designed for X-Y motion detection and precise positioning in drones and robotics, particularly in indoor or GPS-denied settings.

Key Technical Specifications

  • Sensor: PixArt PMW3901MB-TXQT.
  • Operating Voltage: 1.8V to 3.6V (typically used at 3.3V).
  • Operating Range: 80mm to infinity (no lens adjustment required).
  • Interface: 4-wire SPI (up to 2MHz).
  • Power Consumption: Very low, typically less than 9mA in active mode.
  • Field of View (FOV): Approximately 40°.

If you'd like to support the development of the site with the price of a coffee — or a few — please do so here.

Here's a handy tip: you can quickly save this page as a PDF by clicking “export to PDF” in the menu on the right side of the screen.

2026/02/14 22:38

CJMCU-3901 pinout

CJMCU-3901/PMW3901 compact optical flow sensor module/IC by PixArt with SPI communication

Pin NameFunctionDescription
3V3Power SupplyTypically 3.3V (range: 1.8V – 3.6V)
GNDGroundConnect to the common ground of your system
MOSSPI Data InMaster Out Slave In; receives commands from the controller
CLKSPI ClockSerial clock signal generated by the master
MISSPI Data OutMaster In Slave Out; sends motion data to the controller
CSChip SelectActive-low signal to enable the sensor for communication
RSTResetOptional active-low hardware reset pin
MOTInterruptMotion detection output; triggers when new motion is detected
VREreference voltage outputIt provides access to the sensor's internal regulated voltage, which is used as a reference for its internal optoelectronic operations

Connection Requirements

  • Logic Levels: This sensor uses 3.3V logic. If you are using a 5V microcontroller, such as an Arduino Uno, you must use a level shifter to prevent damage to the chip.
  • SPI Speed: The module supports SPI clock speeds up to 2 MHz.
  • Orientation: Look for a small notch or arrow on the board; this usually indicates the “back” or “front” to ensure correct X-Y coordinate tracking in your firmware.

Arduino wiring

Since the CJMCU-3901 operates on 3.3V logic, you must use a 3.3V Arduino (e.g., Nano 33 IoT) or a level shifter if using a 5V Arduino (e.g., Uno).

CJMCU-3901 PinArduino Pin (Uno/Nano)Function
VCC3.3VPower Supply
GNDGNDGround
CSD10 (or any Digital Pin)Chip Select
MOSID11SPI Data In
MISOD12SPI Data Out
SCLKD13SPI Clock

Arduino code

Need to install the Bitcraze_PMW3901 library via the Arduino Library Manager.

#include "Bitcraze_PMW3901.h"
 
// Using digital pin 10 for chip select
Bitcraze_PMW3901 flow(10);
 
void setup() {
  Serial.begin(9600);
 
  // Initialize the sensor
  if (!flow.begin()) {
    Serial.println("Initialization of the flow sensor failed");
    while(1); // Halt if sensor not found
  }
}
 
int16_t deltaX, deltaY;
 
void loop() {
  // Get motion count since the last call
  flow.readMotionCount(&deltaX, &deltaY);
 
  Serial.print("X: ");
  Serial.print(deltaX);
  Serial.print(" | Y: ");
  Serial.println(deltaY);
 
  delay(100); // Small delay for readability
}
Operational Notes

  • Measurement Units: The sensor outputs unitless “ticks” representing the amount of motion.
  • Surface Texture: The sensor requires a textured surface (not solid black or mirrored) to track movement effectively.
  • Focus: The built-in lens is typically pre-focused from 80mm to infinity.

This page has been accessed for: Today: 1, Until now: 26