中级
30 分钟

使用SARA-R510M8S和PIC18F57Q43以极大的信心导航广阔的LTE IoT领域

体验卓越的LTE无缝物联网

LTE IoT 5 Click with Curiosity Nano with PIC18F57Q43

已发布 6月 24, 2024

点击板

LTE IoT 5 Click

开发板

Curiosity Nano with PIC18F57Q43

编译器

NECTO Studio

微控制器单元

PIC18F57Q43

发现我们先进的LTE物联网解决方案所带来的无限连接力量。通过我们的技术,设备间的通信方式得到了改变,重新定义了可能性,使得超越传统的物联网体验成为可能。

A

A

硬件概览

它是如何工作的?

LTE IoT 5 Click基于SARA-R510M8S,这是一款支持LTE Cat M1/Cat NB2频段的蜂窝模块,配备了来自u-blox的集成高性能标准精密M8 GNSS接收器。它采用了迷你的SARA LGA封装模块,可以直接替代其他u-blox蜂窝模块系列。SARA-R510系列模块提供基于软件的多频段配置,支持LTE Cat M1/NB2无线接入技术,可实现国际多区域覆盖,支持一套全面的3GPP Rel. 14功能,适用于数据传输速率高达1200 kbit/s的物联网应用。SARA-R510M8S的GNSS射频输入设计为50Ω特性阻抗,具有内部直流阻挡器,适用于主动和被动GNSS天线,因为内置的SAW滤波器跟随一个LNA位于集成的高性能u-Blox M8并发定位引擎前面。该模块需要3.8V的电源供应。因此,Click board™集成了由德州仪器(Texas Instruments)标记为TPS7A7002的集成降压(降压DC-DC)转换器。该IC可输出高达3A的电流,保持良好的调节。其任务是提供稳定的3.8V电源,能够在输入出现高电流峰值时(通

常在设备启动时)减小电压下降。SARA-R510M8S使用UART接口与MCU通信,自动波特率检测用于来自外部应用主处理器的模块控制,可以通过u-blox提供的AT命令进行便捷配置。此Click board™还符合USB 2.0规范,配备了USB Type C连接器,最大数据速率为480 Mbit/s,仅用于诊断目的。该模块作为USB设备,可以连接到任何具有兼容驱动程序的USB主机。除了两个女性SMA连接器(用于LTE和主动GNSS天线),LTE IoT 5 Click还具有一个nano-SIM卡槽,可提供多个连接和接口选项。J1标头允许您访问SARA模块的可配置GPIO和EXT中断引脚,而从TP1到TP6标记的测试点可实现模块的轻松固件升级和测试。板载的低电平推按钮标记为PWR,路由到mikroBUS™插座上的AN引脚,代表点火(上电)按钮,成功操作将由STAT LED指示。如果设备已上电,则在此引脚上产生1.5s的低电平脉冲将关闭模块电源。也可以通过发出AT+CPWROFF命令或使用路由到mikroBUS™

插座上的RST引脚的复位功能将模块关闭电源,这将通过在此引脚上产生持续10s的低电平输入来导致突然关闭电源(强制关闭电源)。除了电源LED指示灯外,此Click board™还有两个额外的LED指示灯:黄色LED标记为STAT用于直观指示设备的操作状态,红色LED标记为TX用于指示网络状态。通过uFOTA客户端/服务器解决方案,客户可以通过空中固件更新为其解决方案未来化,该解决方案利用LwM2M,这是一种轻便紧凑的适用于物联网的协议。我们还提供了直接连接到TxD和RxD引脚的可访问测试点,用于固件升级目的。此Click board™可以通过VCC SEL跳线选择3.3V或5V逻辑电压电平运行。这样,既能使用3.3V也能使用5V逻辑电平的MCU可以正确使用通信线路。此外,此Click board™配备了一个包含易于使用的功能和示例代码的库,可用作进一步开发的参考。

LTE IoT 5 Click hardware overview image

功能概述

开发板

PIC18F57Q43 Curiosity Nano 评估套件是一款尖端的硬件平台,旨在评估 PIC18-Q43 系列内的微控制器。其设计的核心是包含了功能强大的 PIC18F57Q43 微控制器(MCU),提供先进的功能和稳健的性能。这个评估套件的关键特点包括一个黄 色用户 LED 和一个响应灵敏的机械用户开关,提供无

