# Reading Mavlink special messages, using pymavlink

**URL:** <https://discuss.bluerobotics.com/t/reading-mavlink-special-messages-using-pymavlink/4965>\
**Category:** Blue Robotics Software\
**Tags:** pymavlink\
**Created:** [April 30, 2019, 12:19am UTC](https://discuss.bluerobotics.com/t/reading-mavlink-special-messages-using-pymavlink/4965 "2019-04-30T00:19:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexxtasi](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@alexxtasi](https://discuss.bluerobotics.com/u/alexxtasi)\
**Post date:** [April 30, 2019, 12:19am UTC](https://discuss.bluerobotics.com/t/reading-mavlink-special-messages-using-pymavlink/4965/1 "2019-04-30T00:19:45Z")

</div>

Hi there all,  
I am following ardusub’s official [docs](https://www.ardusub.com/developers/pymavlink.html), so I can read mavlink messages that suits my needs.  
At the time of writing this, data that I need are:

- time (as time of reading data)
- depth
- pressure
- temperature
- heading

Searching the forum and in Mavlink’s documentation, I could find those messages :

- time - **SYSTEM\_TIME** (from [Mavlink’s common messages](https://mavlink.io/en/messages/common.html#SYSTEM_TIME))
- depth - **GLOBAL\_POSITION\_INT** or **VFR\_HUD** (found [here](https://discuss.bluerobotics.com/t/read-data-of-depth-pressure-sensor/436/20) and mentioned also in [here](https://discuss.bluerobotics.com/t/writing-telemetry-data-specifically-depth-to-gopro-video/1833/2))
- pressure - **SCALED\_PRESSURE2** (found [here](https://discuss.bluerobotics.com/t/read-data-of-depth-pressure-sensor/436/20), also [here](https://discuss.bluerobotics.com/t/obtaining-depth-from-the-rov/4566/2) and in [this thead](https://discuss.bluerobotics.com/t/mavros-depth-sensor-plugin/1276/3))
- temperature - **RAW\_PRESSURE** or **SCALED\_PRESSURE** (also **SCALED\_PRESSURE2** , **SCALED\_PRESSURE3** found in mavlink docs, but cannot decide which is the correct message)
- heading - **VFR\_HUD** , **RAW\_IMU** and **ATTITUDE** (found [here](https://discuss.bluerobotics.com/t/heading-depth-data-to-surface/1281/27) and [here](https://discuss.bluerobotics.com/t/autopilot-with-compass/3900/4))

specially for the heading, my search results confused me, since I cannot tell the difference between **VFR\_HUD** , **RAW\_IMU** , **ATTITUDE** and **AHRS**

I think… testing those and at the same time crosschecking with QGC’s data, can give me an answer. But I would like anyone’s suggestion in this forum, based on your experience.

Thanks is advance !!

---

<div class="post-metadata">

**Author:** ![patrickelectric](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/patrickelectric/32/2162_2.png) [@patrickelectric](https://discuss.bluerobotics.com/u/patrickelectric)\
**Post date:** [April 30, 2019, 12:17pm UTC](https://discuss.bluerobotics.com/t/reading-mavlink-special-messages-using-pymavlink/4965/2 "2019-04-30T12:17:02Z")

</div>

Hi,

- depth - you should use **VFR\_HUD** , **GLOBAL\_POSITION\_INT** is for GPS systems.
- temperature - it depends, you can get the temperature of the pressure sensor ([Bar100](https://www.bluerobotics.com/store/sensors-sonars-cameras/sensors/bar100-sensor-r1/), [Bar30](https://www.bluerobotics.com/store/sensors-sonars-cameras/sensors/bar30-sensor-r1/), [Bar02](https://www.bluerobotics.com/store/sensors-sonars-cameras/sensors/bar02-sensor-r1-rp/)) with **SCALED\_PRESSURE2** or [Celsius Fast-Response Temperature Sensor](https://www.bluerobotics.com/store/sensors-sonars-cameras/sensors/celsius-sensor-r1/) with **SCALED\_PRESSURE3**.
- heading - **RAW\_IMU** is the raw values from the sensor. For heading estimation, you should use **VFR\_HUD** (0° … 360º [degree]) or **ATTITUDE** (-pi … +pi [rad]), the only difference is the unit.

Since ArduPilot messages are limited and are used in multiple devices/concepts, some messages like **SCALED\_PRESSURE2** and **SCALED\_PRESSURE3** can be a bit confuse, but everything else is straightforward after reading the documentation.

---

<div class="post-metadata">

**Author:** ![alexxtasi](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@alexxtasi](https://discuss.bluerobotics.com/u/alexxtasi)\
**Post date:** [May 2, 2019, 12:26am UTC](https://discuss.bluerobotics.com/t/reading-mavlink-special-messages-using-pymavlink/4965/3 "2019-05-02T00:26:23Z")

</div>

Hey @patrickelectric thanks for the answer !!  
you didn’t mention anything about time or pressure, so I suppose I was right on those.  
To sum up … mavlink messages I need are:

- time - SYSTEM\_TIME.time\_unix\_usec
- depth - VFR\_HUD.alt
- pressure - SCALED\_PRESSURE2.press\_diff
- temperature - SCALED\_PRESSURE2.temperature (I use the Bar30 sensor)
- heading - VFR\_HUD.heading

please correct me if anything of the above is wrong.

I also encountered some difference between mavlink time and local time (on the system python is reading the messages) - a very small one, but in a case of video timing might be critical.  
I also saw this mentioned in [Writing telemetry data (specifically, depth) to gopro video? - #5 by mspencer](https://discuss.bluerobotics.com/t/writing-telemetry-data-specifically-depth-to-gopro-video/1833/5)

Is there a workaround on this ??  
and what is the status of [Add option to set system time via GCS](https://github.com/bluerobotics/ardusub/issues/131) ??

many thanks

---

<div class="post-metadata">

**Author:** ![patrickelectric](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/patrickelectric/32/2162_2.png) [@patrickelectric](https://discuss.bluerobotics.com/u/patrickelectric)\
**Post date:** [May 2, 2019, 1:06pm UTC](https://discuss.bluerobotics.com/t/reading-mavlink-special-messages-using-pymavlink/4965/4 "2019-05-02T13:06:02Z")

</div>

Hi,

Yes, I just did the corrections, your other assumptions are correct.

> [@alexxtasi](#):
>
> please correct me if anything of the above is wrong.

Everything looks right.

For the time issue, this should be fixed if you are using the last version of ArduSub and QGC. After doing the connection with the vehicle, QGC will set the time based on the surface computer date/time information, you can also set the desired time with [system\_time\_send](https://mavlink.io/en/mavgen_python/#sending).

---

<div class="post-metadata">

**Author:** ![alexxtasi](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@alexxtasi](https://discuss.bluerobotics.com/u/alexxtasi)\
**Post date:** [May 2, 2019, 9:41pm UTC](https://discuss.bluerobotics.com/t/reading-mavlink-special-messages-using-pymavlink/4965/5 "2019-05-02T21:41:05Z")

</div>

Patrick thank you very much for your answer !!

---

<div class="post-metadata">

**Author:** ![ugurdemirezen](https://avatars.discourse-cdn.com/v4/letter/u/9de053/32.png) [@ugurdemirezen](https://discuss.bluerobotics.com/u/ugurdemirezen)\
**Post date:** [November 13, 2021, 10:59am UTC](https://discuss.bluerobotics.com/t/reading-mavlink-special-messages-using-pymavlink/4965/7 "2021-11-13T10:59:32Z")

</div>

Hi,  
How did you read all this parameter’s mavlink message ? Can you help me ? Thanks.

---

<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:** [November 14, 2021, 2:50am UTC](https://discuss.bluerobotics.com/t/reading-mavlink-special-messages-using-pymavlink/4965/8 "2021-11-14T02:50:05Z")

</div>

> [@ugurdemirezen](#):
>
> How did you read all this parameter’s mavlink message ?

There’s a difference between “mavlink messages” (which are regularly communicated between the vehicle and ground control software) and “vehicle parameters” (which the vehicle uses for internal control, and to interpret the messages/commands it gets sent). We have examples for getting both:

- [receive data and filter by message type](https://www.ardusub.com/developers/pymavlink.html#receive-data-and-filter-by-message-type)
- [read and write parameters](https://www.ardusub.com/developers/pymavlink.html#read-and-write-parameters)

The discussion in this thread has all been about mavlink messages, so I expect you want the first one.
