# Px4 + rtk + raspberryPi fed rtk correction data: is it possible?

**URL:** <https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009>\
**Category:** PX4 Autopilot\
**Created:** [December 7, 2022, 11:00am UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009 "2022-12-07T11:00:54Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![louiluiloui](https://discuss.px4.io/user_avatar/discuss.px4.io/louiluiloui/32/11952_2.png) [@louiluiloui](https://discuss.px4.io/u/louiluiloui)\
**Post date:** [December 7, 2022, 11:00am UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/1 "2022-12-07T11:00:54Z")

</div>

Hey there,

I wanted to start a little project to build a rtk drone with a raspberry pi mounted as well, which receives the rtk via cellular from SAPOS (it’s a provider in Germany offering rtk data over the internet in real time in the Ntrip standard.) I know it’s possible for DJI drones, but after quite some search I couldn’t come up with someone in the pixhawk community writing about this.

So I wonder mainly about two things:

1. Can I transmit the rtk data via cable from pi to px4 or do I have to do the go around via bluetooth (from which I know it’s working, but quite unreliable)?
2. Which RTK receiver is able to be fed rtk data not from the designated base station of the same brand, but rtk data from this online provider?

Help is much appreciated!  
Cheers

---

<div class="post-metadata">

**Author:** ![AlexKlimaj](https://discuss.px4.io/user_avatar/discuss.px4.io/alexklimaj/32/14479_2.png) [@AlexKlimaj](https://discuss.px4.io/u/AlexKlimaj)\
**Post date:** [December 7, 2022, 4:34pm UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/2 "2022-12-07T16:34:39Z")

</div>

You will just need to send the rtcm data to the flight controller from the pi over mavlink.

---

<div class="post-metadata">

**Author:** ![louiluiloui](https://discuss.px4.io/user_avatar/discuss.px4.io/louiluiloui/32/11952_2.png) [@louiluiloui](https://discuss.px4.io/u/louiluiloui)\
**Post date:** [December 8, 2022, 3:44pm UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/3 "2022-12-08T15:44:49Z")

</div>

Understood, thanks.  
Do you know which rtk receivers are able to handle SAPOS data?

---

<div class="post-metadata">

**Author:** ![AlexKlimaj](https://discuss.px4.io/user_avatar/discuss.px4.io/alexklimaj/32/14479_2.png) [@AlexKlimaj](https://discuss.px4.io/u/AlexKlimaj)\
**Post date:** [December 8, 2022, 6:44pm UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/4 "2022-12-08T18:44:15Z")

</div>

I don’t believe the Ublox F9P can use SAPOS.

---

<div class="post-metadata">

**Author:** ![Katawan](https://discuss.px4.io/user_avatar/discuss.px4.io/katawan/32/5544_2.png) [@Katawan](https://discuss.px4.io/u/Katawan)\
**Post date:** [December 9, 2022, 7:22am UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/5 "2022-12-09T07:22:29Z")

</div>

Hi @louiluiloui,

I can give you my feedback as I implemented a RTK stream with:  
Internet ↔ Companion computer (RPi) ↔ Ntripclient + MAVSDK ↔ Pixhawk 4 ↔ Ublox F9P

> [@louiluiloui](#):
>
> - Can I transmit the rtk data via cable from pi to px4 or do I have to do the go around via bluetooth (from which I know it’s working, but quite unreliable)?

Yes. In my case, I use UART of RPi to TELEM2 of Pixhawk 4. Then I use an adaptation of a C++ ntrip client [here](https://github.com/sevensx/ntrip) and send the ntrip correction with the [send\_rtcm\_data](https://mavsdk.mavlink.io/main/en/cpp/api_reference/classmavsdk_1_1_rtk.html#classmavsdk_1_1_rtk_1ab0f183ba8e57944e6f9d383f51490d09) provided in MAVSDK. MAVProxy also have something to send ntrip data in Python [here](https://github.com/ArduPilot/MAVProxy/blob/master/MAVProxy/modules/lib/ntrip.py)

> [@louiluiloui](#):
>
> - Which RTK receiver is able to be fed rtk data not from the designated base station of the same brand, but rtk data from this online provider?

I use the F9P ublox chip. I don’t know SAPOS but I would say if it respect the ntrip standard it worth giving a try.

One possibility also could be to use something already done such as ArduSimple do with their [4G Ntrip module](https://www.ardusimple.com/pcb-integration-guide-4g-ntrip-master/) or one of their kit so that you just have to worry about finding an internet provider.

I hope this help !

---

<div class="post-metadata">

**Author:** ![louiluiloui](https://discuss.px4.io/user_avatar/discuss.px4.io/louiluiloui/32/11952_2.png) [@louiluiloui](https://discuss.px4.io/u/louiluiloui)\
**Post date:** [December 9, 2022, 9:56am UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/6 "2022-12-09T09:56:00Z")

</div>

what makes you think that?

---

<div class="post-metadata">

**Author:** ![louiluiloui](https://discuss.px4.io/user_avatar/discuss.px4.io/louiluiloui/32/11952_2.png) [@louiluiloui](https://discuss.px4.io/u/louiluiloui)\
**Post date:** [December 9, 2022, 10:12am UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/7 "2022-12-09T10:12:36Z")

</div>

That helps a lot, thanks!  
My problem is the UART of my Pi is already used for my cellular module.  
I saw there are some workarounds using the USB port of the Pi and going into the telem2 of the pixhawk via an adaptor, but they all seemed to work rather poorly. Have you a any tips for establishing such a connection?

---

<div class="post-metadata">

**Author:** ![louiluiloui](https://discuss.px4.io/user_avatar/discuss.px4.io/louiluiloui/32/11952_2.png) [@louiluiloui](https://discuss.px4.io/u/louiluiloui)\
**Post date:** [December 9, 2022, 11:35am UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/8 "2022-12-09T11:35:11Z")

</div>

ah never mind I just saw that a normal usb cable works just fine from pi to pixhawk. Is it really that simple?

---

<div class="post-metadata">

**Author:** ![Katawan](https://discuss.px4.io/user_avatar/discuss.px4.io/katawan/32/5544_2.png) [@Katawan](https://discuss.px4.io/u/Katawan)\
**Post date:** [December 9, 2022, 4:14pm UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/9 "2022-12-09T16:14:41Z")

</div>

When you forward the Ntrip data to the Pixhawk you should see the drone switching to RTK fixed or float if it’s working properly

---

<div class="post-metadata">

**Author:** ![AlexKlimaj](https://discuss.px4.io/user_avatar/discuss.px4.io/alexklimaj/32/14479_2.png) [@AlexKlimaj](https://discuss.px4.io/u/AlexKlimaj)\
**Post date:** [December 9, 2022, 5:50pm UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/10 "2022-12-09T17:50:12Z")

</div>

No mention of SAPOS in the data sheet.

> **[ZED-F9P-04B\_DataSheet\_UBX-21044850.pdf](https://content.u-blox.com/sites/default/files/ZED-F9P-04B_DataSheet_UBX-21044850.pdf)**
>
> 1132.86 KB

---

<div class="post-metadata">

**Author:** ![louiluiloui](https://discuss.px4.io/user_avatar/discuss.px4.io/louiluiloui/32/11952_2.png) [@louiluiloui](https://discuss.px4.io/u/louiluiloui)\
**Post date:** [December 14, 2022, 10:35am UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/11 "2022-12-14T10:35:35Z")

</div>

@AlexKlimaj Well I would be surprised if they list it there, after all it’s an official provider from the German government. SAPOS is just available in Germany. There are those providers of the rtk data in many countries and none of them are listed.

@all Anyways I have now all the parts together and will update you if it works the way I hope (it probably won’t)  
Thanks again!

---

<div class="post-metadata">

**Author:** ![Benjamin1994](https://discuss.px4.io/letter_avatar_proxy/v4/letter/b/d26b3c/32.png) [@Benjamin1994](https://discuss.px4.io/u/Benjamin1994)\
**Post date:** [July 27, 2023, 4:03am UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/12 "2023-07-27T04:03:57Z")

</div>

Hi can you please explain more about this?

I am very new to this and what you implemented a RTK stream is exactly I am trying to reach!!!

---

<div class="post-metadata">

**Author:** ![Katawan](https://discuss.px4.io/user_avatar/discuss.px4.io/katawan/32/5544_2.png) [@Katawan](https://discuss.px4.io/u/Katawan)\
**Post date:** [July 27, 2023, 2:39pm UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/13 "2023-07-27T14:39:37Z")

</div>

Hi @Benjamin1994,

Happy to help but I would need more specific question 😅 You already implemented something and fail to make it works or you don’t understand the setup I propose ?

---

<div class="post-metadata">

**Author:** ![Benjamin1994](https://discuss.px4.io/letter_avatar_proxy/v4/letter/b/d26b3c/32.png) [@Benjamin1994](https://discuss.px4.io/u/Benjamin1994)\
**Post date:** [July 28, 2023, 3:41am UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/14 "2023-07-28T03:41:24Z")

</div>

Thank you for reply!

Here is my setup:  
[raspberryPi fed RTK correction data to Pixawk: is it possible? - PX4 Autopilot - Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink](https://discuss.px4.io/t/raspberrypi-fed-rtk-correction-data-to-pixawk-is-it-possible/33443)

All I want to do is sending RTK Correction Data to Drone without telemetry, therefore my idea is

1. Streaming RTK correction data (RTCM only, because I can only find python function that feed rtcm data to Pixhawk) from Holybro RTK Base Station to RPi(A) connected to it \<— I have done this part

2. Once the RPi(A) connected to Holybro RTK Base Station, it will send the correction data to another RPi(B) connected to Pixhawk via Wi-Fi (they are both in the network) \<---- I barely have done this part

3. Once RPi(B) received the correction data from RPi(A), it feed the data to Pixhawk for getting RTK float or even RTK Fixed \<----- this is the part I am struggling, I could not find any example for me to achieve this part

I was doing research and found this post, I think Mr.Katawan your set-up is much lighter (sorry for my poor english). The idea I got from your set-up is, you do not need the RTK base station because you directly get the NTRIP data from online and feed it to Pixhawk. My RPi(B) which connected to Pixhawk is plugged in a 4G SIM Card Dongle, therefore I think your system may also can be applied on my system.

However, at this stage, I would like to ask Mr.Katawan, can you please explain or teach me, how do I use the send\_rtcm\_data provided in MAVSDK, to feed the RTK correction data I got from RTK base station, to Pixhawk?

Thank you very much!!!

Here is the RTCM correction data I got from RTK base station

 ![image](https://discuss.px4.io/uploads/default/original/2X/5/545ebd3b2b76a06adefa61534ba1b9f32f43b436.png)

---

<div class="post-metadata">

**Author:** ![Katawan](https://discuss.px4.io/user_avatar/discuss.px4.io/katawan/32/5544_2.png) [@Katawan](https://discuss.px4.io/u/Katawan)\
**Post date:** [July 29, 2023, 11:50am UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/15 "2023-07-29T11:50:26Z")

</div>

So I guess you have also a Holybro RTK connected in you drone through UART or something like this ?

Basically you need to send the raw data of RTCM to the Pixhawk and it will forward it automatically to your onboard GPS RTK

If you are working with Python, you might found a good example of use in MAVProxy [here](https://github.com/ArduPilot/MAVProxy/blob/85806b9561814402868434b56848b060cd12c7f5/MAVProxy/modules/mavproxy_ntrip.py). In my case I wrote the bridge in C++ using MAVSDK but I can share it to you if necessary.

P.S: You can mp me in the PX4 discord it would be easier to discuss [Dronecode Foundation](https://discord.gg/euuBEeEB)

---

<div class="post-metadata">

**Author:** ![Benjamin1994](https://discuss.px4.io/letter_avatar_proxy/v4/letter/b/d26b3c/32.png) [@Benjamin1994](https://discuss.px4.io/u/Benjamin1994)\
**Post date:** [July 30, 2023, 3:23pm UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/16 "2023-07-30T15:23:37Z")

</div>

Thank you for the reply again!!!

Yes, I do have the Holybro RTK rover connected to my drone through UART, here is my RTK rover

 ![image](https://discuss.px4.io/uploads/default/original/2X/9/961e6ed1ab096c8ff2fba87d78303b7350e04528.jpeg)  
My Raspberry Pi(B) is connected to my drone through Serial Port (/dev/ttyAMA1) to TELEM2 of PX4

And I have this RTK base connected to my Raspberry Pi(A)  
 ![image](https://discuss.px4.io/uploads/default/original/2X/f/ff28a65737a31f9ba9bdfe2d9ae68e66a1ad841b.png)

I do have search for example code of MAVSDK and I think this example is what I would like to achieve

> <https://github.com/mavlink/MAVSDK-Python/blob/ac985f523cadefbe85ed0524e0b4779392678e9a/examples/rtk.py>

I tried to run this code in my Raspberry Pi(B) (Connected to PX4) but I don’t think it send the RTK data to PX4, can you help me with that? I sure my Raspberry Pi(B) can communicated to PX4 since I can run this code and get all the parameters:

> <https://github.com/mavlink/MAVSDK-Python/blob/ac985f523cadefbe85ed0524e0b4779392678e9a/examples/all_params.py>

Yes I am working with Python but I am really new to it, I do not know quite much about it and therefore I would like to use the existed system, which is Raspberry Pi(A) sends the RTCM data to Raspberry Pi(B) via Wi-Fi, and then Raspberry Pi(B) send the data to Pixhawk.

as you said “Basically you need to send the raw data of RTCM to the Pixhawk and it will forward it automatically to your onboard GPS RTK”

THIS IS THE PART I AM REALLY STRUGGLING, I do not know how to send the raw data of RTCM to the Pixhawk via python code. Can you please help me with this?

---

<div class="post-metadata">

**Author:** ![Benjamin1994](https://discuss.px4.io/letter_avatar_proxy/v4/letter/b/d26b3c/32.png) [@Benjamin1994](https://discuss.px4.io/u/Benjamin1994)\
**Post date:** [July 30, 2023, 3:33pm UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/17 "2023-07-30T15:33:10Z")

</div>

Sorry I tried to understand the MAVProxy code but I really do not understand…  
Is the code run in base station or run in drone?

---

<div class="post-metadata">

**Author:** ![Benjamin1994](https://discuss.px4.io/letter_avatar_proxy/v4/letter/b/d26b3c/32.png) [@Benjamin1994](https://discuss.px4.io/u/Benjamin1994)\
**Post date:** [July 30, 2023, 4:23pm UTC](https://discuss.px4.io/t/px4-rtk-raspberrypi-fed-rtk-correction-data-is-it-possible/30009/18 "2023-07-30T16:23:02Z")

</div>

the PX4 I am using was bought 2 yrs before and I did not upgrade its firmware,  
will it be the reason I run the MAVSDK example and got nothing? The old firmware can not communicate with new python code?