缝的交互和测试。为一个 32.768kHz 水晶振荡器足迹提供支持,确保精准的定时能力。套件内置的调试器拥有一个绿色电源和状态 LED,使编程和调试变得直观高效。此外,增强其实用性的还有虚拟串行端口 (CDC)和一个调试 GPIO 通道(DGI GPIO),提供广泛的连接选项。该套件通过 USB 供电,拥有由

 MIC5353 LDO 调节器提供支持的可调目标电压功能,确保在 1.8V 至 5.1V 的输出电压范围内稳定运行,最大输出电流为 500mA,受环境温度和电压限制。

PIC18F57Q43 Curiosity Nano double side image

微控制器概述 

MCU卡片 / MCU

default

建筑

PIC

MCU 内存 (KB)

128

硅供应商

Microchip

引脚数

48

RAM (字节)

8196

你完善了我!

配件

Curiosity Nano Base for Click boards 是一款多功能硬件扩展平台,专为简化 Curiosity Nano 套件与扩展板之间的集成而设计,特别针对符合 mikroBUS™ 标准的 Click 板和 Xplained Pro 扩展板。这款创新的基板(屏蔽板)提供了无缝的连接和扩展可能性,简化了实验和开发过程。主要特点包括从 Curiosity Nano 套件提供 USB 电源兼容性,以及为增强灵活性而提供的另一种外部电源输入选项。板载锂离子/锂聚合物充电器和管理电路确保电池供电应用的平稳运行,简化了使用和管理。此外,基板内置了一个固定的 3.3V 电源供应单元,专用于目标和 mikroBUS™ 电源轨,以及一个固定的 5.0V 升压转换器,专供 mikroBUS™ 插座的 5V 电源轨,为各种连接设备提供稳定的电力供应。

Curiosity Nano Base for Click boards accessories 1 image

LTE扁平旋转天线是提升3G/4G LTE设备性能的多功能选择。其宽频范围为700-2700MHz,确保在全球主要蜂窝频段上实现最佳连接。这款扁平天线采用SMA公头连接器,方便直接连接到您的设备或SMA模块连接器。其突出特点之一是可调节角度,可设置为45⁰的增量(0⁰/45⁰/90⁰),使您可以微调天线的方向以实现最大的信号接收。该天线的阻抗为50Ω,VSWR比率为<2.0:1,确保可靠高效的连接。其5dB增益、垂直极化和全向辐射模式增强了信号强度,适用于各种应用场景。尺寸为196mm×38mm,既紧凑又有效,可提供改善连接的解决方案。最大输入功率为50W,可满足各种设备的需求。

LTE IoT 5 Click accessories 1 image

GNSS主动外置天线是一种来自u-blox的独特的多频段天线,非常适合需要高精度GNSS应用的选择,这些应用需要高度准确的位置能力,比如RTK。ANN-MB-00是一款多频段(L1、L2/E5b/B2I)主动GNSS天线,配有5米长的电缆和SMA连接器。该天线支持GPS、GLONASS、伽利略和北斗,包括高性能的多频段RHCP双馈入补偿天线元件、内置高增益LNA与SAW预滤波器,以及5米长的天线电缆与SMA连接器,具有防水功能。

LTE IoT 5 Click accessories 2 image

使用的MCU引脚

mikroBUS™映射器

Power-On
PA0
AN
Reset
PA7
RST
UART RTS
PD4
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
UART RI
PB0
PWM
UART CTS
PA6
INT
UART TX
PC3
TX
UART RX
PC2
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

LTE IoT 5 Click Schematic schematic

一步一步来

项目组装

Curiosity Nano Base for Click boards front image hardware assembly

从选择您的开发板和Click板™开始。以Curiosity Nano with PIC18F57Q43作为您的开发板开始。

Curiosity Nano Base for Click boards front image hardware assembly
Charger 27 Click front image hardware assembly
PIC18F47Q10 Curiosity Nano front image hardware assembly
Prog-cut hardware assembly
Charger 27 Click complete accessories setup image hardware assembly
Curiosity Nano with PICXXX Access MB 1 - upright/background 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
PIC18F57Q43 Curiosity 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

实时跟踪您的结果

应用程序输出

此款Click板可通过两种方式进行接口连接和监控:

  • Application Output - 在调试模式下,使用“Application Output”窗口进行实时数据监控。按照本教程正确设置它。

软件支持

库描述

该库包含 LTE IoT 5 Click 驱动程序的 API。

关键功能:

  • lteiot5_generic_read - LTE IoT 5数据读取函数

  • lteiot5_send_cmd - 发送命令函数

  • lteiot5_power_on - LTE IoT 5开机

