GPS features in Cleanflight are experimental. Please share your findings with the developers.
GPS works best if the GPS receiver is mounted above and away from other sources of interference.
The compass/mag sensor should be well away from sources of magnetic interference, e.g. keep it away from power wires, motors, ESCs.
Two GPS protocols are supported. NMEA text and UBLOX binary.
Enable the GPS from the CLI as follows:
- configure a serial port to use for GPS.
- set your GPS baud rate
- enable the
- set the
- connect your GPS to the serial port configured for GPS.
- save and reboot.
Note: GPS packet loss has been observed at 115200. Try using 57600 if you experience this.
For the connections step check the Board documentation for pins and port numbers.
gps_provider appropriately, for example
GPS Auto configuration
When using UBLOX it is a good idea to use GPS auto configuration so your FC gets the GPS messages it needs.
Enable GPS auto configuration as follows
If you are not using GPS auto configuration then ensure your GPS receiver sends out the correct messages at the right frequency. See below for manual UBlox settings.
When using a UBLOX GPS the SBAS mode can be configured using
The default is AUTO.
If you use a regional specific setting you may achieve a faster GPS lock than using AUTO.
This setting only works when
GPS Receiver Configuration
UBlox GPS units can either be configured using the FC or manually.
UBlox GPS manual configuration
Use UBox U-Center and connect your GPS to your computer. The CLI
gpspassthrough command may be of use if you do not have a spare USART to USB adapter.
Note that many boards will not provide +5V from USB to the GPS module, such as the SPRacingF3; if you are using
gpspassthrough you may need to connect a BEC to the controller if your board permits it, or use a standalone UART adapter. Check your board documentation to see if your GPS port is powered from USB.
Display the Packet Console (so you can see what messages your receiver is sending to your computer).
Display the Configation View.
Navigate to CFG (Configuration)
Revert to default configuration.
At this point you might need to disconnect and reconnect at the default baudrate - probably 9600 baud.
Navigate to PRT (Ports)
1 - Uart 1
Protocol In to
Protocol Out to
This will immediatly "break" communication to the GPS. Since you haven't saved the new baudrate setting to the non-volatile memory you need to change the baudrate you communicate to the GPS without resetting the GPS. So
Disconnect, Change baud rate to match, then
PRT in the Configuration view again and inspect the packet console to make sure messages are being sent and acknowledged.
Next, to ensure the FC doesn't waste time processing unneeded messages, click on
MSG and enable the following on UART1 alone with a rate of 1. When changing message target and rates remember to click
Send after changing each message.:
NAV-POSLLH NAV-DOP NAV-SOL NAV-VELNED NAV-TIMEUTC
Enable the following on UART1 with a rate of 5, to reduce bandwidth and load on the FC.
All other message types should be disabled.
Next change the global update rate, click
Rate (Rates) in the Configuration view.
Measurement period to
Navigation rate to
This will cause the GPS receive to send the require messages out 10 times a second. If your GPS receiver cannot be set to use
200ms (5hz) - this is less precise.
Next change the mode, click
NAV5 (Navigation 5) in the Configuration View.
Dynamic Model to
Pedestrian and click
Next change the SBAS settings. Click
SBAS (SBAS Settings) in the Configuration View.
PRN Codes to
Finally, we need to save the configuration.
CFG (Configuration in the Configuration View.
Save current configuration and click
UBlox Navigation model
Cleanflight will use
Pedestrian when gps auto config is used.
From the UBlox documentation:
- Pedestrian - Applications with low acceleration and speed, e.g. how a pedestrian would move. Low acceleration assumed. MAX Altitude [m]: 9000, MAX Velocity [m/s]: 30, MAX Vertical, Velocity [m/s]: 20, Sanity check type: Altitude and Velocity, Max Position Deviation: Small.
- Portable - Applications with low acceleration, e.g. portable devices. Suitable for most situations. MAX Altitude [m]: 12000, MAX Velocity [m/s]: 310, MAX Vertical Velocity [m/s]: 50, Sanity check type: Altitude and Velocity, Max Position Deviation: Medium.
- Airborne < 1G - Used for applications with a higher dynamic range and vertical acceleration than a passenger car. No 2D position fixes supported. MAX Altitude [m]: 50000, MAX Velocity [m/s]: 100, MAX Vertical Velocity [m/s]: 100, Sanity check type: Altitude, Max Position Deviation: Large
There are many GPS receivers available on the market. Below are some examples of user-tested hardware.
|U-blox Neo-M8N w/Compass||Pinout can be found in Pixfalcon manual. SDA and SCL can be attached to I2C bus for compass, TX and RX can be attached to UART for GPS. Power must be applied for either to function.|
|Reyax RY825AI||NEO-M8N, 18Hz UART USB interface GPS Glonass BeiDou QZSS antenna module flash. eBay|
|U-blox Neo-7M w/Compass||HobbyKing You have to set align_mag in the CLI to get the magnetometer working correctly:
|Ublox NEO-6M GPS with Compass||eBay|
|MTK 3329||Tested on hardware serial at 115200 baud (default) and on softserial at 19200 baud. The baudrate and refresh rate can be adjusted using the MiniGPS software (recommended if you lower the baudrate). The software will estimate the percentage of UART bandwidth used for your chosen baudrate and update rate.|