Create Your Own GPS Data Publisher Support SSL

Create Your Own GPS Data Publisher Support SSL

Introduction

This blog focuses on how to use the STM32F103C8T6 microcontroller, a GPS module, and a DTU to build a small GPS publisher that can transmit GPS data via MQTT over SSL. This project is designed to help beginners create their own GPS module to access and publish data on their platform.

Background

While there are many GPS products available on the market, most of them lack support for SSL or the capability to process location data on a custom platform. Considering data security and the need for custom data formats, building your own GPS data publisher offers a tailored solution. This DIY project can be used, for example, on robots operating outside to track their locations.

Required Hardware

  • STM32F103C8T6: Microcontroller for controlling the GPS and DTU modules.
  • GPS Module: Used for receiving location data.
  • DTU: DTU Module for transmitting data via MQTT.
  • USB Power Band: Provides 5V power to the GPS and DTU modules.

Wiring and Connections

  • GPS and DTU’s power lines (red and black) are linked to the USB power band, all of them at 5V.

  • GPS’s TX connects to STM32 A10, and GPS’s RX connects to STM32 A9.

  • DTU’s TX connects to STM32 A3, and DTU’s RX connects to STM32 A2.

  • STM32 uses the SWD port for 3.3V and GND.

  • STM32’s BOOT0 is set to 0, and BOOT1 has no connection.

just like these:

Note: The DTU may overheat when used outdoors for extended periods.

Understanding the Indicator Lights on Each Board

GPS Module

The GPS module has two indicator lights:

  • POWER Light: This light is red and indicates that the GPS module is powered on.
  • PPS Light: This light will not be illuminated when the GPS module is not receiving a signal. When it does receive a signal and obtains location data, the light will flash.

DTU Module

The DTU module has two indicator lights:

  • POWER Light: This light is red and indicates that the DTU module is powered on.
  • NETWORK Light: This blue light blinks on for 0.125 seconds and off for 0.125 seconds when transmitting data through 4G. For more detailed information about the indicator lights, please refer to the "Quick Reference" document on page 6.

Logic Flow in the STM32 Program

Setting Up the STM32CubeIDE Project

Configuring Pinout and Frequency

As shown in the picture, configure the pinout as follows:

  • PA10 as USART1_RX and PA9 as USART1_TX for the GPS module to publish data.
  • PA3 as USART2_RX and PA2 as USART2_TX to receive and publish data.

Set the baud rate for both USART1 and USART2 to 115200.

Additionally:

  • Enable the Debug mode at Serial Wire.
  • Enable the USART1 global interrupt.
Setting Global Variables

Here are the global variables set as needed:

#define CUSTOMER_NAME "XX"
#define SITE_NAME "XX"
#define ROBOT_ID "XX"
GIS Coordinate Exchange
...

double latitude = 0.0;
    double longitude = 0.0;
    if (lat[0] != '\0') {
      latitude = atof(lat);
      int lat_deg = (int)(latitude / 100);
      double lat_min = latitude - (lat_deg * 100);
      latitude = lat_deg + lat_min / 60.0;
      if (strcmp(latdir, "S") == 0) latitude = -latitude;
    }
    if (lon[0] != '\0') {
      longitude = atof(lon);
      int lon_deg = (int)(longitude / 100);
      double lon_min = longitude - (lon_deg * 100);
      longitude = lon_deg + lon_min / 60.0;
      if (strcmp(londir, "W") == 0) longitude = -longitude;
    }

...

Setting GPS Module

Use u-center to configure the serial port frequency, publishing frequency, and message type. We use GPRMC to pack GPS data.

First, open u-center and configure the settings:

img

If the GPS module is connected correctly, you can view the location data:

img

Next, use the command line to send commands to disable other messages:

img

24 45 49 47 50 51 2c 44 54 4d 2a 33 42 0d 0a b5 62 06 01 03 00 f0 0a 00 04 23 // Disable GPDTM
24 45 49 47 50 51 2c 47 42 53 2a 33 30 0d 0a b5 62 06 01 03 00 f0 09 00 03 21 // Disable GPGBS
24 45 49 47 50 51 2c 47 47 41 2a 32 37 0d 0a b5 62 06 01 03 00 f0 00 00 fa 0f // Disable GPGGA
24 45 49 47 50 51 2c 47 4c 4c 2a 32 31 0d 0a b5 62 06 01 03 00 f0 01 00 fb 11 // Disable GPGLL
24 45 49 47 50 51 2c 47 52 53 2a 32 30 0d 0a b5 62 06 01 03 00 f0 06 00 00 1b // Disable GPGRS
24 45 49 47 50 51 2c 47 53 41 2a 33 33 0d 0a b5 62 06 01 03 00 f0 02 00 fc 13 // Disable GPGSA
24 45 49 47 50 51 2c 47 53 54 2a 32 36 0d 0a b5 62 06 01 03 00 f0 07 00 01 1d // Disable GPGST
24 45 49 47 50 51 2c 47 53 56 2a 32 34 0d 0a b5 62 06 01 03 00 f0 03 00 fd 15 // Disable GPGSV
24 45 49 47 50 51 2c 56 54 47 2a 32 33 0d 0a b5 62 06 01 03 00 f0 05 00 ff 19 // Disable GPVTG
24 45 49 47 50 51 2c 5a 44 41 2a 33 39 0d 0a b5 62 06 01 03 00 f0 08 00 02 1f // Disable GPZDA

