初学者
10 分钟

使用M20071和ATmega328P根据卫星信号确定精确的位置坐标

精确可靠的全球导航和定位解决方案

GNSS 17 Click with Arduino UNO Rev3

已发布 7月 22, 2025

点击板

GNSS 17 Click

开发板

Arduino UNO Rev3

编译器

NECTO Studio

微控制器单元

ATmega328P

同时跟踪GPS、GLONASS、Galileo、BeiDou和QZSS卫星,以提高定位精度,尤其是在城市环境中

A

A

硬件概览

它是如何工作的?

GNSS 17 Click 基于 Antenova 的 M20071,这是一个集成全功能 GNSS 接收器模块。该模块包括 MediaTek AG3335MN 闪存芯片,能够同时跟踪多个 GNSS 星座,如 GPS、GLONASS、GALILEO、BEIDOU 和 QZSS。M20071 的高级多路径算法提高了定位精度,特别是在密集的城市环境中。此外,板载 LNA 确保在弱信号场景下表现出色,非常适合可穿戴设备。此 Click board™ 适用于多种应用,包括便携设备、资产跟踪、个人安全、运动电子和导航系统,提供可靠且精确的定位服务。M20071 还具有几个显著特性,增强了此板的功能。EPO(扩展预测轨道)快速修复功能允许模块使用长达 30 天的轨道预测,实现即时修复解决方案。EASY(自生成轨道预测)功能通过提供长达 3 天的 GPS 轨道预测,无需互联网连接或主处理器上的软件,加速 TTFF(首次定位时间)性能。此外,AIC(主动干扰消除)功能提供有效的窄带干扰消除,确保即使在挑战性环境中也能可靠和准确的 GNSS 性能。M20071 还提供三种

节能模式:关闭、RTC 和周期。在关闭模式下,通过 mikroBUS™ 插座的 EN 引脚控制,模块仅保持电源管理逻辑激活,当 EN 引脚处于低逻辑状态时,所有其他逻辑电路断电。RTC 模式,通过 mikroBUS™ 插座的 RTC 引脚管理,是一种低功耗状态,关闭系统核心。此模式下模块不能发送命令或提供与位置相关的信息,但它会将导航数据保存到 RTC-RAM。唤醒后,模块使用这些保存的数据快速重新获取位置修复。周期模式是一种用户可配置状态,模块在运行和睡眠之间交替,减少电流消耗,同时保持更新的数据。这种灵活性允许用户根据特定的功耗和性能需求调整模块的操作。M20071 模块和主机 MCU 通过 UART 接口进行通信,使用标准 UART RX 和 TX 引脚。默认通信速度设置为 115200bps,确保高效的数据交换。除了 UART TX 和 RX 引脚外,板上还使用 RTS 引脚与主机 MCU 进行握手,以防止丢失命令。此外,GNSS 17 Click 包括一个绿色 PPS LED 指示灯,每秒从 M20071 发出一个同步脉冲信号。此脉冲

信号的默认宽度为 100 ms,但可以配置在 50 ms 到 999 ms 之间。PPS 功能默认启用,一旦达到 3D 修复,模块将输出 PPS 信号。M20071 不需要特定的上电顺序,但其系统核心需要 1.8V 电压才能正常工作。为实现这一点,两个小型 AP2112 LDO 稳压器从 mikroBUS™ 电源轨提供必要的 1.8V 电压,为 M20071 及其 GNSS 天线供电。除了 mikroBUS™ 电源轨外,此板还支持从板背面附加的纽扣电池提供备用电源。负责 GNSS 天线供电的稳压器可以通过 mikroBUS™ 插座的 AON 引脚激活。此 Click board™ 可以通过 VCC SEL 跳线选择使用 3.3V 或 5V 逻辑电压水平。由于 M20071 模块在 1.8V 下工作,使用逻辑电平转换器 TXB0106 以实现正确操作和精确的信号电平转换。因此,3.3V 和 5V 兼容的 MCU 都可以正确使用通信线路。此外,这款 Click board™ 配备了包含易用功能的库和示例代码,可作为进一步开发的参考。

GNSS 17 Click hardware overview image

功能概述

开发板

Arduino UNO 是围绕 ATmega328P 芯片构建的多功能微控制器板。它为各种项目提供了广泛的连接选项,具有 14 个数字输入/输出引脚,其中六个支持 PWM 输出,以及六个模拟输入。其核心组件包括一个 16MHz 的陶瓷谐振器、一个 USB 连接器、一个电

源插孔、一个 ICSP 头和一个复位按钮,提供了为板 子供电和编程所需的一切。UNO 可以通过 USB 连接到计算机,也可以通过 AC-to-DC 适配器或电池供电。作为第一个 USB Arduino 板,它成为 Arduino 平台的基准,"Uno" 符号化其作为系列首款产品的地