开源

代码示例

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

/*!
 * @file 
 * @brief LTEIoT6 Click example
 * 
 * # Description
 * This example reads and processes data from LTE IoT 5 clicks.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes driver and wake-up module and sets default configuration for connecting device to network.
 * 
 * ## Application Task  
 * Waits for device to connect to network and then sends SMS to selected phone number.
 * 
 * ## Additional Function
 * - static void lteiot5_clear_app_buf ( void )
 * - static void lteiot5_error_check( err_t error_flag )
 * - static void lteiot5_log_app_buf ( void )
 * - static void lteiot5_check_connection( void )
 * - static err_t lteiot5_rsp_check ( void )
 * - static err_t lteiot5_process ( void )
 * 
 * *note:* 
 * In order for the example to work, 
   user needs to set the phone number and sim apn to which he wants to send an SMS
 * Enter valid data for the following macros: SIM_APN and PHONE_NUMBER_TO_MESSAGE.
 * E.g. 
    SIM_APN "vip.mobile"
    PHONE_NUMBER_TO_MESSAGE "999999999"
 * 
 * @author Luka Filipovic
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "lteiot5.h"

#define APP_OK                              0
#define APP_ERROR_DRIVER                    -1
#define APP_ERROR_OVERFLOW                  -2
#define APP_ERROR_TIMEOUT                   -3

#define RSP_OK                              "OK"
#define RSP_ERROR                           "ERROR"

#define SIM_APN                             ""  // Set valid SIM APN
#define PHONE_NUMBER_TO_MESSAGE             ""  // Set Phone number to message
#define MESSAGE_CONTENT                     "LTE IoT 5 Click"   // Messege content 

#define PROCESS_BUFFER_SIZE                 500

#define WAIT_FOR_CONNECTION                 0
#define CONNECTED_TO_NETWORK                1

static lteiot5_t lteiot5;
static log_t logger;

static char app_buf[ PROCESS_BUFFER_SIZE ]  = { 0 };
static int32_t app_buf_len                  = 0;
static int32_t app_buf_cnt                  = 0;

static uint8_t app_connection_status        = WAIT_FOR_CONNECTION;

static err_t app_error_flag;

/**
 * @brief LTE IoT 5 clearing application buffer.
 * @details This function clears memory of application buffer and reset it's length and counter.
 * @note None.
 */
static void lteiot5_clear_app_buf ( void );

/**
 * @brief LTE IoT 5 data reading function.
 * @details This function reads data from device and concats data to application buffer.
 * 
 * @return @li @c  0 - Read some data.
 *         @li @c -1 - Nothing is read.
 *         @li @c -2 - Application buffer overflow.
 *
 * See #err_t definition for detailed explanation.
 * @note None.
 */
static err_t lteiot5_process ( void );

/**
 * @brief LTE IoT 5 check for errors.
 * @details This function checks for different types of errors and logs them on UART.
 * @note None.
 */
static void lteiot5_error_check( err_t error_flag );

/**
 * @brief LTE IoT 5 logs application buffer.
 * @details This function logs data from application buffer.
 * @note None.
 */
static void lteiot5_log_app_buf ( void );

/**
 * @brief LTE IoT 5 response check.
 * @details This function checks for response and returns the status of response.
 * 
 * @return application status.
 * See #err_t definition for detailed explanation.
 * @note None.
 */
static err_t lteiot5_rsp_check ( void );

/**
 * @brief LTE IoT 5 chek connection.
 * @details This function checks connection to the network and 
 *          logs that status to UART.
 * 
 * @note None.
 */
static void lteiot5_check_connection( void );



