初学者
10 分钟

使用NORA-W256WS和PIC32MZ2048EFH100轻松收集、存储和分析各种应用数据

无线奇迹在等待 – 今天就提升您的技术体验!

IoT ExpressLink 3 Click with Flip&Click PIC32MZ

已发布 6月 27, 2024

点击板

IoT ExpressLink 3 Click

开发板

Flip&Click PIC32MZ

编译器

NECTO Studio

微控制器单元

PIC32MZ2048EFH100

通过 IoT ExpressLink,您可以释放项目的潜力,无缝连接到云端。无需专业知识——我们已经为您提供了全面的安全保障!

A

A

硬件概览

它是如何工作的?

IoT ExpressLink 3 Click 基于 u-blox 的 NORA-W256WS,这是一个独立的多无线电模块。其核心是 ESP32-S3,一款用于无线通信的射频模块,以及来自 Esspressif 的双核 MCU。这个强大的 32 位微控制器拥有 512KB 的 RAM 和 8192KB 的闪存。它具有主机软件 OTA、模块固件 OTA、安全启动、端到端安全(TLS)、MQTT、无状态 AT 命令、WPA/WPA2/WPA3 等功能。预先烧录的 AWS IoT ExpressLink 软件提供即插即用的亚马逊 

Web 服务 (AWS) 连接,您可以利用 AWS 提供的便捷云访问应用程序和所有其他服务。NORA-W256WS 模块带有一个印刷天线,可为两种无线电服务,但一次只能使用一种。模块还配有一个 RGB LED,可视化系统状态。IoT ExpressLink 3 Click 使用标准的 2 线 UART 接口与主 MCU 通信,常用的 UART RX 和 TX 引脚以 115200bps 的波特率工作。ExpressLink 事件可以通过 EVT 引脚进行监控。模块进入待机状态并停止 Wi-Fi,直

到唤醒 WK 引脚被断言。切换此引脚时,模块处于深度睡眠模式下可以进入活动唤醒模式。模块可以通过 RST 引脚复位(重启)。您也可以通过 RESET 按钮重置模块。此外,还可以通过 RSN 引脚重置 ExpressLink。此 Click board™ 只能在 3.3V 逻辑电压水平下运行。使用具有不同逻辑电平的 MCU 之前,板必须进行适当的逻辑电压水平转换。此外,这款 Click board™ 配备了包含易于使用功能和示例代码的库,可用于进一步开发。

IoT ExpressLink 3 Click hardware overview image

功能概述

开发板

Flip&Click PIC32MZ 是一款紧凑型开发板,设计为一套完整的解决方案,它将 Click 板™的灵活性带给您喜爱的微控制器,使其成为实现您想法的完美入门套件。它配备了一款板载 32 位 PIC32MZ 微控制器,Microchip 的 PIC32MZ2048EFH100,四个 mikroBUS™ 插槽用于 Click 板™连接,两个 USB 连接器,LED 指示灯,按钮,调试器/程序员连接器,以及两个与 Arduino-UNO 引脚兼容的头部。得益于创

新的制造技术,它允许您快速构建具有独特功能和特性的小工具。Flip&Click PIC32MZ 开发套件的每个部分都包含了使同一板块运行最高效的必要组件。此外,还可以选择 Flip&Click PIC32MZ 的编程方式,使用 chipKIT 引导程序(Arduino 风格的开发环境)或我们的 USB HID 引导程序,使用 mikroC、mikroBasic 和 mikroPascal for PIC32。该套件包括一个通过 USB 类型-C(USB-C)连接器的干净且调

节过的电源供应模块。所有 mikroBUS™ 本身支持的 通信方法都在这块板上,包括已经建立良好的 mikroBUS™ 插槽、用户可配置的按钮和 LED 指示灯。Flip&Click PIC32MZ 开发套件允许您在几分钟内创建新的应用程序。它由 Mikroe 软件工具原生支持,得益于大量不同的 Click 板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作的许多方面。

Flip&Click PIC32MZ double image

微控制器概述 

MCU卡片 / MCU

default

建筑

PIC32

MCU 内存 (KB)

2048

硅供应商

Microchip

引脚数

100

RAM (字节)

524288

使用的MCU引脚

mikroBUS™映射器

Reset Nora Module
RB11
AN
Device Enable / ID SEL
RE2
RST
Chip Select / ID COMM
RA0
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Module Wake Up
RC14
PWM
Event Interrupt
RD9
INT
UART TX
RE3
TX
UART RX
RG9
RX
NC
NC
SCL
NC
NC
SDA
NC
NC
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

IoT ExpressLink 3 Click Schematic schematic

一步一步来

项目组装

Flip&Click PIC32MZ front image hardware assembly

从选择您的开发板和Click板™开始。以Flip&Click PIC32MZ作为您的开发板开始。

Flip&Click PIC32MZ front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
Flip&Click PIC32MZ MB1 Access - 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
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”替换为要显示的参数。

软件支持

库描述

该库包含 IoT ExpressLink 3 Click 驱动程序的 API。

