# Deaph data problem

**URL:** <https://discuss.bluerobotics.com/t/deaph-data-problem/13788>\
**Category:** Blue Robotics Software\
**Tags:** pymavlink\
**Created:** [February 28, 2023, 4:54pm UTC](https://discuss.bluerobotics.com/t/deaph-data-problem/13788 "2023-02-28T16:54:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fusari](https://avatars.discourse-cdn.com/v4/letter/f/8e7dd6/32.png) [@fusari](https://discuss.bluerobotics.com/u/fusari)\
**Post date:** [February 28, 2023, 4:54pm UTC](https://discuss.bluerobotics.com/t/deaph-data-problem/13788/1 "2023-02-28T16:54:21Z")

</div>

hi  
iḿ tring to write a controller in pymavlink for my bluerov (whit bar 30 sensor)but when i try to read the altitude it is always 0; this is the code that i use

```auto
# Disable "Broad exception" warning
# pylint: disable=W0703

import time
import sys

# Import mavutil
from pymavlink import mavutil

# Create the connection
master = mavutil.mavlink_connection('udpin:0.0.0.0:14550')
# Wait a heartbeat before sending commands
master.wait_heartbeat()

# Request all parameters
master.mav.param_request_list_send(master.target_system, master.target_component)

try: # acquisizione profondita
    Z = master.messages['VFR_HUD'].alt
    print('altitude [m]:',Z)
    
except:
    print('no time message received')

```

some one can help me pls? because idk if instead i should calculate the z by the zacc

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [March 6, 2023, 11:16am UTC](https://discuss.bluerobotics.com/t/deaph-data-problem/13788/2 "2023-03-06T11:16:23Z")

</div>

Hi @fusari,

I’m not really sure what you’re trying to do with this program - you’re requesting all the parameters and then not trying to receive them, and then checking whether a specific message has been received that you haven’t [requested](http://www.ardusub.com/developers/pymavlink.html#request-message-interval).

If you’ve opened up a control station software (e.g. QGroundControl) before you run this Python program then most likely a `VFR_HUD` messages will be available, because control station softwares [automatically request particular message rates](https://discuss.bluerobotics.com/t/accessing-real-time-mavlink-messages-via-pymavlink/11355/10). Even in that case, your code currently only works if a `VFR_HUD` message was received while waiting for the initial heartbeat to be detected from the vehicle, whereas it would make more sense to just wait for the message you want directly, instead of your current `try-except` approach:

```python
msg = master.recv_match(type='VFR_HUD', blocking=True)
print('Depth [m]': -msg.alt)

```

---

<div class="post-metadata">

**Author:** ![fusari](https://avatars.discourse-cdn.com/v4/letter/f/8e7dd6/32.png) [@fusari](https://discuss.bluerobotics.com/u/fusari)\
**Post date:** [March 7, 2023, 10:16am UTC](https://discuss.bluerobotics.com/t/deaph-data-problem/13788/4 "2023-03-07T10:16:46Z")

</div>

Hi @EliotBR  
i tried the code you suggest but even i “put it down” by 40cm the valie is still 0  
if the sistem dont see the sensor i shouldn´t able to print it, right? (to know if there is a connection problem about the sensor)

p.s. if blocking parametr is false msg will be updated only if will receive the values right? i ask because i need to do a acquire date not blocking were if he can take the new valiue he will take it and do thing but if he don´t receive it still do the think whit the old valiue

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [March 9, 2023, 3:12am UTC](https://discuss.bluerobotics.com/t/deaph-data-problem/13788/5 "2023-03-09T03:12:49Z")

</div>

When you connect to the vehicle with QGroundControl (instead of your program), does it show depth readings, or does it give warning about no external pressure sensor being connected? It’s best to first make sure (with a known working setup/program) that the hardware is behaving as expected, and _then_ trying to change how it behaves with your own programs.

> [@fusari](#):
>
> if blocking parametr is false msg will be updated only if will receive the values right?

“Blocking” means the program stops at that point and just waits for the requested message (i.e. execution is blocked until some condition is met).

In this case if the message type is not being received then the code will just wait there indefinitely, unless you also set a value for the `timeout` parameter, in which case it will return `None` if the message you’re after does not arrive before the timeout occurs. If `blocking` is left as `False` (the default behaviour) then it’s like having a timeout of 0 - if the message is not available in the message buffer when it is requested then it will return `None` instead of a message object.

If you use timeouts / non-blocking behaviour then how you handle receiving `None` values is up to your code. It’s worth noting that there are some alternative message receiving / handling approaches discussed in [this comment](https://discuss.bluerobotics.com/t/the-interval-of-getting-data/12077/5) 🙂
