中级
30 分钟

使用nRF9160和MK64FN1M0VDC12体验新一代网络

迈入LTE连接的未来

LTE IoT 4 Click with Clicker 2 for Kinetis

已发布 6月 27, 2024

点击板

LTE IoT 4 Click

开发板

Clicker 2 for Kinetis

编译器

NECTO Studio

微控制器单元

MK64FN1M0VDC12

步入连接与智能相融合的世界,选择我们的LTE卓越解决方案。通过采用我们的解决方案,确保您的物联网项目拥有强大、无缝且面向未来的网络支持。

A

A

硬件概览

它是如何工作的?

LTE IoT 4 Click基于nRF9160,这是一款高度集成的System-in-Package (SiP),包含集成的ARM® Cortex®-M33处理器、多模LTE-M/NB-IoT调制解调器、RF前端(RFFE)、GPS和电源管理功能,由Nordic Semiconductor提供。ARM® Cortex®-M33处理器支持1MB闪存和256KB RAM内存,具有先进的安全功能,如Arm CryptoCell,通过提供加密和安全资源来帮助保护您的物联网应用免受攻击威胁。它还内置了辅助GPS,适用于将来自云端的位置信息与GPS卫星数据相结合的跟踪应用,以便远程监控设备的位置。nRF9160经过认证,可以在全球最重要的地区、网络和LTE频段上运行。nRF9160设计充分利用LTE-M和NB-IoT标准的能

效优势。它支持PSM和eDRX省电模式,使nRF9160能够更长时间休眠。在此Click板™的左侧,有一个额外的标记为SWD的头部,通过串行线调试(SWD)接口(SWDIO、SWCLK和SWO)提供完整的调试和编程能力支持。LTE IoT 4 Click使用UART接口与MCU通信,作为默认的通信协议,用户也可以选择使用其他接口,如SPI和I2C,如果他们希望通过这些协议自行配置模块并编写库。它还可以通过mikroBUS™插座上的硬件复位引脚(标记为RST)复位,将此引脚置于低电平状态即可。SiP固件中的GPS功能目前尚不支持。然而,用户可以使用Nordic的SDK和nRF Connect SDK开发自己的固件,并通过SWD接口

更新SiP。LTE调制解调器集成了一个灵活的收发器,频率范围为700至2200 MHz。此外,它具有两个SMA天线连接器,阻抗为50Ω,标记为GPS和LTE,用于连接MIKROE提供的适当天线,如LTE Flat Rotation Antenna和Active GPS Antenna。除了这些SMA连接器之外,该Click板™还具有一个微型SIM卡槽,提供多种连接和接口选项。此Click板™只能在3.3V逻辑电压水平下运行。在使用具有不同逻辑电平的MCU之前,必须进行适当的逻辑电压电平转换。此外,它还配备了一个包含函数和示例代码的库,可用作进一步开发的参考。

LTE IoT 4 Click hardware overview image

功能概述

开发板

Clicker 2 for Kinetis 是一款紧凑型入门开发板,它将 Click 板™的灵活性带给您喜爱的微控制器,使其成为实现您想法的完美入门套件。它配备了一款板载 32 位 ARM Cortex-M4F 微控制器,NXP 半导体公司的 MK64FN1M0VDC12,两个 mikroBUS™ 插槽用于 Click 板™连接,一个 USB 连接器,LED 指示灯,按钮,一个 JTAG 程序员连接器以及两个 26 针头用于与外部电子设备的接口。其紧凑的设计和清晰、易识别的丝网标记让您能够迅速构建具有独特功能和特性

的小工具。Clicker 2 for Kinetis 开发套件的每个部分 都包含了使同一板块运行最高效的必要组件。除了可以选择 Clicker 2 for Kinetis 的编程方式,使用 USB HID mikroBootloader 或外部 mikroProg 连接器进行 Kinetis 编程外,Clicker 2 板还包括一个干净且调节过的开发套件电源供应模块。它提供了两种供电方式;通过 USB Micro-B 电缆,其中板载电压调节器为板上每个组件提供适当的电压水平,或使用锂聚合物 电池通过板载电池连接器供电。所有 mikroBUS™ 本