位。这个名称选择,意为意大利语中的 "一",是为了 纪念 Arduino Software(IDE)1.0 的推出。最初与 Arduino Software(IDE)版本1.0 同时推出,Uno 自此成为后续 Arduino 发布的基础模型,体现了该平台的演进。

Arduino UNO Rev3 double side image

微控制器概述 

MCU卡片 / MCU

default

建筑

AVR

MCU 内存 (KB)

32

硅供应商

Microchip

引脚数

28

RAM (字节)

2048

你完善了我!

配件

Click Shield for Arduino UNO 具有两个专有的 mikroBUS™ 插座,使所有 Click board™ 设备能够轻松与 Arduino UNO 板进行接口连接。Arduino UNO 是一款基于 ATmega328P 的微控制器开发板,为用户提供了一种经济实惠且灵活的方式来测试新概念并构建基于 ATmega328P 微控制器的原型系统,结合了性能、功耗和功能的多种配置选择。Arduino UNO 具有 14 个数字输入/输出引脚(其中 6 个可用作 PWM 输出)、6 个模拟输入、16 MHz 陶瓷谐振器(CSTCE16M0V53-R0)、USB 接口、电源插座、ICSP 头和复位按钮。大多数 ATmega328P 微控制器的引脚都连接到开发板左右两侧的 IO 引脚,然后再连接到两个 mikroBUS™ 插座。这款 Click Shield 还配备了多个开关,可执行各种功能,例如选择 mikroBUS™ 插座上模拟信号的逻辑电平,以及选择 mikroBUS™ 插座本身的逻辑电压电平。此外,用户还可以通过现有的双向电平转换电压转换器使用任何 Click board™,无论 Click board™ 运行在 3.3V 还是 5V 逻辑电压电平。一旦将 Arduino UNO 板与 Click Shield for Arduino UNO 连接,用户即可访问数百种 Click board™,并兼容 3.3V 或 5V 逻辑电压电平的设备。

Click Shield for Arduino UNO accessories 1 image

主动 GPS 天线旨在增强您的 GPS 和 GNSS Click 板™ 的性能。这款外置天线结构坚固,适用于各种天气条件。凭借 1575.42MHz 的频率范围和 50Ohm 的阻抗,它确保了可靠的信号接收。天线在较宽的角度范围内提供大于 -4dBic 的增益,确保超过 75% 的覆盖率。± 5MHz 的带宽进一步保证了精确的数据采集。天线采用右旋圆极化 (RHCP),提供稳定的信号接收。其紧凑的尺寸为 48.5×39×15mm,配有 2 米长的电缆,安装方便。磁性天线类型与 SMA 公连接器确保了安全便捷的连接。如果您需要为定位设备提供可靠的外置天线,我们的主动 GPS 天线是完美的解决方案。

GNSS 17 Click accessories 1 image

使用的MCU引脚

mikroBUS™映射器

GNSS Antenna Regulator Enable
PC0
AN
Device Enable / ID SEL
PD2
RST
UART RTS / ID COMM
PB2
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
RTC Mode
PD6
PWM
NC
NC
INT
UART TX
PD0
TX
UART RX
PD1
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

GNSS 17 Click Schematic schematic

一步一步来

项目组装

Click Shield for Arduino UNO front image hardware assembly

从选择您的开发板和Click板™开始。以Arduino UNO Rev3作为您的开发板开始。

Click Shield for Arduino UNO front image hardware assembly
Arduino UNO Rev3 front image hardware assembly
Charger 27 Click front image hardware assembly
Prog-cut hardware assembly
Charger 27 Click complete accessories setup image hardware assembly
Board mapper by product8 hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Arduino UNO MCU Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

软件支持

库描述

该库包含 NAME Click 驱动程序的 API。

关键功能:

  • gnss17_generic_read - 此函数通过使用UART串行接口读取所需数量的数据字节。

  • gnss17_parse_gga - 此函数从读取的响应缓冲区解析GGA数据。

  • gnss17_reset_device - 此函数通过切换EN和AON引脚来重置设备。

开源

代码示例

完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio 应用程序代码也可以在MIKROE的GitHub账户中找到。

/*!
 * @file main.c
 * @brief GNSS 17 Click Example.
 *
 * # Description
 * This example demonstrates the use of GNSS 17 Click by reading and displaying
 * the GNSS coordinates.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and resets the Click board.
 *
 * ## Application Task
 * Reads the received data, parses the NMEA GGA info from it, and once it receives 
 * the position fix it will start displaying the coordinates on the USB UART.
 *
 * ## Additional Function
 * - static void gnss17_clear_app_buf ( void )
 * - static void gnss17_log_app_buf ( void )
 * - static err_t gnss17_process ( gnss17_t *ctx )
 * - static void gnss17_parser_application ( uint8_t *rsp )
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "gnss17.h"

// Application buffer size
#define APP_BUFFER_SIZE             500
#define PROCESS_BUFFER_SIZE         200

static gnss17_t gnss17;
static log_t logger;

static uint8_t app_buf[ APP_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;

/**
 * @brief GNSS 17 clearing application buffer.
 * @details This function clears memory of application buffer and reset its length.
 * @note None.
 */