void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    lteiot5_cfg_t lteiot5_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 " );
    Delay_ms( 1000 );
    
    // Click initialization.
    lteiot5_cfg_setup( &lteiot5_cfg );
    LTEIOT5_MAP_MIKROBUS( lteiot5_cfg, MIKROBUS_1 );
    err_t init_flag  = lteiot5_init( &lteiot5, &lteiot5_cfg );
    if ( init_flag == UART_ERROR )
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }
    
    log_info( &logger, " Power on device... " );
    lteiot5_reset( &lteiot5 );
    lteiot5_power_on( &lteiot5 );
    
    lteiot5_send_cmd( &lteiot5, LTEIOT5_CMD_AT );
    Delay_ms( 500 );
    lteiot5_process(  );
    lteiot5_clear_app_buf(  );
    
    //AT
    lteiot5_send_cmd( &lteiot5, LTEIOT5_CMD_AT );
    app_error_flag = lteiot5_rsp_check();
    lteiot5_error_check( app_error_flag );
    Delay_ms( 500 );
    
    //ATI
    lteiot5_send_cmd( &lteiot5, LTEIOT5_CMD_ATI );
    app_error_flag = lteiot5_rsp_check();
    lteiot5_error_check( app_error_flag );
    Delay_ms( 500 );
    
    //ATI
    lteiot5_send_cmd( &lteiot5, LTEIOT5_CMD_CGMR );
    app_error_flag = lteiot5_rsp_check();
    lteiot5_error_check( app_error_flag );
    Delay_ms( 500 );
    
    //CFUN
    lteiot5_send_cmd_with_parameter( &lteiot5, LTEIOT5_CMD_CFUN, "0" );
    app_error_flag = lteiot5_rsp_check();
    lteiot5_error_check( app_error_flag );
    Delay_ms( 500 );
    
    //COPS
    lteiot5_send_cmd_with_parameter( &lteiot5, LTEIOT5_CMD_COPS, "2" );
    app_error_flag = lteiot5_rsp_check();
    lteiot5_error_check( app_error_flag );
    Delay_ms( 500 );
    
    //CGDCONT
    lteiot5_set_sim_apn( &lteiot5, SIM_APN );
    app_error_flag = lteiot5_rsp_check();
    lteiot5_error_check( app_error_flag );
    Delay_ms( 500 );
    
    //URAT
    lteiot5_send_cmd_with_parameter( &lteiot5, LTEIOT5_CMD_URAT, "7" );
    app_error_flag = lteiot5_rsp_check();
    lteiot5_error_check( app_error_flag );
    Delay_ms( 500 );
    
    //UBANDMASK,
    lteiot5_send_cmd_with_parameter( &lteiot5, LTEIOT5_CMD_UBANDMASK, "0,185473183" );
    app_error_flag = lteiot5_rsp_check();
    lteiot5_error_check( app_error_flag );
    Delay_ms( 500 );
    
    //CFUN
    lteiot5_send_cmd_with_parameter( &lteiot5, LTEIOT5_CMD_CFUN, "1" );
    app_error_flag = lteiot5_rsp_check();
    lteiot5_error_check( app_error_flag );
    Delay_ms( 1000 );
    
    //CFUN
    lteiot5_send_cmd_with_parameter( &lteiot5, LTEIOT5_CMD_CFUN, "16" );
    app_error_flag = lteiot5_rsp_check();
    lteiot5_error_check( app_error_flag );
    Delay_ms( 5000 );
    
    lteiot5_send_cmd_check( &lteiot5, LTEIOT5_CMD_CFUN );
    app_error_flag = lteiot5_rsp_check();
    lteiot5_error_check( app_error_flag );
    Delay_ms( 500 );
    
    //COPS
    lteiot5_send_cmd_check( &lteiot5, LTEIOT5_CMD_COPS );
    app_error_flag = lteiot5_rsp_check();
    lteiot5_error_check( app_error_flag );
    Delay_ms( 500 );
    
    //UANTR
    lteiot5_send_cmd_with_parameter( &lteiot5, LTEIOT5_CMD_UANTR, "0" );
    app_error_flag = lteiot5_rsp_check();
    lteiot5_error_check( app_error_flag );
    Delay_ms( 500 );
    
    //CEREG
    lteiot5_send_cmd_with_parameter( &lteiot5, LTEIOT5_CMD_CEREG, "2" );
    app_error_flag = lteiot5_rsp_check();
    lteiot5_error_check( app_error_flag );
    Delay_ms( 500 );
    
    //CIMI
    lteiot5_send_cmd( &lteiot5, LTEIOT5_CMD_CIMI );
    app_error_flag = lteiot5_rsp_check();
    lteiot5_error_check( app_error_flag );
    Delay_ms( 500 );
    
    app_buf_len = 0;
    app_buf_cnt = 0;
    app_connection_status = WAIT_FOR_CONNECTION;
    log_info( &logger, " Application Task " );
    Delay_ms( 5000 );
}

