强大而多功能的物联网开发工具,提供先进功能、安全连接,并通过 5G 准备工作未来保护。
A
A
硬件概览
它是如何工作的?
IoT ExpressLink 2 Click基于u-blox的SARA-R510AWS,这是一款LTE-M AWS IoT ExpressLink模块。内置的AWS IoT ExpressLink认证软件提供了一套新的定制AT命令集,可以直接访问AWS云,极大地加速了上市时间。它具有基于硬件的根信任的直接AWS IoT云访问、安全引导、uFOTA、FOAT、主机OTA、超低功耗睡眠等功能。该模块提供对AWS服务的访问,无需用户在主机MCU上集成任何额外的API。每个步骤都在模块内部处理。该模块支持TCP/IP、MQTT和TLS/DTLS协议。一些u-blox支持的兼容服务是CellLocate和AWS IoT ExpressLink的零触摸配置。通过使用Cat M1半双工,它可以实现375kbit/s
的下行速率和1200 kbit/s的上行速率。该模块具有SMA天线连接器,可连接适当的天线以提高范围和接收信号强度。Click板™背面的Micro SIM卡槽用于安装微型SIM卡。没有有效的SIM卡,设备无法使用,该SIM卡允许连接到蜂窝网络。支持1.8V和3V (U)SIM卡类型。板上的PWR键用于开启设备。有四个测试点用于测试。其中一个是Power On,其余是Sara模块的reset、TXD和RXD。有一个黄色LED表示异步事件标志。该模块支持USB C连接器提供的高速USB 2.0兼容接口。USB接口支持最高480Mbit/s的数据速率。模块本身作为USB设备,可以连接到任何USB主机。USB接口仅用于诊断目的。模块可以通过USB C连接器或
mikroBUS™插座的5V供电。它使用TPS7A7002进行电压调节,这是一款来自德州仪器的非常低输入和辍电3A稳压器。IoT ExpressLink 2 Click使用标准的2线USRT接口与主机MCU进行通信,固定波特率为115200kbps。除了板上的PWR键,您还可以通过PWR引脚为设备供电。WUP引脚配置为低功耗睡眠状态唤醒引脚。RST用于重置设备。此外,除了提到的黄色LED,事件标志还可以通过EVT引脚进行监视。此Click板™可以通过VCC SEL跳线选择3.3V或5V逻辑电压电平运行。这样,既支持3.3V又支持5V的MCU可以正确使用通信线路。此外,该Click板™配备有一个包含易于使用的函数和示例代码的库,可用作进一步开发的参考。
功能概述
开发板
EasyPIC v8 是一款专为快速开发嵌入式应用的需求而特别设计的开发板。它支持许多高引脚计数的8位PIC微控制器,来自Microchip,无论它们的引脚数量如何,并且具有一系列独特功能,例如首次集成的调试器/程序员。开发板布局合理,设计周到,使得最终用户可以在一个地方找到所有必要的元素,如开关、按钮、指示灯、连接器等。得益于创新的制造技术,EasyPIC v8 提供了流畅而沉浸式的工作体验,允许在任何情况下、任何地方、任何时候都能访问。
EasyPIC v8 开发板的每个部分都包含了使同一板块运行最高效的必要组件。除了先进的集成CODEGRIP程 序/调试模块,该模块提供许多有价值的编程/调试选项和与Mikroe软件环境的无缝集成外,该板还包括一个干净且调节过的开发板电源供应模块。它可以使用广泛的外部电源,包括电池、外部12V电源供应和通过USB Type-C(USB-C)连接器的电源。通信选项如USB-UART、USB DEVICE和CAN也包括在内,包括 广受好评的mikroBUS™标准、两种显示选项(图形和
基于字符的LCD)和几种不同的DIP插座。这些插座覆盖了从最小的只有八个至四十个引脚的8位PIC MCU的广泛范围。EasyPIC v8 是Mikroe快速开发生态系统的一个组成部分。它由Mikroe软件工具原生支持,得益于大量不同的Click板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作和开发的许多方面。
微控制器概述
MCU卡片 / MCU

建筑
PIC
MCU 内存 (KB)
24
硅供应商
Microchip
引脚数
40
RAM (字节)
2048
你完善了我!
配件
使用的MCU引脚
mikroBUS™映射器
“仔细看看!”
Click board™ 原理图

一步一步来
项目组装
实时跟踪您的结果
应用程序输出
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”替换为要显示的参数。

