惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
P
Privacy International News Feed
P
Proofpoint News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
C
CXSECURITY Database RSS Feed - CXSecurity.com
Know Your Adversary
Know Your Adversary
Security Latest
Security Latest
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Attack and Defense Labs
Attack and Defense Labs
NISL@THU
NISL@THU
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
GbyAI
GbyAI
N
News and Events Feed by Topic
N
News | PayPal Newsroom
Y
Y Combinator Blog
C
CERT Recently Published Vulnerability Notes
N
Netflix TechBlog - Medium
S
Security Affairs
Spread Privacy
Spread Privacy
罗磊的独立博客
腾讯CDC
MyScale Blog
MyScale Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
L
LINUX DO - 热门话题
The Cloudflare Blog
L
LangChain Blog
博客园_首页
H
Hacker News: Front Page
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
博客园 - 聂微东
SecWiki News
SecWiki News
A
Arctic Wolf
爱范儿
爱范儿
Google Online Security Blog
Google Online Security Blog
T
Threat Research - Cisco Blogs
Hacker News - Newest:
Hacker News - Newest: "LLM"
有赞技术团队
有赞技术团队
The GitHub Blog
The GitHub Blog
Cyberwarzone
Cyberwarzone
博客园 - 叶小钗
V
Visual Studio Blog
V
V2EX
T
Tailwind CSS Blog
Project Zero
Project Zero
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
MongoDB | Blog
MongoDB | Blog
D
Docker

Nemo

再见,2025 Complete ORB-SLAM3 Setup Guide for Jetson Xavier NX with RealSense D455 20250723 再见,2024 Using CertBot for Automatic Secure EMQX Broker AGV Dispatching System Technical Documentation Finding Nemo No title 香港賽馬會呈獻系列:黑白——攝影敘事 再见,2023 团团是只猫 Design an FSM for Robot State Machines – Basics of Computer Science Data-driven robot lifespan: Collection 数据驱动的机器人寿命:收集、诊断、预测 Exploring the design space of binary search trees 特首来了 Large language models, explained with a minimum of math and jargon 设计有缓存异步逻辑的监控脚本并测试其资源占用 使用loguru记录串口数据并使用Docker搭建ARM开发环境 在vscode的Dev Container中构建.NET开发环境及使用doxygen和graphviz绘制函数调用图 State or Status? A*算法两种时间复杂度 /A* Algorithm: Two Types of Time Complexity 使用KD-Tree快速收敛到最近坐标点/Fast convergence to the nearest coordinate point using KD-Tree 翻译 || 总结 - Go语言中的空结构体(The empty struct) 再见,2022 从PE工作报告中能读出什么 Give me miles, give me truth AMR调度系统性能优化/AMR Dispatch System Performance Optimization 条件触发AMR避让流程/Conditionally triggered AMR avoidance process Docker实现调度系统整体部署/Docker implementation of dispatching system overall deployment 调度系统中加密算法的使用/增加SM4补0方法/Use of encryption algorithms in scheduling systems/add SM4 complementary 0 method 一篇关于北京四天三夜的攻略 2022 藏疆自驾 策划/招募书 AMR仿真模型/AMR Simulation Model 东东有鱼2022年会分享 使用perf-FlameGraph监控系统性能 Beyond Compare 4删除试用 你的灵魂有香气 Pyinstaller打包Python项目 [转载]Python中的单例模式的几种实现方式的及优化 - Nemo 再见! 2020 1024 UML软件建模 入职优必选一个月 写论文时 那些让你开心的软件 - Nemo 分享一个记录刷题次数的模版 LeetCode-查找表类算法题精析 PyCharm 调用vs 2010 C++库导致提示报错R6034解决方法 MySQL基础教程 多种数据结构的Python实现形式 字节跳动-挑战字符串 选择排序 二分查找和大O表示法 算法中的动态规划问题 高高手课程-青山裕企人像摄影 笔记(内含福利)
Create Your Own GPS Data Publisher Support SSL
Nemo · 2024-05-31 · via Nemo

Introduction

This article 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:

image.png

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

image.png

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;
    }

...
buffer protect

Even tiny software needs a safety design theory. For example, the buffer index needs to be protected, just like in the following code:

...
if (huart->Instance == USART1)
    {
        // Add received data to the buffer
        if (receive_index < BUFFER_SIZE)
        {
            receive_buffer[receive_index++] = gps_buffer[0];
        }
        else
        {
            // Handle buffer overflow error
            char error_msg[] = "Receive buffer overflow!\r\n";
            HAL_UART_Transmit(&huart2, (uint8_t *)error_msg, strlen(error_msg), HAL_MAX_DELAY);

            // Reset buffer and index
            receive_index = 0;
            memset(receive_buffer, 0, BUFFER_SIZE);
        }

        // Check for message start and end conditions
        if (gps_buffer[0] == '\n')
        {
            // Process the received message
            receive_buffer[receive_index] = '\0'; // Null-terminate the string

            // Find the start of the message (find '$' character)
            char *start_ptr = strchr(receive_buffer, '$');
            if (start_ptr != NULL)
            {
                // Process the message starting from '$'
                parse_and_send_gps_data(start_ptr);
            }

            // Reset buffer and index for next message
            receive_index = 0;
            memset(receive_buffer, 0, BUFFER_SIZE);
        }

        // Continue to receive the next byte
        if (HAL_UART_Receive_IT(&huart1, (uint8_t *)gps_buffer, 1) != HAL_OK)
        {
            Error_Handler();
        }
    }
    ...

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:

image.png

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

image.png

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

image.png

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

image.png

  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)

image.png

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:

image.png

Typical Route Comparison

Starting Point

image.png

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

image.png

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

image.png

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

image.png

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.

image.png

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.