void application_task ( void )
{  
    if ( app_connection_status == WAIT_FOR_CONNECTION )
    {
        lteiot5_send_cmd_check( &lteiot5, LTEIOT5_CMD_CGATT );
        app_error_flag = lteiot5_rsp_check();
        lteiot5_error_check( app_error_flag );
        Delay_ms( 500 );
        
        lteiot5_send_cmd_check( &lteiot5, LTEIOT5_CMD_CEREG );
        app_error_flag = lteiot5_rsp_check();
        lteiot5_error_check( app_error_flag );
        Delay_ms( 500 );
        
        lteiot5_send_cmd( &lteiot5, LTEIOT5_CMD_CSQ );
        app_error_flag = lteiot5_rsp_check();
        lteiot5_error_check( app_error_flag );
        Delay_ms( 5000 );
    }
    else
    {
        log_info( &logger, "CONNECTED TO NETWORK" );
        
        lteiot5_send_cmd_with_parameter( &lteiot5, "AT+CMGF", "1" );
        app_error_flag = lteiot5_rsp_check();
        lteiot5_error_check( app_error_flag );
        Delay_ms( 3000 );
        
        for( ; ; )
        {   
            log_printf( &logger, "> Sending message to phone number...\r\n" );
            lteiot5_send_text_message( &lteiot5, PHONE_NUMBER_TO_MESSAGE, MESSAGE_CONTENT );
            app_error_flag = lteiot5_rsp_check();
            lteiot5_error_check( app_error_flag );
            Delay_ms( 10000 );
        }
    }
}

void main ( void )
{
    application_init( );

    for ( ; ; )
    {
        application_task( );
    }
}

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

static err_t lteiot5_process ( void )
{
    err_t return_flag = APP_ERROR_DRIVER;
    int32_t rx_size;
    char rx_buff[ PROCESS_BUFFER_SIZE ] = { 0 };
    
    rx_size = lteiot5_generic_read( &lteiot5, rx_buff, PROCESS_BUFFER_SIZE );

    if ( rx_size > 0 )
    { 
        int32_t buf_cnt = 0;
        return_flag = APP_OK;

        if ( app_buf_len + rx_size >= PROCESS_BUFFER_SIZE )
        {
            lteiot5_clear_app_buf(  );
            return_flag = APP_ERROR_OVERFLOW;
        }
        else
        {
            buf_cnt = app_buf_len;
            app_buf_len += rx_size;
        }

        for ( int32_t rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ )
        {
            if ( rx_buff[ rx_cnt ] != 0 ) 
            {
                app_buf[ ( buf_cnt + rx_cnt ) ] = rx_buff[ rx_cnt ];
            }
            else
            {
                app_buf_len--;
            }
        }
    } 

    return return_flag;
}

static err_t lteiot5_rsp_check ( void )
{
    uint16_t timeout_cnt = 0;
    uint16_t timeout = 10000;
    
    err_t error_flag = lteiot5_process(  );
    if ( ( error_flag != 0 ) && ( error_flag != -1 ) )
    {
        return error_flag;
    }
    
    while ( ( strstr( app_buf, RSP_OK ) == 0 ) && ( strstr( app_buf, RSP_ERROR ) == 0 ) )
    {
        error_flag = lteiot5_process(  );
        if ( ( error_flag != 0 ) && ( error_flag != -1 ) )
        {
            return error_flag;
        }
        
        timeout_cnt++;
        if ( timeout_cnt > timeout )
        {
            while ( ( strstr( app_buf, RSP_OK ) == 0 ) && ( strstr( app_buf, RSP_ERROR ) == 0 ) )
            {
                lteiot5_send_cmd( &lteiot5, LTEIOT5_CMD_AT );
                lteiot5_process(  );
                Delay_ms( 100 );
            }
            lteiot5_clear_app_buf(  );
            return APP_ERROR_TIMEOUT;
        }
        
        Delay_ms( 1 );
    }
    
    lteiot5_check_connection();
    
    lteiot5_log_app_buf();
    
    log_printf( &logger, "-----------------------------------\r\n" );
    
    return APP_OK;
}

static void lteiot5_error_check( err_t error_flag )
{
    if ( ( error_flag != 0 ) && ( error_flag != -1 ) )
    {
        switch ( error_flag )
        {
            case -2:
                log_error( &logger, " Overflow!" );
                break;
            case -3:
                log_error( &logger, " Timeout!" );
                break;
            default:
                break;
        }
    }
}

static void lteiot5_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 ] );
    }
    log_printf( &logger, "\r\n" );
    lteiot5_clear_app_buf(  );
}

static void lteiot5_check_connection( void )
{
    #define CONNECTED "+CGATT: 1"
    
    if ( strstr( app_buf, CONNECTED ) != 0 )
    {
        app_connection_status = CONNECTED_TO_NETWORK;
    }
}

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

额外支持

资源

喜欢这个项目吗?

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