Setting up a GPS with Betaflight

There’s a whole bunch of reasons why you might want a GPS receiver on your Betaflight quad. It might be for helping you know where you are in long-range endeavors, liking the fuzzy warm feeling of having a home arrow, or the increased safety aspect of having the GPS rescue mode available.

I’ve already made several YouTube videos on the subject, but I’ll say it again here just to be clear (just once and then I’ll shut up) it’s the word of warning. Don’t use a GPS as your primary method of navigation, or rely on it getting your quad back to you in a loss of signal situation. I’ve personally had plenty of times where a GPS has just gone a bit “special”, and GPS rescue should be treated as both experimental and as a last resort. Ok, having got past the necessary disclaimer, let’s crack on.


Choosing a GPS

Well, first things first – what should you use on your Betaflight quad? Well, it’s more about what not to use. The GPS support in Betaflight doesn’t require a compass, so don’t get a GPS receiver with a built-in compass. They are bigger and more expensive.

I’ve used Beitian GPS’s from Banggood for several projects. Specifically the BN-220, but I also hear good things about the slightly smaller BN-180. I’ve recently checked out the HGLRC M80 GPS receiver in a recent video review as well.


Connecting your GPS

The good news is that connecting up the GPS receiver is fairly trivial. Typically (and certainly in the case of the GPS’s I’ve mentioned) they have 4 connections. GND, VCC, TX & RX. In all the cases I’ve come across so far, the VCC supports 5v, so essentially you are just hooking this up to a spare UART on your flight controller.

At this point, it would feel useful to show a picture of a flight controller and a GPS wired in, but the range and layouts of flight controllers are so vast and varied these days that it seems a bit pointless.

A UART also has a GND, 5V, TX, and RX connection – what a coincidence. So connect the GND on the FC to the GND on the GPS, and similarly the 5v on the FC to the VCC on the GPS. The important thing here though is to make sure you don’t connect the TX and RX on the FC to the same pins on the GPS. This confuses people sometimes because it feels like you should connect the same pins over on both. But quite simply put, a TX sends and an RX receives so connecting up a TX to a TX just results in both ends shouting at each other and nobody listening. So make sure you connect the TX on the FC to the RX on the GPS and the RX on the FC to the TX on the GPS.


Positioning the GPS on your quad

It’s worth explicitly pointing this out, as you’d be surprised at the number of people that manage to connect everything perfectly and then mount their GPS upside down.

The actual receiving antenna side of the GPS is a flat square looking thing with a small metal circular part in the middle. This side has to point upwards. To be fair, this can seem slightly counter-intuitive, the other side will generally have the connector, some nice branding and even some status lights to tell you when you are getting a satellite lock. It seems odd to install the GPS so you can’t see any of this, but it’s what you must do.

A quick word on where to mount your GPS as well. You can see in the above picture I’ve mounted bang on the middle of my top plate. You generally want it away from anything transmitting (even on different frequencies) like a VTX or a telemetry receiver. In a 5″ quad, there’s not an awful lot of room to choose from, but anywhere with an unrestricted view upwards is generally good. I’ve found that telemetry receivers (such as the FrSky R-XSR) can wipe out a GPS signal, so if everything looks good and you aren’t getting a signal – try moving things around to see if your receiver is the problem.


Betaflight Setup

With the physical wiring done (and don’t forget to check and double check those wires) it’s time to jump onto Betaflight and actually set the GPS up. Standard warning again here: When connecting a quad to Betaflight, be sure to remove the props!

The first thing to do is to go to the ports tab and tell Betaflight which UART you have your GPS connected to. This will, of course, depend on your flight controller. In the example here, it’s connected to UART6. I define the sensor input as GPS and a baud rate of 57600. I had defined the baud rate as Auto as the code should work out the rate, but it reset itself to 57600 – so if in doubt, use that.

On to the config tab next. There is a section for the GPS which will be disabled by default, so you’ll need to first enable this using the slider and then select the protocol that your GPS uses. The ones I’ve mentioned all use the UBLOX protocol. This is handy in the fact that UBLOX uses it’s own protocol which makes it possible to use auto baud and auto config. So there’s barely any setup here. But should your GPS use another config (every GPS will generally talk in NMEA) then use the drop down to set it up.

At this point, you probably want to check it’s working in some way. You’ll notice from my screen shots that the GPS isn’t showing up in the list of sensors (where you can see it’s detected a Gyro and Accel) this is because in my case, the UART supplying the GPS needs power from the battery.

You can use the GPS tab to see if any activity is going on. While it’s useful in checking how well your GPS is working – in many cases you are going to be inside your house on a computer where the GPS signal is very bad, so don’t be surprised if you don’t see much activity indoors.

I actually find the fact that my GPS sensor has been detected more useful in terms of performing a basic check. Even though no satellites have been found, it means the GPS is communicating properly with the flight controller. If your GPS is powered on and you don’t see it being detected, then this is a source of worry. Go back and check your physical wiring and your Betaflight setup again.

Now your GPS is installed, you’ll probably want to take advantage of seeing some of that information in your OSD, so your the OSD tab is probably your next port of call.

What you decide to include is up to you, of course, but one essential piece of information you shouldn’t miss out is your GPS satellite count – as you’ll want to know how many sat’s you’ve got locked, and if this suddenly changes in flight. I also find it useful to have a GPS coordinates (although this does clutter the screen a bit) distance from home, home arrow, speed, and altitude.

Another thing that most people will want to setup is GPS rescue mode. The easiest way of doing this is through the failsafe tab (available by enabling Expert mode) Betaflight document all the latest additions to Rescue mode here https://github.com/betaflight/betaflight/wiki/GPS-rescue-mode and it’s very much worth a read.