身支持的通信方法都在这块板上,包括已经建立良好的 mikroBUS™ 插槽、重置按钮和几个用户可配置的按钮及 LED 指示灯。Clicker 2 for Kinetis 是 Mikroe 生态系统的一个组成部分,允许您在几分钟内创建新的应用程序。它由 Mikroe 软件工具原生支持,得益于大量不同的 Click 板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作的许多方面。

Clicker 2 for Kinetis dimensions image

微控制器概述 

MCU卡片 / MCU

default

建筑

ARM Cortex-M4

MCU 内存 (KB)

1024

硅供应商

NXP

引脚数

121

RAM (字节)

262144

你完善了我!

配件

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

LTE IoT 4 Click accessories image

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

LTE IoT 4 Click accessories 2 image

使用的MCU引脚

mikroBUS™映射器

NC
NC
AN
Reset
PB11
RST
SPI Chip Select
PC4
CS
SPI Clock
PC5
SCK
SPI Data OUT
PC7
MISO
SPI Data IN
PC6
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
NC
NC
INT
UART TX
PD3
TX
UART RX
PD2
RX
I2C Clock
PD8
SCL
I2C Data
PD9
SDA
NC
NC
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

LTE IoT 4 Click Schematic schematic

一步一步来

项目组装

Clicker 2 for PIC32MZ front image hardware assembly

从选择您的开发板和Click板™开始。以Clicker 2 for Kinetis作为您的开发板开始。

Clicker 2 for PIC32MZ front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Board mapper by product7 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
Flip&Click PIC32MZ 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

实时跟踪您的结果

应用程序输出

1. 应用程序输出 - 在调试模式下,“应用程序输出”窗口支持实时数据监控,直接提供执行结果的可视化。请按照提供的教程正确配置环境,以确保数据正确显示。

2. UART 终端 - 使用UART Terminal通过USB to UART converter监视数据传输,实现Click board™与开发系统之间的直接通信。请根据项目需求配置波特率和其他串行设置,以确保正常运行。有关分步设置说明,请参考提供的教程

3. Plot 输出 - Plot功能提供了一种强大的方式来可视化实时传感器数据,使趋势分析、调试和多个数据点的对比变得更加直观。要正确设置,请按照提供的教程,其中包含使用Plot功能显示Click board™读数的分步示例。在代码中使用Plot功能时,请使用以下函数:plot(insert_graph_name, variable_name);。这是一个通用格式,用户需要将“insert_graph_name”替换为实际图表名称,并将“variable_name”替换为要显示的参数。

软件支持

库描述

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

关键功能:

  • lteiot4_set_rst - 设置复位引脚的状态

  • lteiot4_send_cmd - 发送命令功能

  • lteiot4_set_sim_apn - 设置SIM卡APN

开源

代码示例

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

/*!
 * @file main.c
 * @brief LTE IoT 4 Click Example.
 *
 * # Description
 * This example reads and processes data from LTE IoT 4 Clicks.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes driver and wake-up module.
 * 
 * ## Application Task  
 * Reads the received data and parses it.
 * 
 * ## Additional Function
 * - static void lteiot4_clear_app_buf ( void )
 * - static void lteiot4_error_check( err_t error_flag )
 * - static void lteiot4_log_app_buf ( void )
 * - static void lteiot4_check_connection( void )
 * - static err_t lteiot4_rsp_check ( void )
 * - static err_t lteiot4_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.
 * E.g. 
    SIM_APN "vip.mobile"
 *
 * @author Luka Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "lteiot4.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 PROCESS_BUFFER_SIZE                 500

#define WAIT_FOR_CONNECTION                 0
#define CONNECTED_TO_NETWORK                1

static lteiot4_t lteiot4;
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 4 clearing application buffer.
 * @details This function clears memory of application buffer and reset it's length and counter.
 * @note None.
 */
static void lteiot4_clear_app_buf ( void );