关键功能:

  • iotexpresslink3_reset_device - 此功能通过切换 RST 引脚状态来重置设备。

  • iotexpresslink3_send_cmd - 此功能通过使用 UART 串行接口发送命令字符串。

开源

代码示例

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

/*!
 * @file main.c
 * @brief IoT ExpressLink 3 Click Example.
 *
 * # Description
 * This example demonstrates the use of IoT ExpressLink 3 click board by bridging the USB UART
 * to mikroBUS UART which allows the click board to establish a connection with
 * the IoT ExpressLink over the Quick Connect demo application without an AWS account.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver, resets the click board to factory default settings, reads
 * and displays the vendor model and thing name on the USB UART, sets the WiFi credentials,
 * and attempts to connect to the AWS Cloud. If the initial attempt fails and the error
 * message "Failed to access network" or "Failed to login AWS (MQTT) broker" appears,
 * check the WiFi credentials and try running the example again.
 *
 * ## Application Task
 * All data received from the USB UART will be forwarded to mikroBUS UART, and vice versa.
 * At this point you should disconnect from the UART terminal and run the Quick Connect
 * demo application.
 *
 * ## Additional Function
 * - static void iotexpresslink3_clear_app_buf ( void )
 * - static err_t iotexpresslink3_process ( iotexpresslink3_t *ctx )
 * - static err_t iotexpresslink3_read_response ( iotexpresslink3_t *ctx )
 *
 * @note
 * To run the demo, follow the below steps:
 * 1. If you opened a terminal application in the previous step, be sure to disconnect that
 *    application from the serial port. 
 * 2. Download the Quick Connect executable: 
 *    Mac: https://quickconnectexpresslinkutility.s3.us-west-2.amazonaws.com/QuickConnect_v1.9_macos.x64.tar.gz
 *    Windows: https://quickconnectexpresslinkutility.s3.us-west-2.amazonaws.com/QuickConnect_v1.9_windows.x64.zip
 *    Linux: https://quickconnectexpresslinkutility.s3.us-west-2.amazonaws.com/QuickConnect_v1.9_linux.x64.tar.gz
 * 3. Unzip the package, and follow the steps from the README file.
 * 
 * The demo will connect to IoT ExpressLink and give you an URL that you can use to visualize data
 * flowing from the device to the cloud using AT+SEND commands. The demo will run for up
 * to two minutes, and afterwards, you will be able to type AT+SEND commands yourself and
 * see the data coming in on the visualizer.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "iotexpresslink3.h"

// Enter valid WiFi credentials below
#define WIFI_SSID               "MikroE Public"     // WiFi SSID
#define WIFI_PASS               "mikroe.guest"      // WiFi Password

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

static iotexpresslink3_t iotexpresslink3;
static log_t logger;

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

/**
 * @brief IoT ExpressLink 3 clearing application buffer.
 * @details This function clears memory of application buffer and reset its length.
 * @note None.
 */
static void iotexpresslink3_clear_app_buf ( void );

/**
 * @brief IoT ExpressLink 3 data reading function.
 * @details This function reads data from device and concatenates data to application buffer. 
 * @param[in] ctx : Click context object.
 * See #iotexpresslink3_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 iotexpresslink3_process ( iotexpresslink3_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.
 * @return @li @c  0 - OK response.
 *         @li @c -2 - Timeout error.
 *         @li @c -3 - Command error.
 *         @li @c -4 - Unknown error.
 * See #err_t definition for detailed explanation.
 * @note None.
 */
