# No optical flow data from PX4Flow with Pixhawk 4

**URL:** <https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430>\
**Category:** PX4 Autopilot\
**Created:** [April 25, 2020, 1:47am UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430 "2020-04-25T01:47:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![crest\_wave](https://discuss.px4.io/letter_avatar_proxy/v4/letter/c/919ad9/32.png) [@crest\_wave](https://discuss.px4.io/u/crest_wave)\
**Post date:** [April 25, 2020, 1:47am UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/1 "2020-04-25T01:47:21Z")

</div>

Hello all,

I have a PX4Flow and a pixhawk4. I connected the PX4Flow to the pixhawk 4 via I2C per the instruction below.  
Link: [https://docs.px4.io/v1.9.0/en/sensor/px4flow.html](https://docs.px4.io/v1.9.0/en/sensor/px4flow.html)  
The green, blue, and orange LED lights on PX4Flow were flashing when connected.  
However, I do not see any optical flow data on QGC.

When I connect the PX4Flow to PC via USB cable, I see optical flow data on QGC.

Could anyone tell me how I can use PX4Flow with Pixhawk4?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![farhang](https://discuss.px4.io/user_avatar/discuss.px4.io/farhang/32/17881_2.png) [@farhang](https://discuss.px4.io/u/farhang)\
**Post date:** [April 25, 2020, 7:17pm UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/2 "2020-04-25T19:17:43Z")

</div>

Hello,

If you do not have any other positioning device connected, are you having Local Position data in Mavlink Inspector?

---

<div class="post-metadata">

**Author:** ![crest\_wave](https://discuss.px4.io/letter_avatar_proxy/v4/letter/c/919ad9/32.png) [@crest\_wave](https://discuss.px4.io/u/crest_wave)\
**Post date:** [April 25, 2020, 11:28pm UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/3 "2020-04-25T23:28:39Z")

</div>

Thank you very much for your reply.  
I have a LightWare SF11/C laser rangefinder connected and see the distance data in Mavlink Inspector. GPS is not connected.  
Also, I set the [EKF2\_AID\_MASK](https://docs.px4.io/v1.9.0/en/advanced_config/parameter_reference.html#EKF2_AID_MASK) as 2 (use optical flow).  
I really appreciate your help.

---

<div class="post-metadata">

**Author:** ![ericleal](https://discuss.px4.io/user_avatar/discuss.px4.io/ericleal/32/5769_2.png) [@ericleal](https://discuss.px4.io/u/ericleal)\
**Post date:** [April 27, 2020, 1:31pm UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/4 "2020-04-27T13:31:30Z")

</div>

In newer versions of px4 there is an optical flow enable parameter that has to be set to one. To see this parameter QGC needs to be up to date.

---

<div class="post-metadata">

**Author:** ![crest\_wave](https://discuss.px4.io/letter_avatar_proxy/v4/letter/c/919ad9/32.png) [@crest\_wave](https://discuss.px4.io/u/crest_wave)\
**Post date:** [April 27, 2020, 2:59pm UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/5 "2020-04-27T14:59:58Z")

</div>

Thank you very much for your help.  
I updated QGC and set the optical flow enable parameter to one.  
Now, I see the optical flow message in the MAVlink Inspector, however I get zero values for most of the parameters of the optical flow as shown in the attached image below.  
Do you have any idea why it’s happening?

 ![PX4flow](https://discuss.px4.io/uploads/default/original/2X/1/16921266dbad0ecfca4be0dad5e494d578047c21.png)

---

<div class="post-metadata">

**Author:** ![ericleal](https://discuss.px4.io/user_avatar/discuss.px4.io/ericleal/32/5769_2.png) [@ericleal](https://discuss.px4.io/u/ericleal)\
**Post date:** [April 27, 2020, 3:31pm UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/6 "2020-04-27T15:31:53Z")

</div>

When the camera does not see enough contrast to identify movement the px4flow board returns 0’s. You can use the usb port on the flow sensor to see if the lens is focused in QGC. Unplug the flow sensor from the pixhawk when you do this of you can damage the i2c power out on the pixhawk. For indoor flight I had to mount a pretty bright led to the bottom of the airframe.

---

<div class="post-metadata">

**Author:** ![crest\_wave](https://discuss.px4.io/letter_avatar_proxy/v4/letter/c/919ad9/32.png) [@crest\_wave](https://discuss.px4.io/u/crest_wave)\
**Post date:** [April 27, 2020, 4:15pm UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/7 "2020-04-27T16:15:13Z")

</div>

I really appreciate your prompt response.  
When I connect the px4flow via USB cable, I can see the nonzero values in QGC as shown in the attached image below.  
However, when I connect the px4flow using I2C cable, I do not receive any values for x/y parameters as shown in my previous post. It seems that I get the distance value from the sonar sensor from the px4flow.

 ![PX4flow](https://discuss.px4.io/uploads/default/original/2X/5/55f9ff0d74316289e43cb5f42733779437a8e73a.png)

---

<div class="post-metadata">

**Author:** ![ericleal](https://discuss.px4.io/user_avatar/discuss.px4.io/ericleal/32/5769_2.png) [@ericleal](https://discuss.px4.io/u/ericleal)\
**Post date:** [April 27, 2020, 4:44pm UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/8 "2020-04-27T16:44:27Z")

</div>

There are a bunch of conditions that need to be met for the data to be sent including the distance being valid and minimum image qualities being met. If you focus the lens to about 6ft and go outside on a sunny day over a highly textured surface it will send the data packet. If you want to do stuff like fly near the ground you have to modify and rebuild the code and replace the sonar with something that works closer to the ground.

---

<div class="post-metadata">

**Author:** ![crest\_wave](https://discuss.px4.io/letter_avatar_proxy/v4/letter/c/919ad9/32.png) [@crest\_wave](https://discuss.px4.io/u/crest_wave)\
**Post date:** [April 28, 2020, 2:59pm UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/9 "2020-04-28T14:59:04Z")

</div>

Thank you very much for your advise.

I did the following two tests under the same condition (indoor).  
However, I get different results and px4flow with I2c does not receive full values.

(Test 1) px4flow connected to QGC via USB cable  
Result:  
most of the parameter values received except for flow\_rate\_x and flow\_rate\_y  
QGC MAVlink Inspector Screenshot:  
[https://discuss.px4.io/uploads/default/original/2X/5/55f9ff0d74316289e43cb5f42733779437a8e73a.png](https://discuss.px4.io/uploads/default/original/2X/5/55f9ff0d74316289e43cb5f42733779437a8e73a.png)

(Test 2) px4flow connected to pixhawk 4 via I2C cable.  
Result:  
no values received except for distance value  
QGC MAVlink Inspector Screenshot:  
[https://discuss.px4.io/uploads/default/original/2X/1/16921266dbad0ecfca4be0dad5e494d578047c21.png](https://discuss.px4.io/uploads/default/original/2X/1/16921266dbad0ecfca4be0dad5e494d578047c21.png)

---

<div class="post-metadata">

**Author:** ![ericleal](https://discuss.px4.io/user_avatar/discuss.px4.io/ericleal/32/5769_2.png) [@ericleal](https://discuss.px4.io/u/ericleal)\
**Post date:** [May 1, 2020, 1:54pm UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/10 "2020-05-01T13:54:38Z")

</div>

Make the scenario where the quality goes to 255 with the usb in. My drone with optical flow has a huge led light on the bottom of it. The px4flow tab should be the video stream so get the focus really sharp and show it a non reflective surface with a lot of texture and contrast.

---

<div class="post-metadata">

**Author:** ![crest\_wave](https://discuss.px4.io/letter_avatar_proxy/v4/letter/c/919ad9/32.png) [@crest\_wave](https://discuss.px4.io/u/crest_wave)\
**Post date:** [May 2, 2020, 2:41pm UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/11 "2020-05-02T14:41:41Z")

</div>

Thank you very much for your advise.  
I did the tests below after the focus is adjusted.  
I’m still wondering why the Test 2 result (with I2C cable) is different from the Test 1 result (with USB) under the same environment with lighting and surface condition.

Test Results:

I did the following two tests under the same condition (indoor).  
However, I get different results and px4flow with I2c does not receive full values.

(Test 1) px4flow connected to QGC via USB cable  
Result:  
most of the parameter values received except for flow\_rate\_x and flow\_rate\_y  
QGC MAVlink Inspector Screenshot:  
[https://discuss.px4.io/uploads/default/original/2X/5/55f9ff0d74316289e43cb5f42733779437a8e73a.png](https://discuss.px4.io/uploads/default/original/2X/5/55f9ff0d74316289e43cb5f42733779437a8e73a.png)

(Test 2) px4flow connected to pixhawk 4 via I2C cable.  
Result:  
no values received except for distance value  
QGC MAVlink Inspector Screenshot:  
[https://discuss.px4.io/uploads/default/original/2X/1/16921266dbad0ecfca4be0dad5e494d578047c21.png](https://discuss.px4.io/uploads/default/original/2X/1/16921266dbad0ecfca4be0dad5e494d578047c21.png)

---

<div class="post-metadata">

**Author:** ![ericleal](https://discuss.px4.io/user_avatar/discuss.px4.io/ericleal/32/5769_2.png) [@ericleal](https://discuss.px4.io/u/ericleal)\
**Post date:** [May 4, 2020, 2:57pm UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/12 "2020-05-04T14:57:28Z")

</div>

There is logic on the px4flow boards microcontroller that will declare the data invalid and replace its measured data with 0’s to prevent false data from crashing the vehicle. In the screenshot with the i2c data showing 0’s the distance is 0.3 which is invalid because the sonar will report false data at that distance. In both screenshots the quality is below 200 which isn’t great. You need to focus the lens to the height you will be flying at which needs to be more that 0.7m without modifying the firmware. I have found that normal indoor lighting is not enough for this camera so either taking it outside or getting a really bright light is needed.

---

<div class="post-metadata">

**Author:** ![crest\_wave](https://discuss.px4.io/letter_avatar_proxy/v4/letter/c/919ad9/32.png) [@crest\_wave](https://discuss.px4.io/u/crest_wave)\
**Post date:** [May 12, 2020, 2:04pm UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/13 "2020-05-12T14:04:25Z")

</div>

I’m sorry for my late reply. It took me a while to investigate. I appreciate your help.

> [@ericleal](#):
>
> There is logic on the px4flow boards microcontroller that will declare the data invalid and replace its measured data with 0’s to prevent false data from crashing the vehicle.

↑ Thank you for this information.

When I got the screenshots in my previous post, the distance was about 0.3m. But, even at around 2m, the i2c data with the focus adjusted shows 0’s all the time although the USB data shows nonzero values.

I understand the normal indoor lighting may not be enough, but I don’t understand why USB data shows nonzero values and the i2c data shows 0’s values under the same lighting condition.

---

<div class="post-metadata">

**Author:** ![ericleal](https://discuss.px4.io/user_avatar/discuss.px4.io/ericleal/32/5769_2.png) [@ericleal](https://discuss.px4.io/u/ericleal)\
**Post date:** [May 12, 2020, 7:33pm UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/14 "2020-05-12T19:33:45Z")

</div>

The data packet usb is not the same as i2c.

> **[PX4/Flow](https://github.com/PX4/Flow/tree/master/src/modules/flow)**
>
> Firmware for PX4FLOW board. Contribute to PX4/Flow development by creating an account on GitHub.

  
If you go through the code and comment out anytime data\_valid is set false it would not send the 0’s but you would crash your drone because it would send the flight controller velocity figures that are not real and cause the ekf to reset. The flow board is basically saying to the flight controller just keep integrating imu data for velocity until I get a good reading. It is possible that the firmware has been updated on the px4flow board which can be flashed from QGC or a desktop build and newer versions of the PX4 firmware may help with dealing with optical flow.

---

<div class="post-metadata">

**Author:** ![crest\_wave](https://discuss.px4.io/letter_avatar_proxy/v4/letter/c/919ad9/32.png) [@crest\_wave](https://discuss.px4.io/u/crest_wave)\
**Post date:** [May 13, 2020, 4:38pm UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/15 "2020-05-13T16:38:12Z")

</div>

Thank you very much for your help. I really appreciate it. I will investigate it more.

---

<div class="post-metadata">

**Author:** ![shamweel\_khan](https://discuss.px4.io/user_avatar/discuss.px4.io/shamweel_khan/32/6739_2.png) [@shamweel\_khan](https://discuss.px4.io/u/shamweel_khan)\
**Post date:** [August 3, 2020, 9:56am UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/16 "2020-08-03T09:56:32Z")

</div>

Hellow  
Can You help me how you enable optical Flow Parameter

---

<div class="post-metadata">

**Author:** ![shamweel\_khan](https://discuss.px4.io/user_avatar/discuss.px4.io/shamweel_khan/32/6739_2.png) [@shamweel\_khan](https://discuss.px4.io/u/shamweel_khan)\
**Post date:** [August 3, 2020, 9:57am UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/17 "2020-08-03T09:57:05Z")

</div>

![Capture](https://discuss.px4.io/uploads/default/original/2X/d/d0d233ea5c13f0d8da61fbe83b0a42fd91e32616.png)

---

<div class="post-metadata">

**Author:** ![farhang](https://discuss.px4.io/user_avatar/discuss.px4.io/farhang/32/17881_2.png) [@farhang](https://discuss.px4.io/u/farhang)\
**Post date:** [August 25, 2020, 10:08am UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/18 "2020-08-25T10:08:16Z")

</div>

Hello,  
we have DOCs for it.

[https://docs.px4.io/v1.9.0/en/sensor/px4flow.html](https://docs.px4.io/v1.9.0/en/sensor/px4flow.html)

---

<div class="post-metadata">

**Author:** ![ticotico](https://discuss.px4.io/letter_avatar_proxy/v4/letter/t/67e7ee/32.png) [@ticotico](https://discuss.px4.io/u/ticotico)\
**Post date:** [February 3, 2022, 8:56am UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/19 "2022-02-03T08:56:13Z")

</div>

Hi, I am facing a similar issue:

- Pixhawk 4 mini
- PX4flow v1.3
- connection: `USART3` of PX4Flow \<=\> `UART&I2C b` port of the pixhawk mini
- Parameter: `SENS_EN_PX4FLOW` set to `1`
- connection via USB works nicely and everything is in QGC

So far all good, but then:

- mavlink console: `px4flow start` shows “ERROR [SPI\_I2C] need to specify a bus type”
- mavlink inspector: `Optical_flow_rad` does not show up

Any hints or ideas?

PS: USART3 is correct according to the manual (see below), but in ardupilot, they [recommend](https://ardupilot.org/copter/docs/common-px4flow-overview.html#connect-to-the-pixhawk) to use the I2C port of the PX4flow

 ![px4flow](https://discuss.px4.io/uploads/default/original/2X/2/2f11939ac21742180855223502b4fb71f91a9d5e.png)

---

<div class="post-metadata">

**Author:** ![farhang](https://discuss.px4.io/user_avatar/discuss.px4.io/farhang/32/17881_2.png) [@farhang](https://discuss.px4.io/u/farhang)\
**Post date:** [February 12, 2022, 6:53pm UTC](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430/20 "2022-02-12T18:53:42Z")

</div>

@ticotico have you solved this yet?

[Next page](https://discuss.px4.io/t/no-optical-flow-data-from-px4flow-with-pixhawk-4/16430.md?page=2)