static void gnss17_clear_app_buf ( void );

/**
 * @brief GNSS 17 log application buffer.
 * @details This function logs data from application buffer to USB UART.
 * @note None.
 */
static void gnss17_log_app_buf ( void );

/**
 * @brief GNSS 17 data reading function.
 * @details This function reads data from device and concatenates data to application buffer. 
 * @param[in] ctx : Click context object.
 * See #gnss17_t object definition for detailed explanation.
 * @return @li @c  0 - Read some data.
 *         @li @c -1 - Nothing is read.
 * See #err_t definition for detailed explanation.
 * @note None.
 */
static err_t gnss17_process ( gnss17_t *ctx );

/**
 * @brief GNSS 17 parser application.
 * @param[in] rsp Response buffer.
 * @details This function logs GNSS data on the USB UART.
 * @return None.
 * @note None.
 */
static void gnss17_parser_application ( uint8_t *rsp );

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    gnss17_cfg_t gnss17_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    gnss17_cfg_setup( &gnss17_cfg );
    GNSS17_MAP_MIKROBUS( gnss17_cfg, MIKROBUS_1 );
    if ( UART_ERROR == gnss17_init( &gnss17, &gnss17_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    if ( GNSS17_OK == gnss17_process( &gnss17 ) ) 
    {
        if ( app_buf_len > ( sizeof ( GNSS17_RSP_GGA ) + GNSS17_GGA_ELEMENT_SIZE ) ) 
        {
            gnss17_parser_application( app_buf );
        }
    }
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

static void gnss17_clear_app_buf ( void ) 
{
    memset( app_buf, 0, app_buf_len );
    app_buf_len = 0;
}

static void gnss17_log_app_buf ( void )
{
    for ( int32_t buf_cnt = 0; buf_cnt < app_buf_len; buf_cnt++ )
    {
        log_printf( &logger, "%c", app_buf[ buf_cnt ] );
    }
}

static err_t gnss17_process ( gnss17_t *ctx ) 
{
    uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
    int32_t overflow_bytes = 0;
    int32_t rx_cnt = 0;
    int32_t rx_size = gnss17_generic_read( ctx, rx_buf, PROCESS_BUFFER_SIZE );
    if ( ( rx_size > 0 ) && ( rx_size <= APP_BUFFER_SIZE ) ) 
    {
        if ( ( app_buf_len + rx_size ) > APP_BUFFER_SIZE ) 
        {
            overflow_bytes = ( app_buf_len + rx_size ) - APP_BUFFER_SIZE;
            app_buf_len = APP_BUFFER_SIZE - rx_size;
            memmove ( app_buf, &app_buf[ overflow_bytes ], app_buf_len );
            memset ( &app_buf[ app_buf_len ], 0, overflow_bytes );
        }
        for ( rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ ) 
        {
            if ( rx_buf[ rx_cnt ] ) 
            {
                app_buf[ app_buf_len++ ] = rx_buf[ rx_cnt ];
            }
        }
        return GNSS17_OK;
    }
    return GNSS17_ERROR;
}

static void gnss17_parser_application ( uint8_t *rsp )
{
    uint8_t element_buf[ 200 ] = { 0 };
    if ( GNSS17_OK == gnss17_parse_gga( rsp, GNSS17_GGA_LATITUDE, element_buf ) )
    {
        static uint8_t wait_for_fix_cnt = 0;
        if ( strlen( element_buf ) > 0 )
        {
            log_printf( &logger, "\r\n Latitude: %.2s degrees, %s minutes \r\n", element_buf, &element_buf[ 2 ] );
            memset( element_buf, 0, sizeof( element_buf ) );
            gnss17_parse_gga( rsp, GNSS17_GGA_LONGITUDE, element_buf );
            log_printf( &logger, " Longitude: %.3s degrees, %s minutes \r\n", element_buf, &element_buf[ 3 ] );
            memset( element_buf, 0, sizeof( element_buf ) );
            gnss17_parse_gga( rsp, GNSS17_GGA_ALTITUDE, element_buf );
            log_printf( &logger, " Altitude: %s m \r\n", element_buf );
            wait_for_fix_cnt = 0;
        }
        else
        {
            if ( wait_for_fix_cnt % 5 == 0 )
            {
                log_printf( &logger, " Waiting for the position fix...\r\n\n" );
                wait_for_fix_cnt = 0;
            }
            wait_for_fix_cnt++;
        }
        gnss17_clear_app_buf(  );
    }
}

// ------------------------------------------------------------------------ END

额外支持

资源

喜欢这个项目吗?

'购买此套件' 按钮会直接带您进入购物车,您可以在购物车中轻松添加或移除产品。