Everything can be set in the CLI, but I find it easier to work in the failsafe tab. You need to enable GPS rescue as a failsafe mode before you can edit it – but I would strongly recommend you set your failsafe back to the normal “Drop” mode until you have thoroughly tested GPS rescue mode in the field.

There are a few parameters to explain here, and the screenshot shows the parameters that I decided on after testing.

  • Angle – This is the maximum angle your quad will tilt to. It seems a bit of an odd thing to think about, and you need to consider if this is enough tilt to reach the speed you need, to make progress against a headwind etc.
  • Initial Altitude (meters) – This one confused me for a while as I thought it was the altitude that your quad returned to you as, but my initial tests had my quad shooting into the air much higher. Why – because initial altitude is the absolute minimum. By default your quad will choose the highest altitude it’s been at during the flight, add 15m to this, and then fly back at this altitude. In Betaflight 4.1 there’s an option of setting this to a fixed altitude – which I haven’t tried as yet.
  • Descent Distance (meters) – GPS Rescue isn’t a Return to Home mode. If left unchecked it will essentially crash close to the home point. This distance represents the point when the quad will start descending from it’s return altitude, think of it as a guided missile that’s aimed at you. Obviously you want it to descend (if it was up high) as if you’d lost video signal(for example) you’d be able to regain control LOS once you could see it.
  • Ground speed (meters/second) – It’s fairly self explanatory what this is, but I do find the units they used weird. What was up with kph or mph? I tuned this so that it could get through any headwind, but wasn’t going too fast that it would potentially become a deadly missile.
  • Throttle (min/max/hover) – These all go hand in hand, so I’ll describe them together. Betaflight is asking for your hover point and min/max you want to use in rescue mode. I set mine up so that my max isn’t too ballistic and that my minimum kept the props spinning at a reasonable rate. The hover point is actually a little higher than it needs to be, but it all works well.
  • Minimum Satellites – This is the number of satellites that Rescue mode needs to work, it actually defaults to 8. I’d set this lower originally because I was taking an age to get to 8 sats on the ground, although you can use the set gps_rescue_allow_arming_without_fix = ON option in the CLI to allow you to arm without a fix. Why you might want to do this is covered later.
  • Sanity Checks – Generally speaking, this should be on. Sanity checks constantly monitors conditions with the GPS – is it still connected, are we still getting a good signal. In rescue mode are we getting closer to the home point. If these conditions are not met, sanity will abort the rescue mode and drop the quad… so not so good if flying over an unrecoverable area, but for most cases, it should be on.

The way of testing Rescue mode isn’t simply to turn your radio off and see what happens (aside from the fact I told you to change your failsafe back to drop for starters – remember!) You can setup GPS rescue mode on a switch. To do this, head over to the modes tab and setup a switch to handle this. Ideally, I’d suggest using a dedicated switch so it doesn’t have any other function.

I also used the Beep GPS Satellite mode. This is just so I don’t keep having to put my goggles on to check my quads got a lock on the ground and I can have it beep the number of sats back to me.


Testing GPS Rescue

So now for the testing – mainly of rescue mode as everything else in your OSD will simply work with the right GPS signal. One word about getting going though.

The first time your GPS acquires satellites, it can take a good few minutes – but then in subsequent flights it’ll almost be instant. I have noticed though that sometimes, I’ll be sitting there on the ground for 5-10 minutes barely getting 4 or 5 sats.

I’m not sure why this is, perhaps sitting on the ground (ground plane?) does something to the signal. What I’ve noticed is that if I take off and get into the air, in less than 30 seconds I’ll have 8 or 10 sats locked in. For this reason I do recommend that you are able to arm and fly your quad without getting a home lock. As mentioned, you can use the CLI command –

gps_rescue_allow_arming_without_fix = ON

It should go without saying, but if you do need to take off without getting a lock, GPS rescue won’t work, it’ll even flash up a warning to let you know.

So once you do have a good lock and you’ve gone and flown off, get yourself beyond 200m away to test the GPS rescue mode. Make sure you do this in a place you know which is easily recoverable should something go wrong and flick the GPS rescue switch. You should see you quad rise into the air and start to come back to you. In the mode text (if you have it on your OSD) it’ll say “RESC”

Don’t be alarmed if the quad comes back to you without facing you – it’s a weird little quirk of GPS rescue that can feel a bit odd to start with, but you’ll get used to it.

When you engage rescue, you need to be ready to come back into regular flight as well. I keep mode throttle stick about centre and my pitch/roll stick neutral ready to take over. Disengage rescue mode and get used to retaking control – don’t let the quad get to close to you, but just check it’s flying towards you and starting to descend.

Do this procedure again, and again, and again. Make sure there’s absolutely nothing untoward happening, and tune any of the GPS rescue mode parameters as you need to. Only after you are completely happy with the way it’s performing should you setup failsafe to use GPS rescue instead of drop.


How to handle a GPS Rescue mode failsafe

Should you go into a GPS failsafe because you’ve lost signal, there’s one really important thing to do because of the way the failsafe works.

Should GPS Rescue mode kick in because signal is lost, but then signal is regained, it’ll hand control over to you… were you ready ! My advice is to activate your GPS Rescue mode switch should you enter into a failsafe – this will simply continue to fly back to you, and when you are confident your control signal will have returned, then you can deactive the switch and take over just as you had practiced.

If you are in the situation where you radio no longer works, remember you have a homing missile coming towards you, so look out for it coming, and get out of the way !

Happy flying.

One thought to “Setting up a GPS with Betaflight”

Leave a Reply

Your email address will not be published. Required fields are marked *