b5 62 06 00 14 00 01 00 00 00 d0 08 00 00 00 c2 01 00 07 00 07 00 00 00 00 00 c4 96 b5 62 06 00 01 00 01 08 22 // Set baud rate to 115200

B5 62 06 08 06 00 C8 00 01 00 01 00 DE 6A B5 62 06 08 00 00 0E 30 // Set 5Hz mode

B5 62 06 09 0D 00 00 00 00 00 FF FF 00 00 00 00 00 00 17 31 BF // Save settings

Setting DTU Module

img

  1. Open YunDTU Config Tool.
  2. Select the serial port from 串口号 (Serial Port Number) and click 打开串口 (Open Serial Port).
  3. Click 读取基本信息 (Read Basic Information) to get the version and IMEI from the DTU.
  4. Set the MQTT broker configuration in the provided fields.
  5. Click 设置所有参数 (Set All Parameters) to save the configuration.
  6. Click 重启设备 (Restart Device) to ensure the DTU runs with the latest configuration.

Outdoor Location Accuracy Test

Get Apple Watch location data

Test Objectives and Content

The objective of this test is to understand the speed and accuracy of the GPS module’s positioning in various outdoor environments, including open areas, building areas, and mixed indoor-outdoor areas. This simulates the deployment on a trolley for trajectory mapping and tracking.

Test Scope
  • Innovation Road on the southwest side of Science Park (simulating a building area)
  • Pak Shek Kok Promenade on the northeast side (simulating an open area)
  • Office area (simulating mixed indoor-outdoor areas)

img

The test standard for comparison is using an Apple Watch Ultra 2 in outdoor walking mode to simultaneously record the trajectory (red trajectory in the picture). It features dual-frequency GPS, providing high positioning accuracy.

The testing method involves starting an outdoor walking record at the 19W main entrance, with the GPS module in working mode, moving counterclockwise:

img

Typical Route Comparison

Starting Point

img

As indicated by the green arrow, when just exiting the 19W building, the positioning is in the initial stage and the building obscures the signal, causing drift and a large dispersion area. Once movement begins, the positioning converges. Both the GPS module and the watch experience this issue initially, but once in motion, the GPS module performs better than the watch.

Long Straight Line Along the Building

img

This part of the walking path is along the fence of Innovation Road. Based on actual experience, the GPS module’s accuracy is superior to the watch’s positioning. The actual position matches the route closely, without drifting to the building side or swinging back and forth.

Mixed Indoor-Outdoor and Crosswalk

img

As shown in the picture, the first arrow indicates taking the elevator to the second floor of the overpass. Entering and exiting the elevator causes slight GPS positioning deviations, which are then corrected.

The second arrow indicates entering and exiting the building’s parking lot. The GPS positioning shows interruptions, with the watch displaying a zigzag line, while the actual movement was straight towards the exit without turning back.

The third arrow indicates walking on the outdoor sidewalk. Based on actual experience, the GPS positioning is more accurate, while the watch trajectory drifts outward and bulges outward, when in reality, the path curves inward.

The fourth arrow indicates crossing the street. The GPS trajectory clearly records the waiting for the traffic light and quickly crossing the street, whereas the watch incorrectly shows me rotating in the middle of the street, which is an incorrect record.

Open Waterfront Area

img

Both devices perform well in the open waterfront area, aligning with the actual route. At the top arrow, I made a U-turn to enter the bike lane, which the GPS module recorded well, but the watch simplified this part of the trajectory.

img

Similarly, when passing under the office building’s sunshade, the GPS accurately shows this process, while the watch shows slight drift.

Summary

Through rooftop testing and outdoor mobile testing, the GPS module’s performance is as follows:

  • Compared to the dual-mode positioning of the watch, the GPS module is more accurate along long straight lines beside buildings, in open areas, and during brief indoor-outdoor transitions. The watch trajectory may have a smoothing logic.
  • During the initial positioning stage, there is a significant deviation due to the low number of satellites, but it quickly converges after waiting a while.
  • The GPS module is susceptible to interference from triangular reflective surfaces, which causes the positioning to continuously drift towards one direction and then stop, especially in balcony corners.
赞赏
Nemo版权所有丨如未注明,均为原创丨本网站采用BY-NC-SA协议进行授权,转载请注明转自:https://nemo.cool/1095.html
# # #
首页      Dev      Robot      Create Your Own GPS Data Publisher Support SSL

Nemo

文章作者

发表回复

textsms
account_circle
email

Create Your Own GPS Data Publisher Support SSL
Introduction This blog focuses on how to use the STM32F103C8T6 microcontroller, a GPS module, and a DTU to build a small GPS publisher that can transmit GPS data via MQTT ove…
扫描二维码继续阅读
2024-05-31