Interfacing GPS Module with STM32F103C8 to get GPS Data
There are many projects that can be made using a GPS module with STM32, to name some are GPS logger, Car Tracker, path tracker and many more.
GPS stands for Global Positioning
System and is used to detect the Latitude and Longitude of any location on the
Earth, with exact UTC time (Universal Time Coordinated). This device receives
the coordinates from the satellite for each and every second, with time and
date. GPS offers great accuracy and also provides other data besides position
coordinates.
We all know that GPS is a very useful
device and very commonly used in mobile phones and other portable devices for
tracking the location. It has a very wide range of applications in every field
from calling the taxi at your home to track the altitude of airplanes.
In this tutorial we will learn to interface Neo6MV2 GPS module with STM32F103C8 to find the location coordinate.
Required some
Components
●
STM32F103C8 Microcontroller
●
GPS Module
●
Breadboard
●
Connecting Wires
●
USB TO TTL converter
● ST LINK
GPS Module
GPS module has 4 pins provided out of the module for connections.
1.
Tx Data Transmitting Pin
2.
Rx Data Receiving Pin
3.
Vcc 5V power Supply
4.
GND Power supply ground
It communicates using the Serial pins and can be easily interfaced with the Serial port of the STM32F103C8.
GPS module sends the data in NMEA format. NMEA format consists of several sentences in string format.
STM32F103C8
STM32F103C8 (BLUE PILL) USART serial communication ports. It has three such communication channels.
Circuit
Diagram and Connections
There are connections to the all
setup.
Connect the GPS Module and TTL with
STM32F103C8.
TTL is used to See the GPS data on a
Serial Monitor( you can use Putty , QCOM, Tera Term etc. for Serial
communication).
ST LINK is used for uploading the code. You can also use a USB cable also for uploading the code in the controller.
GPS Module |
STM32F103C8 |
RXD |
PA9 (TX1) |
TXD |
PA10 (RX1) |
5V |
+5V |
GND |
GND |
UART(TTL) |
STM32F103C8 |
RXD |
PA3 (TX2) |
TXD |
PA2 (RX2) |
GND |
GND |
For configure pin assignments, the
clock tree, integrated peripherals, and simulate the power consumption use the
STM32CubeMX.
●
Select STM32F103C8 MCU.
●
Configure RCC HSE(High Speed
Clock) is Crystal/Ceramic Resonator.
●
SYS Debug is Serial wire.
●
Connectivity USART1 and USART2
mode is Asynchronous , sets baud rate 115200 or 9600 and in NVIC interrupt
Table , Enabled USART1 and USART2 globally interrupt .
● Write project Name and select IDE MDK-ARM and Generate Code.
I have used the KEIL Tool for programming.
Write the Receive commands on Usart1 to see GPS data in watch
memory.
●
HAL_UART_Receive(&s_UARTHandle,
buffer, sizeof(buffer), HAL_MAX_DELAY);
Write the Transmit commands on Usart2 to see GPS data on Serial
Monitor.
●
HAL_UART_Transmit(&s_UARTHandle,
buffer, sizeof(buffer), HAL_MAX_DELAY);
We can’t see proper GPS data in watch
memory that’s why we are using Serial monitor QCOM.
According to your requirement you can
Parse GPS Data like Parse Latitude, Longitude, Status, Time, Date, Speed and
Number of satellites.
After building the setup and uploading
the code, make sure to place the GPS module in an open area to receive the
signal fast. Sometimes it takes a few minutes to receive a signal so wait for
some time. The LED will start blinking
in the GPS module when it starts to receive signal and location coordinates
will get data on the Serial Monitor.
These strings are in NMEA format.
Here, you can see all the GPS data and Parse the GPS data also. If you want to parse GPS data then you need to add some function in code for Parsing.
You can verify the latitude and longitude of location by using Google maps.
You can face
some issue like this:
1. If your GPS data is not getting
then
●
Check if the GPS module is
damaged.
●
Try it outdoors under open sky.
●
Try to change the place.
●
Wait for at least 10 min.
●
If the weather is not then you
can face this problem also.
2. It happens in some cases that it is
unable to detect the data that might be the issue with the antenna, so unplug
the antenna( if it is detachable) and attach it again.
Check Website: https://externlabs.com/
Here are some of the projects you can
make now from the knowledge you gained right now.
●
GPS Car tracker
●
GPS Data logger
● IOT GPS tracker
Comments
Post a Comment