Initialization of the optical flow sensor (pmw3901) failed

After connecting pmw3901 to Arduino Uno, running the bitcraze_pmw3901 flow example code will output as a "Initialization of the flow sensor failed"

What's the solution to the problem?

Connection
sensor arduino
mosi -> pin11
sck -> pin13
miso -> pin12
cs -> pin10

You might want to look at this How to get the best out of this forum before you proceed any further.
We only know what you tell us, and without knowing what you have, we don't stand a chance.

In your case we need to see the schematic and your code. Your word salad connection list is missing things, for example there is no mention of ground connections.

1 Like

Welcome! If you wired it Like it appears you did with your list of ??? it will not work. You might want to read up on SPI and how it works. Read the forum guidelines as suggested by @Grumpy_Mike.

Hi. When I run an example of using pmw3901 sensor in Arduino Uno, I keep getting the phrase 'initialization failed'.

Please tell me how to fix pmw3901 initialization failure problem

----Using----
sensor : optical flow sensor breakout pmw3901

Arduino Board : Arduino UNO

Library : Bitcraze_PMW3901 by Bitcraze

Using this example code.

#include "Bitcraze_PMW3901.h"

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

void setup() {
  Serial.begin(9600);

  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(deltaX);
  Serial.print(", Y: ");
  Serial.print(deltaY);
  Serial.print("\n");

  delay(100);
}

The wiring was connected according to the SPI Library documentation, and the picture below is a wiring diagram.

Why did you start a topic in the Uncategorised category of the forum when its description explicitly tells you not to ?

Your topic has been moved to a relevant category. Please be careful in future when deciding where to start new topics

Your wiring looks OK; the initialisation will fail if the chip ID or inverse chip ID can't be read or don't match with the expected numbers.

You can add some Serial prints to the begin() method in the library to see what the numbers are that the begin() method gets back. Expected are 0x49 and 0xB6.

You claimed that the problem was solved in your other post on the same topic
So is it solved or not?

I have merged your cross-posts @sirius.

Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting can result in a suspension from the forum.

In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.


The question asked by @jim-p still stands even after the merge, so make sure to answer that.

Initialization issues are still occurring.

When I checked chipid and inverseechipid using the Serial print , both of them turned out to be 0. Therefore, I think spi communication is problematic. So, if spi communication is good with two Uno boards, I can think of it as a sensor problem.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.