软件支持
库描述
该库包含 IoT ExpressLink 2 Click 驱动程序的 API。
关键功能:
iotexpresslink2_power_on
- 此函数执行开机序列。iotexpresslink2_send_cmd
- 此函数通过使用 UART 串行接口发送命令字符串。iotexpresslink2_generic_read
- 此函数通过使用 UART 串行接口读取所需数量的数据字节。
开源
代码示例
完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio。 应用程序代码也可以在MIKROE的GitHub账户中找到。
/*!
* @file main.c
* @brief IoT ExpressLink 2 Click Example.
*
* # Description
* This example demonstrates the use of IoT ExpressLink 2 Click board by connecting
* to the selected AWS account's data endpoint and showcasing the messaging topic model
* through sending and receiving messages to/from AWS IoT console.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and logger, powers up the device, reads and displays
* the vendor model, thing name, and the PEM certificate of the device. It then sets
* the SIM APN and device endpoint, and attempts to connect to AWS network.
* Finally, it configures the topic name and number and subscribes to it.
*
* ## Application Task
* Sends a desired message on the configured topic and retrieves the next two pending
* messages from the same topic approximately every 10 seconds. The sent message is also
* added to the receive queue because the same topic is used for both sending and receiving.
*
* ## Additional Function
* - static void iotexpresslink2_clear_app_buf ( void )
* - static err_t iotexpresslink2_process ( iotexpresslink2_t *ctx )
* - static err_t iotexpresslink2_read_response ( iotexpresslink2_t *ctx, uint32_t timeout )
*
* @note
* Steps for the very first connection attempt:
* 1. During the initial connection attempt, the device responds with: "ERR14 UNABLE TO CONNECT
* Certificate generation completed. Proceed to register device with AWS cloud and then try
* to connect again".
* 2. At this point, you should restart the system and proceed with registering the device
* with the AWS Cloud using device's thing name and PEM certificate displayed in the logger.
* Detailed steps for registering device are described in the module's application development guide.
* 3. After registering the device with your AWS account, restart the system, and it should
* now successfully connect to the cloud.
*
* @author Stefan Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "iotexpresslink2.h"
// Enter valid APN below for inserted SIM card
#define SIM_APN "internet"
// Enter the device data endpoint below for your AWS account in form:
// xxxxxxxxxxxxxx-ats.iot.us-east-1.amazonaws.com
#define DEVICE_ENDPOINT ""
// Device topic and text message
#define TOPIC_NUM "1"
#define TOPIC_NAME "IoT_ExpressLink_2"
#define TEXT_MESSAGE "IoT ExpressLink 2 Click board - demo message"
// Application buffer size
#define APP_BUFFER_SIZE 900
#define PROCESS_BUFFER_SIZE 100
static iotexpresslink2_t iotexpresslink2;
static log_t logger;
static uint8_t app_buf[ APP_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;
/**
* @brief IoT ExpressLink 2 clearing application buffer.
* @details This function clears memory of application buffer and reset its length.
* @note None.
*/
static void iotexpresslink2_clear_app_buf ( void );
/**
* @brief IoT ExpressLink 2 data reading function.
* @details This function reads data from device and concatenates data to application buffer.
* @param[in] ctx : Click context object.
* See #iotexpresslink2_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 iotexpresslink2_process ( iotexpresslink2_t *ctx );
/**
* @brief IoT ExpressLink read response function.
* @details This function waits for a response message, reads and displays it on the USB UART.
* @param[in] ctx : Click context object.
* See #iotexpresslink_t object definition for detailed explanation.
* @param[in] timeout : Timeout for command response in milliseconds.
* @return @li @c 0 - OK response.
* @li @c -1 - Unknown error.
* @li @c -2 - Timeout error.
* @li @c -3 - Command error.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t iotexpresslink2_read_response ( iotexpresslink2_t *ctx, uint32_t timeout );
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
iotexpresslink2_cfg_t iotexpresslink2_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.
iotexpresslink2_cfg_setup( &iotexpresslink2_cfg );
IOTEXPRESSLINK2_MAP_MIKROBUS( iotexpresslink2_cfg, MIKROBUS_1 );
if ( UART_ERROR == iotexpresslink2_init( &iotexpresslink2, &iotexpresslink2_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_printf( &logger, "Power up device\r\n\n" );
iotexpresslink2_power_on ( &iotexpresslink2 );
log_printf( &logger, "Get vendor model\r\n" );
strcpy ( app_buf, IOTEXPRESSLINK2_CMD_CONF_CHECK );
strcat ( app_buf, IOTEXPRESSLINK2_CMD_SEPARATOR );
strcat ( app_buf, IOTEXPRESSLINK2_CONF_KEY_ABOUT );
iotexpresslink2_send_cmd ( &iotexpresslink2, app_buf );
iotexpresslink2_read_response ( &iotexpresslink2, IOTEXPRESSLINK2_NORMAL_TIMEOUT );
log_printf( &logger, "Get thing name\r\n" );
strcpy ( app_buf, IOTEXPRESSLINK2_CMD_CONF_CHECK );
strcat ( app_buf, IOTEXPRESSLINK2_CMD_SEPARATOR );
strcat ( app_buf, IOTEXPRESSLINK2_CONF_KEY_THING_NAME );
iotexpresslink2_send_cmd ( &iotexpresslink2, app_buf );
iotexpresslink2_read_response ( &iotexpresslink2, IOTEXPRESSLINK2_NORMAL_TIMEOUT );
log_printf( &logger, "Get certificate pem\r\n" );
strcpy ( app_buf, IOTEXPRESSLINK2_CMD_CONF_CHECK );
strcat ( app_buf, IOTEXPRESSLINK2_CMD_SEPARATOR );
strcat ( app_buf, IOTEXPRESSLINK2_CONF_KEY_CERTIFICATE_PEM );
iotexpresslink2_send_cmd ( &iotexpresslink2, app_buf );
iotexpresslink2_read_response ( &iotexpresslink2, IOTEXPRESSLINK2_NORMAL_TIMEOUT );
log_printf( &logger, "Set SIM APN to: %s\r\n", ( char * ) SIM_APN );
strcpy ( app_buf, IOTEXPRESSLINK2_CMD_CONF );
strcat ( app_buf, IOTEXPRESSLINK2_CMD_SEPARATOR );
strcat ( app_buf, IOTEXPRESSLINK2_CONF_KEY_APN );
strcat ( app_buf, IOTEXPRESSLINK2_CMD_SIGN_EQUAL );
strcat ( app_buf, SIM_APN );
iotexpresslink2_send_cmd ( &iotexpresslink2, app_buf );
iotexpresslink2_read_response ( &iotexpresslink2, IOTEXPRESSLINK2_NORMAL_TIMEOUT );
log_printf( &logger, "Set device endpoint to: %s\r\n", ( char * ) DEVICE_ENDPOINT );
strcpy ( app_buf, IOTEXPRESSLINK2_CMD_CONF );
strcat ( app_buf, IOTEXPRESSLINK2_CMD_SEPARATOR );
strcat ( app_buf, IOTEXPRESSLINK2_CONF_KEY_ENDPOINT );
strcat ( app_buf, IOTEXPRESSLINK2_CMD_SIGN_EQUAL );
strcat ( app_buf, DEVICE_ENDPOINT );
iotexpresslink2_send_cmd ( &iotexpresslink2, app_buf );
iotexpresslink2_read_response ( &iotexpresslink2, IOTEXPRESSLINK2_NORMAL_TIMEOUT );
log_printf( &logger, "Trying to connect...\r\n" );
log_printf( &logger, "This may take up to 15min for the initial connect.\r\n" );
iotexpresslink2_send_cmd ( &iotexpresslink2, IOTEXPRESSLINK2_CMD_CONNECT );
if ( IOTEXPRESSLINK2_OK !=
iotexpresslink2_read_response ( &iotexpresslink2, IOTEXPRESSLINK2_CONNECT_TIMEOUT ) )
{
log_printf( &logger, "\r\nUNABLE TO CONNECT\r\n" );
log_printf( &logger, "Make sure that the SIM card is inserted in the board, \r\n" );
log_printf( &logger, "an antenna is connected, and the module is within range \r\n" );
log_printf( &logger, "of a cellular network that provides LTE-M coverage.\r\n" );
log_printf( &logger, "Double check that the device registration procedure have been \r\n" );
log_printf( &logger, "correctly followed. If CONNECT worked in the past for this \r\n" );
log_printf( &logger, "device, it may be that the cellular network has decided \r\n" );
log_printf( &logger, "to refuse service for a \"guard time\" (e.g. 1 hour) because \r\n" );
log_printf( &logger, "the device has connected and disconnected more than a handful \r\n" );
log_printf( &logger, "of times in quick succession. The only way to avoid this is \r\n" );
log_printf( &logger, "avoiding many connections/disconnections. \r\n" );
for ( ; ; );
}
log_printf( &logger, "Set topic %s to: %s\r\n", ( char * ) TOPIC_NUM, ( char * ) TOPIC_NAME );
strcpy ( app_buf, IOTEXPRESSLINK2_CMD_CONF );
strcat ( app_buf, IOTEXPRESSLINK2_CMD_SEPARATOR );
strcat ( app_buf, IOTEXPRESSLINK2_CONF_KEY_TOPIC );
strcat ( app_buf, TOPIC_NUM );
strcat ( app_buf, IOTEXPRESSLINK2_CMD_SIGN_EQUAL );
strcat ( app_buf, TOPIC_NAME );
iotexpresslink2_send_cmd ( &iotexpresslink2, app_buf );
iotexpresslink2_read_response ( &iotexpresslink2, IOTEXPRESSLINK2_NORMAL_TIMEOUT );
log_printf( &logger, "Subscribe to topic %s\r\n", ( char * ) TOPIC_NUM );
strcpy ( app_buf, IOTEXPRESSLINK2_CMD_SUBSCRIBE );
strcat ( app_buf, TOPIC_NUM );
iotexpresslink2_send_cmd ( &iotexpresslink2, app_buf );
iotexpresslink2_read_response ( &iotexpresslink2, IOTEXPRESSLINK2_NORMAL_TIMEOUT );
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
// Send message on topic
log_printf( &logger, "Send message on topic: %s\r\n", ( char * ) TOPIC_NAME );
strcpy ( app_buf, IOTEXPRESSLINK2_CMD_SEND );
strcat ( app_buf, TOPIC_NUM );
strcat ( app_buf, IOTEXPRESSLINK2_CMD_SEPARATOR );
strcat ( app_buf, TEXT_MESSAGE );
iotexpresslink2_send_cmd ( &iotexpresslink2, app_buf );
iotexpresslink2_read_response ( &iotexpresslink2, IOTEXPRESSLINK2_NORMAL_TIMEOUT );
Delay_ms ( 1000 );
// Retrieve the next message received on topic in the order of arrival.
log_printf( &logger, "Request next message pending on topic: %s\r\n", ( char * ) TOPIC_NAME );
strcpy ( app_buf, IOTEXPRESSLINK2_CMD_GET );
strcat ( app_buf, TOPIC_NUM );
iotexpresslink2_send_cmd ( &iotexpresslink2, app_buf );
iotexpresslink2_read_response ( &iotexpresslink2, IOTEXPRESSLINK2_NORMAL_TIMEOUT );
Delay_ms ( 1000 );
// Retrieve the next message received on topic in the order of arrival.
log_printf( &logger, "Request next message pending on topic: %s\r\n", ( char * ) TOPIC_NAME );
strcpy ( app_buf, IOTEXPRESSLINK2_CMD_GET );
strcat ( app_buf, TOPIC_NUM );
iotexpresslink2_send_cmd ( &iotexpresslink2, app_buf );
iotexpresslink2_read_response ( &iotexpresslink2, IOTEXPRESSLINK2_NORMAL_TIMEOUT );
// 8 seconds delay
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
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 iotexpresslink2_clear_app_buf ( void )
{
memset( app_buf, 0, APP_BUFFER_SIZE );
app_buf_len = 0;
}
static void iotexpresslink2_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 iotexpresslink2_process ( iotexpresslink2_t *ctx )
{
uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
int32_t overflow_bytes = 0;
int32_t rx_cnt = 0;
int32_t rx_size = iotexpresslink2_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 IOTEXPRESSLINK2_OK;
}
return IOTEXPRESSLINK2_ERROR;
}
static err_t iotexpresslink2_read_response ( iotexpresslink2_t *ctx, uint32_t timeout )
{
uint32_t timeout_cnt = 0;
iotexpresslink2_clear_app_buf ( );
iotexpresslink2_process( ctx );
while ( ( 0 == strstr( app_buf, IOTEXPRESSLINK2_RSP_OK ) ) &&
( 0 == strstr( app_buf, IOTEXPRESSLINK2_RSP_ERR ) ) )
{
iotexpresslink2_process( ctx );
if ( timeout_cnt++ > timeout )
{
iotexpresslink2_clear_app_buf( );
return IOTEXPRESSLINK2_ERROR_TIMEOUT;
}
Delay_ms ( 1 );
}
Delay_ms ( 100 );
while ( IOTEXPRESSLINK2_OK == iotexpresslink2_process( ctx ) )
{
Delay_ms ( 100 );
}
if ( app_buf_len > 0 )
{
log_printf( &logger, "%s\r\n", app_buf );
}
Delay_ms ( 100 );
if ( strstr( app_buf, IOTEXPRESSLINK2_RSP_OK ) )
{
iotexpresslink2_clear_app_buf( );
return IOTEXPRESSLINK2_OK;
}
else if ( strstr( app_buf, IOTEXPRESSLINK2_RSP_ERR ) )
{
iotexpresslink2_clear_app_buf( );
return IOTEXPRESSLINK2_ERROR_CMD;
}
iotexpresslink2_clear_app_buf( );
return IOTEXPRESSLINK2_ERROR;
}
// ------------------------------------------------------------------------ END