static err_t iotexpresslink3_read_response ( iotexpresslink3_t *ctx );

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    iotexpresslink3_cfg_t iotexpresslink3_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.
    iotexpresslink3_cfg_setup( &iotexpresslink3_cfg );
    IOTEXPRESSLINK3_MAP_MIKROBUS( iotexpresslink3_cfg, MIKROBUS_1 );
    if ( UART_ERROR == iotexpresslink3_init( &iotexpresslink3, &iotexpresslink3_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    log_printf( &logger, "Reset device\r\n\n" );
    iotexpresslink3_reset_device ( &iotexpresslink3 );
    Delay_ms ( 2000 );

    log_printf( &logger, "Factory reset\r\n" );
    strcpy ( app_buf, IOTEXPRESSLINK3_CMD_FACTORY_RESET );
    iotexpresslink3_send_cmd ( &iotexpresslink3, app_buf );
    iotexpresslink3_read_response ( &iotexpresslink3 );
    Delay_ms ( 2000 );
    
    log_printf( &logger, "Vendor model\r\n" );
    strcpy ( app_buf, IOTEXPRESSLINK3_CMD_CONF_CHECK );
    strcat ( app_buf, IOTEXPRESSLINK3_CMD_SEPARATOR );
    strcat ( app_buf, IOTEXPRESSLINK3_CONF_KEY_ABOUT );
    iotexpresslink3_send_cmd ( &iotexpresslink3, app_buf );
    iotexpresslink3_read_response ( &iotexpresslink3 );
    
    log_printf( &logger, "Thing name\r\n" );
    strcpy ( app_buf, IOTEXPRESSLINK3_CMD_CONF_CHECK );
    strcat ( app_buf, IOTEXPRESSLINK3_CMD_SEPARATOR );
    strcat ( app_buf, IOTEXPRESSLINK3_CONF_KEY_THING_NAME );
    iotexpresslink3_send_cmd ( &iotexpresslink3, app_buf );
    iotexpresslink3_read_response ( &iotexpresslink3 );
    
    log_printf( &logger, "WiFi SSID\r\n" );
    strcpy ( app_buf, IOTEXPRESSLINK3_CMD_CONF );
    strcat ( app_buf, IOTEXPRESSLINK3_CMD_SEPARATOR );
    strcat ( app_buf, IOTEXPRESSLINK3_CONF_KEY_SSID );
    strcat ( app_buf, IOTEXPRESSLINK3_CMD_SIGN_EQUAL );
    strcat ( app_buf, WIFI_SSID );
    iotexpresslink3_send_cmd ( &iotexpresslink3, app_buf );
    iotexpresslink3_read_response ( &iotexpresslink3 );
    
    log_printf( &logger, "WiFi Password\r\n" );
    strcpy ( app_buf, IOTEXPRESSLINK3_CMD_CONF );
    strcat ( app_buf, IOTEXPRESSLINK3_CMD_SEPARATOR );
    strcat ( app_buf, IOTEXPRESSLINK3_CONF_KEY_PASSPHRASE );
    strcat ( app_buf, IOTEXPRESSLINK3_CMD_SIGN_EQUAL );
    strcat ( app_buf, WIFI_PASS );
    iotexpresslink3_send_cmd ( &iotexpresslink3, app_buf );
    iotexpresslink3_read_response ( &iotexpresslink3 );
    
    log_printf( &logger, "Try to connect\r\n" );
    strcpy ( app_buf, IOTEXPRESSLINK3_CMD_CONNECT );
    iotexpresslink3_send_cmd ( &iotexpresslink3, app_buf );
    iotexpresslink3_read_response ( &iotexpresslink3 );
    
    log_info( &logger, " Application Task " );
    
    log_printf( &logger, "Now close the UART terminal and switch to the QuickConnect app\r\n" );
    Delay_ms ( 1000 );
    
    uart_set_blocking( &logger.uart, false );
}

void application_task ( void ) 
{
    app_buf_len = uart_read( &logger.uart, app_buf, PROCESS_BUFFER_SIZE );
    if ( app_buf_len > 0 ) 
    {
        uart_write ( &iotexpresslink3.uart, app_buf, app_buf_len );
        iotexpresslink3_clear_app_buf( );
    }
    app_buf_len = uart_read( &iotexpresslink3.uart, app_buf, PROCESS_BUFFER_SIZE );
    if ( app_buf_len > 0 ) 
    {
        uart_write ( &logger.uart, app_buf, app_buf_len );
        iotexpresslink3_clear_app_buf( );
    }
}

void main ( void ) 
{
    application_init( );

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

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

static void iotexpresslink3_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 iotexpresslink3_process ( iotexpresslink3_t *ctx ) 
{
    uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
    int32_t overflow_bytes = 0;
    int32_t rx_cnt = 0;
    int32_t rx_size = iotexpresslink3_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 IOTEXPRESSLINK3_OK;
    }
    return IOTEXPRESSLINK3_ERROR;
}


static err_t iotexpresslink3_read_response ( iotexpresslink3_t *ctx ) 
{
    uint32_t timeout_cnt = 0;
    uint32_t timeout = 30000;
    iotexpresslink3_clear_app_buf ( );
    iotexpresslink3_process( ctx );
    while ( ( 0 == strstr( app_buf, IOTEXPRESSLINK3_RSP_OK ) ) &&
            ( 0 == strstr( app_buf, IOTEXPRESSLINK3_RSP_ERR ) ) )
    {
        iotexpresslink3_process( ctx );
        if ( timeout_cnt++ > timeout )
        {
            iotexpresslink3_clear_app_buf( );
            return IOTEXPRESSLINK3_ERROR_TIMEOUT;
        }
        Delay_ms( 1 );
    }
    Delay_ms ( 100 );
    iotexpresslink3_process( ctx );
    if ( app_buf_len > 0 ) 
    {
        log_printf( &logger, "%s\r\n", app_buf );
    }
    if ( strstr( app_buf, IOTEXPRESSLINK3_RSP_OK ) )
    {
        iotexpresslink3_clear_app_buf( );
        return IOTEXPRESSLINK3_OK;
    }
    else if ( strstr( app_buf, IOTEXPRESSLINK3_RSP_ERR ) )
    {
        iotexpresslink3_clear_app_buf( );
        return IOTEXPRESSLINK3_ERROR_CMD;
    }
    iotexpresslink3_clear_app_buf( );
    return IOTEXPRESSLINK3_ERROR_UNKNOWN;
}

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

额外支持

资源

喜欢这个项目吗?

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