How do I send RTK data from my base station to ArduPilot

Well here it goes. For whoever finding the same solution.
You need 2 software, mission planner and U-center.(old one not the u-center 2)
I am using HERE+, I suspect any Ublox device can work difference is you need to set the band frequency.
You can do all in u-center but the survey part I prefer in Mission Planner at least I can see the progress

  1. Go mission planner> Setup> RTK Inject. Connect the serial port. Set the accuracy level, min. time survey and restart.
    It took like 20 mins to achieve 1.2metre, 0.5 metre it took like 40-60mins. So if you want <10cm accuracy expect to survey like an entire day.
  2. Once survey is complete just click use the results button. It will save the details in to the here+. Its good if you write down the values so you can use it later and next time.
  3. Go to u-center, connect to the device. Remember to disconnect in mission planner.
    View > Message View
    UBX > CFG > GNSS > Make sure it is the same band frequency your client is using. Here3 uses Beidou, GPS and Glosnoss so I select these 3 although rarely I receive any beidou signal. It doesn’t work if it is different between client and base.
    UBX > CFG >PRT Set protocol out to RTCM3, you only need NMEA and UBX for surveying. Remember to put in NMEA + UBX + RTCM3 when you do survey.
    UBX > CFG >TMODE3 If you have set to use the GPS value in mission planner. You should see that here it is in Fixed Mode with the surveyed GPS values. If it is not then you change to fixed mode and insert the value. Remember the default is in Metres which is not correct. You should select Lat/Lon.
    Finally click send at bottom left to send all values into HERE+

Now connect your computer which can be a SBC or a standard computer. I used raspberry write a script to read all serial data from the HERE+ and send it to your client.

On the client side with the mavproxy connected to your ardupilot and drone. You can write your own script to send in mavlink through mavproxy. Its up to you how you write it. Here is just part of my script, you just modify to your use.

flags = 1	
frag_id = 1
seq_id = 1
		while flags != 0:
			rtcmlng = len(rtcm)
			if rtcmlng <= 180 and frag_id == 1:
				buf = bytearray(rtcm)
				flags = 0
				flags_val = (seq_id << 3) | 0
			elif rtcmlng <= 180:
				buf = bytearray(rtcm)
				flags = 0
				flags_val = (seq_id << 3) | frag_id << 1 | 1
				buf = bytearray(rtcm[0:180])
				rtcm = rtcm[180:-1]
				flags_val = (seq_id << 3) | frag_id << 1 | 1		
			buflng = len(buf)	
			fill = 180 - buflng
			the_connection.mav.gps_rtcm_data_send(flags_val, buflng, buf)
			frag_id += 1
			if rtcmlng <= 180 and seq_id <= 99998:
				seq_id += 1	
			elif rtcmlng <= 180:
				seq_id = 1
1 Like

You could just let Mission Planner and ArduPilot auto configure the uBlox modules instead of reinventing the wheel. It works quite well with both M8P and F9P based modules and the Cube Orange.

I’m sure most user can just use the mission planner. Its almost plug and play. This is more for people who needs to set up RTK GPS base station remotely or using a different UBlox device. Hope it helps in anyway.

Still, it seems as if you’ve reinvented an unnecessary wheel, but I’m glad you got it working.

Thank you for the solution. For people who are not using Mission Planner or QGroundcontrol and making their own hardware (custom drone and base station if you like) with software, this is a great solution.

Hi @jimovonz, I am looking for a similar solution for sending RTK corrections from the base module to the rover. As for my application, I cannot use Mission planner or Qgroundcontrol for RTK inject. So I used MAVPROXY commands for doing the same. I tried to send RTCM data from my base module to the rover module via UDP port 13320 using the DGPS module on MAVPROXY. But I did not get the GPS status change from “3D-fix” to RTK-float". Can you please explain in a little more detail how you send RTCM corrections from the base to the rover using the DGPS module in MAVPROXY?
Thanks for your time.


can you also share the script to reall all serial data from the HERE+ and send it to client??

take a look at the rtcm scripts included with RTKLib.

Hi Jesephjj,

Is this able to send the correction directly to ArduPilot or you need to load mavproxy? I am using your code and it doen’t change anything. would you suggest me some change?

thank you,

Hi yes you need mavproxy. You need a way to inject code in. The python code is for mavproxy. I just paste the code to structure your rtk data the rest of it you have to customize yourself to your own use and send it.

Just this script doesn’t work, your script needs to first establish a connection wirh ardupilot. Reading heartbeat etc. You can find this information in Mavlink website. This script just explain how to structure your rtk data to be send to ardupilot.

Hey, thank you for your reply!!!

I still didn’t get well why you need mavproxy in this case. I mean, you may (or may not) use it to connect it to your ardupilot (the_connection) and after you send (gps_data_send) directly to the device, am I wrong? This code is very similar to the one inside mavproxy DGPS, that receives the correction in port 13320 and send it forward.

I did as you suggested about establishing the connection and sending the packages. It returns no error but I don’t see any difference in my mission planner.

Thank you again in advance for your comments :slight_smile:

You are right you can use mavproxy DGPS. Weirdly I find it laggy.
Anyway you can use it if the set up is simple.

I do my own for certain very customized projects. that is why I explore this.

And no, if you use (gps_data_send, there is no need for all these. You use DGPS only if you are using the GPS unit attached to your FC. (gps_data_send you just directly send GPS position so your FC will use your data for positioning, its 2 different thing.

thank you again!

Actually my GPS is attached to my FC. What I want is to send the NMEA package directly to the device. I am using gps_rtcm_data_send similar to the code you wrote. My only problem is that I don’t get any correction message displayed in Mission Planner nor my position seems visually fixed.

Good to know the latency issue with mavproxy…

I want to send the corrections directly from rtk2go to the controller using a onboard 4G connected Rpi.

Again, any comment/extra code would be really appreciated :slight_smile:

Hi Josephjj,
so we are struggling with getting RTK float/fix on out drone. So our setup is this: jetson orin nano companion computer running linux connected to orangeCube flight controller (FC) via UART, one telem connected to the FC. We setup the RTK ground station to send RTCM (we think) and the trying to receive them via another telem connected directly to GPS module (uBlox F9P). The gps module is also connected to the FC via a UART also, so basically the gps module is connected to both a telem to receive rtcm messages and the FC for the FC to receive gps data. Our idea is send the rtcm messages via telem and channel them directly via UART to the gps module. The gps module on the ground sending the corrections is the same uBlox F9P and is connected to the telem which is transmitting the corrections via UART. But we are having issues with it and have not been able to get it to work. Any help or suggestions would be appreciated.
Thank you!