Using STM32 and GP-01 Positioning Module to Obtain Latitude and Longitude Information

Introduction to the GP-01 Module

The GP-01 is a high-performance BDS/GNSS multi - constellation satellite navigation receiver SOC module. It integrates the RF front - end, digital baseband processor, 32 - bit RISC CPU, power management, and active antenna detection and protection functions. It supports multiple satellite navigation systems, including China's BDS, the US GPS, and Russia's GLONASS, enabling multi - system joint positioning.

This article uses the GP-01 - Kit development board as an example to introduce how to obtain the latitude and longitude information from the GP-01 via STM32.

1. Hardware Preparation

The hardware involved in this driver includes the GP-01-Kit, STM32F103C8T6 minimum system board, USB - TTL converter, ST - Link, and several jumper wires.

1.1 GP-01 - Kit

 

The GP-01 development board requires a 5V power supply.

1.2 STM32F103C8T6 Core Board or Minimum Development Board

Programming can be done via serial port or using ST - Link or J - Link.

1.3 Wiring

The wiring between the GP-01 - Kit development board and the STM32F103C8T6, as well as between the STM32F103C8T6 and the USB - TTL converter, is shown in the table below.

GP-01-Kit Development Board

STM32F103C8T6

TX

PB11

RX

PB10

USB to TTL

STM32F103C8T6

GND

GND

VCC

V5

TX

PA10

RX

PA9

 

In addition, use an Android cable to connect the GP-01-Kit to the serial port for power supply.

 

2. Software Preparation

2.1 MDK (Keil v5)

Refer to online examples for the download method.

2.2 Serial Port Debugging Assistant(SSCOM)

Used to view the latitude and longitude output information obtained by the STM32 UART drive from the GP-01.

 

3. NMEA

The GP-01 supports the NMEA - 0183 protocol, which outputs data to the serial port after power - on. This data is in the format of all GPS receivers and is the most universal data output format. The NMEA - 0183 protocol defines many sentences, but the most commonly used and widely compatible ones are GPGGA,GPGSA, GPGSV,GPRMC, GPVTG,and GPGLL. To obtain latitude and longitude, focus on the $GNRMC information.

 

The GPRMC protocol is as follows:

GPRMC (It is recommended to use the minimal GPS data format)

$GPRMC,<1>,<2>,<3>,<4>,<5>,<6>,<7>,<8>,<9>,<10>,<11><CR><LF>

(1) Standard positioning time (UTC time) format: hhmmss.sss.

(2) Positioning status, A = data available, V = data not available.

(3) Latitude, format: ddmm.mmmm.

(4) Latitude hemisphere, N for the northern hemisphere or S for the southern hemisphere.

(5) Longitude, format: dddmm.mmmm.

(6) Longitude hemisphere, E for the eastern hemisphere or W for the western hemisphere.

(7) Relative speed, 0.0 to 1851.8 knots.

(8) Relative track made good, 000.0 to 359.9 degrees. Actual value.

(9) Date format: ddmmyy.

(10) Magnetic variation, 000.0 to 180.0.

(11) Degrees.

(12) Checksum.

4. STM32 Program Implementation

Source code acquisition method:

Source code link:https://pan.baidu.com/s/1I8CXlKuAWouwOdgN-9z_1w 

Extraction code: AIXK

 

4.1 Serial Port Code

Communication between GPS and STM32 uses UART3. Below is the initialization code for UART3:

// Initialize IO UART3

// pclk1: PCLK1 clock frequency (Mhz)

// bound: baud rate

void usart3_init(u32 bound)

{

NVIC_InitTypeDef NVIC_InitStructure;

GPIO_InitTypeDef GPIO_InitStructure;

USART_InitTypeDef USART_InitStructure;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); // Enable GPIOB clock

RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); // Enable UART3 clock

USART_DeInit(USART3);  // Reset UART3

// USART3_TX PB10

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; // PB10

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
...
Read more »