/**
 * @brief LTE IoT 4 data reading function.
 * @details This function reads data from device and concatenates 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 lteiot4_process ( void );

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

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

/**
 * @brief LTE IoT 4 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 lteiot4_rsp_check ( void );

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

void application_init ( void )
{
    log_cfg_t log_cfg;          /**< Logger config object. */
    lteiot4_cfg_t lteiot4_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.
    lteiot4_cfg_setup( &lteiot4_cfg );
    LTEIOT4_MAP_MIKROBUS( lteiot4_cfg, MIKROBUS_1 );
    err_t init_flag  = lteiot4_init( &lteiot4, &lteiot4_cfg );
    if ( init_flag == UART_ERROR )
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }
    
    log_info( &logger, " Power up device... " );
    lteiot4_default_cfg ( &lteiot4 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    
    lteiot4_process(  );
    lteiot4_process(  );
    lteiot4_process(  );
    lteiot4_clear_app_buf(  );
    
    //AT
    log_info( &logger, " Communication test " );
    lteiot4_send_cmd( &lteiot4, LTEIOT4_CMD_AT );
    app_error_flag = lteiot4_rsp_check();
    lteiot4_error_check( app_error_flag );
    Delay_ms ( 500 );
    
    //CGMM
    log_info( &logger, " Module version " );
    lteiot4_send_cmd( &lteiot4, LTEIOT4_CMD_MODULE_VERSION );
    app_error_flag = lteiot4_rsp_check();
    lteiot4_error_check( app_error_flag );
    Delay_ms ( 500 );
    
    //CGMR
    log_info( &logger, " FW version " );
    lteiot4_send_cmd( &lteiot4, LTEIOT4_CMD_FW_VERSION );
    app_error_flag = lteiot4_rsp_check();
    lteiot4_error_check( app_error_flag );
    Delay_ms ( 500 );
    
    //CFUN
    log_info( &logger, " Flight mode " );
    lteiot4_send_cmd( &lteiot4, LTEIOT4_CMD_FLIGHT_MODE );
    app_error_flag = lteiot4_rsp_check();
    lteiot4_error_check( app_error_flag );
    Delay_ms ( 500 );
    
    //XSYSTEMMODE
    log_info( &logger, " Enable NB network " );
    lteiot4_send_cmd( &lteiot4, LTEIOT4_CMD_NBIOT_MODE );
    app_error_flag = lteiot4_rsp_check();
    lteiot4_error_check( app_error_flag );
    Delay_ms ( 500 );
    
    //CIND
    log_info( &logger, " Enable service and messages " );
    lteiot4_send_cmd( &lteiot4, LTEIOT4_CMD_ENABLE_NET_SMS );
    app_error_flag = lteiot4_rsp_check();
    lteiot4_error_check( app_error_flag );
    Delay_ms ( 500 );
    
    //CFUN
    log_info( &logger, " Full functionalty mode " );
    lteiot4_send_cmd( &lteiot4, LTEIOT4_CMD_FULL_FUNCTION );
    app_error_flag = lteiot4_rsp_check();
    lteiot4_error_check( app_error_flag );
    Delay_ms ( 500 );
    
    //CGDCONT
    log_info( &logger, " Set APN " );
    lteiot4_set_sim_apn( &lteiot4, SIM_APN );
    app_error_flag = lteiot4_rsp_check();
    lteiot4_error_check( app_error_flag );
    Delay_ms ( 500 );
    
    //COPS
    log_info( &logger, " Set automatic network search " );
    lteiot4_send_cmd( &lteiot4, LTEIOT4_CMD_AUTO_NET_SRC );
    app_error_flag = lteiot4_rsp_check();
    lteiot4_error_check( app_error_flag );
    Delay_ms ( 500 );
    
    //CEREG
    log_info( &logger, " Activate search for network  " );
    lteiot4_send_cmd( &lteiot4, LTEIOT4_CMD_SEARCH_NET );
    app_error_flag = lteiot4_rsp_check();
    lteiot4_error_check( app_error_flag );
    Delay_ms ( 500 );
    
    //CIMI
    log_info( &logger, " SIM test " );
    lteiot4_send_cmd( &lteiot4, LTEIOT4_CMD_SIM_TEST );
    app_error_flag = lteiot4_rsp_check();
    lteiot4_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\r\n" );
    log_printf( &logger, "-------------------------------\r\n" );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
}

