Optical flow sensor(PMW3901) does ot output the data it should

I wanted an optical sensor which will give me X,Y positions for indoor moving cart. the cart is at the same level so the position from the floor will always be the same. I have Arduino Uno, with it I bought this sensor cjmcu 3901 (based on pmw3901 sensor) from AliExpress

CJMCU 3901 Optical Current Sensor PMW3901 XY Translation Optical Flow Sensor for Accurate Lateral (x & y) Velocity Measurement|Replacement Parts & Accessories| - AliExpress.

the sensor came with small lens. i remove the tape on the optical eye and attached the lens to it.
I connect it according to te SPI and seems that the connections are fine but the output data is not correct. the sensor output delta x & y from the last read, and when i move the cart slowly , i always get delta x & y = 0.

i tried diffferent surfaces but still no change. i got changes in the delta x & y when i put some colorful surface(like magazine cover) and move it quickly. maybe this sensor is not quite good? i know that it's range limitations is from 8cm to infinity. what am i doing wrong?

i used the simple code below to get the data:

#include "PMW3901.h"

// Using digital pin 10 for chip select
PMW3901 flow(10);

void setup() {

  if (!flow.begin()) {
    Serial.println("Initialization of the flow sensor failed");
    while(1) { }

int16_t deltaX,deltaY;

void loop() {
  // Get motion count since last call
  flow.readMotionCount(&deltaX, &deltaY);

  Serial.print("X: ");
  Serial.print(", Y: ");


Moved your topic to it's current location as it is more suitable.

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

These sensors require a sharp focus to see texture detail, you've moved the lens? Is it in focus?

I just installed the lens on the sensor(there were no istructions whatsoever).
I am attaching two images of the sensor - with and without the lens.

can you explain how i know the sensor is focused?

without lens.gif