void application_task ( void )
{
    if ( app_connection_status == WAIT_FOR_CONNECTION )
    {
        //CEREG
        log_info( &logger, " Check connection  " );
        lteiot4_send_cmd( &lteiot4, LTEIOT4_CMD_CHECK_CONNECTION );
        app_error_flag = lteiot4_rsp_check();
        lteiot4_error_check( app_error_flag );
        Delay_ms ( 500 );
        
        //CEREG
        log_info( &logger, " Check network status  " );
        lteiot4_send_cmd( &lteiot4, LTEIOT4_CMD_CHECK_REGISTARTION );
        app_error_flag = lteiot4_rsp_check();
        lteiot4_error_check( app_error_flag );
        Delay_ms ( 500 );
        
        //CEREG
        log_info( &logger, " Check signal quality  " );
        lteiot4_send_cmd( &lteiot4, LTEIOT4_CMD_SIGNAL_QUALITY );
        app_error_flag = lteiot4_rsp_check();
        lteiot4_error_check( app_error_flag );
        log_printf( &logger, "-------------------------------\r\n" );
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
    }
    else
    {
        log_info( &logger, "CONNECTED TO NETWORK\r\n" );
        log_printf( &logger, "-------------------------------\r\n" );
        //CCLK
        log_info( &logger, " Set Time " );
        lteiot4_send_cmd( &lteiot4, LTEIOT4_CMD_SET_DUMMY_CLOCK );
        app_error_flag = lteiot4_rsp_check();
        lteiot4_error_check( app_error_flag );
        log_printf( &logger, "-------------------------------\r\n" );
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
        
        for(;;)
        {
            //XTEMP
            log_info( &logger, " Check Temperature " );
            lteiot4_send_cmd( &lteiot4, LTEIOT4_CMD_CHECK_TEMPERATURE );
            app_error_flag = lteiot4_rsp_check();
            lteiot4_error_check( app_error_flag );
            Delay_ms ( 500 );
            //CCLK
            log_info( &logger, " Check Time " );
            lteiot4_send_cmd( &lteiot4, LTEIOT4_CMD_CHECK_CLOCK );
            app_error_flag = lteiot4_rsp_check();
            lteiot4_error_check( app_error_flag );
            log_printf( &logger, "-------------------------------\r\n" );
            Delay_ms ( 1000 );
            Delay_ms ( 1000 );
            Delay_ms ( 1000 );
            Delay_ms ( 1000 );
            Delay_ms ( 1000 );
        }
    }
}

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 lteiot4_clear_app_buf ( void )
{
    memset( app_buf, 0, app_buf_len );
    app_buf_len = 0;
    app_buf_cnt = 0;
}

static err_t lteiot4_process ( void )
{
    err_t return_flag = APP_ERROR_DRIVER;
    int32_t rx_size;
    char rx_buff[ PROCESS_BUFFER_SIZE ] = { 0 };
    
    rx_size = lteiot4_generic_read( &lteiot4, 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 )
        {
            lteiot4_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 lteiot4_rsp_check ( void )
{
    uint16_t timeout_cnt = 0;
    uint16_t timeout = 5000;
    
    err_t error_flag = lteiot4_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 = lteiot4_process(  );
        if ( ( error_flag != 0 ) && ( error_flag != -1 ) )
        {
            return error_flag;
        }
        
        timeout_cnt++;
        if ( timeout_cnt > timeout )
        {
            lteiot4_clear_app_buf(  );
            return APP_ERROR_TIMEOUT;
        }
        
        Delay_ms ( 1 );
    }
    
    lteiot4_check_connection();
    
    lteiot4_log_app_buf();
    
    return APP_OK;
}

static void lteiot4_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 lteiot4_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" );
    lteiot4_clear_app_buf(  );
}

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


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

额外支持

资源

喜欢这个项目吗?

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