随着我们引入创新的超低功耗Wi-Fi解决方案,您将体验到无缝连接的新时代,重新定义您在移动时保持连接的方式。
A
A
硬件概览
它是如何工作的?
LP WiFi Click基于瑞萨的DA16200MOD-AA,这是一款高度集成的超低功耗WiFi模块,具有最佳的射频性能和舒适的开发环境。它由DA16200 SoC、4MB闪存存储器、射频组件、晶体振荡器、射频集成滤波器和一枚内置的2.4GHz芯片天线组成。这种低功耗操作可以延长电池寿命一年甚至更长,具体取决于应用场景,即使板上持续连接到WiFi网络。该模块还具有强大的物联网安全性,包括用于WiFi和更高堆栈层的身份验证和加密的WPA3和TLS。DA16200MOD具有集成的RTC块(36位实时计数器),带有32.768kHz时钟源,用于SoC的RTC块中的自由运行计数器,
提供电源管理和功能控制以进行低功耗操作。当正常操作期间板上标记为POWER的开关设置为适当的ON位置时,RTC块始终处于通电状态。这样可以优化功耗,并用于开关电源的目的。此外,板的左上角标记为RTC块Pads的标头连接到内部RTC块,用于连接并从外部设备(如传感器)接收外部事件信号。LP WiFi Click使用UART接口作为其默认通信协议与MCU通信。用户可以使用其他接口,如SPI和I2C,以改进和与外围设备通信。值得注意的是,DA16200模块附带的固件仅支持与主机微控制器的UART通信和与传感器等外围设备的I2C通信(SPI接口默认不支持,
可以通过固件更新启用)。此板还具有某些按钮和标头。板载的按钮标记为RESET和WPS,分别表示恢复出厂设置按钮和WiFi Protected Setup(WPS)按钮。至于标头,第一个标有TX和RX信号的标头适用于使用UART接口进行调试,而第二个标头可以通过将其连接到带有I2C信号的右上标头来向设计中添加一个小而明亮、清晰的OLED显示屏。此Click board™只能在3.3V逻辑电压级别下运行。在使用具有不同逻辑电压级别的MCU之前,板必须执行适当的逻辑电压级别转换。此外,它配备了一个包含函数和示例代码的库,可用作进一步开发的参考。
功能概述
开发板
Nucleo-64 搭载 STM32F103RB MCU 提供了一种经济高效且灵活的平台,供开发者探索新想法并原型设计他们的项目。该板利用 STM32 微控制器的多功能性,使用户能够为他们的项目选择最佳的性能与功耗平衡。它配备了 LQFP64 封装的 STM32 微控制器,并包含了如用户 LED(同时作为 ARDUINO® 信号)、用户和复位按钮,以及 32.768kHz 晶体振荡器用于精确的计时操作等基本组件。Nucleo-64 板设计考虑到扩展性和灵活性,它特有的 ARDUINO® Uno
V3 扩展连接器和 ST morpho 扩展引脚头,提供了对 STM32 I/O 的完全访问,以实现全面的项目整合。电源供应选项灵活,支持 ST-LINK USB VBUS 或外部电源,确保在各种开发环境中的适应性。该板还配备了一个具有 USB 重枚举功能的板载 ST-LINK 调试器/编程器,简化了编程和调试过程。此外,该板设计旨在简化高级开发,它的外部 SMPS 为 Vcore 逻辑供电提供高效支持,支持 USB 设备全速或 USB SNK/UFP 全速,并内置加密功能,提升了项目的功效
和安全性。通过外部 SMPS 实验的专用连接器、 用于 ST-LINK 的 USB 连接器以及 MIPI® 调试连接器,提供了更多的硬件接口和实验可能性。开发者将通过 STM32Cube MCU Package 提供的全面免费软件库和示例得到广泛支持。这些,加上与多种集成开发环境(IDE)的兼容性,包括 IAR Embedded Workbench®、MDK-ARM 和 STM32CubeIDE,确保了流畅且高效的开发体验,使用户能够充分利用 Nucleo-64 板在他们的项目中的能力。
微控制器概述
MCU卡片 / MCU

建筑
ARM Cortex-M3
MCU 内存 (KB)
128
硅供应商
STMicroelectronics
引脚数
64
RAM (字节)
20480
你完善了我!
配件
Click Shield for Nucleo-64 配备了两个专有的 mikroBUS™ 插座,使得所有的 Click board™ 设备都可以轻松地与 STM32 Nucleo-64 开发板连接。这样,Mikroe 允许其用户从不断增长的 Click boards™ 范围中添加任何功能,如 WiFi、GSM、GPS、蓝牙、ZigBee、环境传感器、LED、语音识别、电机控制、运动传感器等。您可以使用超过 1537 个 Click boards™,这些 Click boards™ 可以堆叠和集成。STM32 Nucleo-64 开发板基于 64 引脚封装的微控制器,采用 32 位 MCU,配备 ARM Cortex M4 处理器,运行速度为 84MHz,具有 512Kb Flash 和 96KB SRAM,分为两个区域,顶部区域代表 ST-Link/V2 调试器和编程器,而底部区域是一个实际的开发板。通过 USB 连接方便地控制和供电这些板子,以便直接对 Nucleo-64 开发板进行编程和高效调试,其中还需要额外的 USB 线连接到板子上的 USB 迷你接口。大多数 STM32 微控制器引脚都连接到了板子左右边缘的 IO 引脚上,然后连接到两个现有的 mikroBUS™ 插座上。该 Click Shield 还有几个开关,用于选择 mikroBUS™ 插座上模拟信号的逻辑电平和 mikroBUS™ 插座本身的逻辑电压电平。此外,用户还可以通过现有的双向电平转换器,使用任何 Click board™,无论 Click board™ 是否在 3.3V 或 5V 逻辑电压电平下运行。一旦将 STM32 Nucleo-64 开发板与我们的 Click Shield for Nucleo-64 连接,您就可以访问数百个工作于 3.3V 或 5V 逻辑电压电平的 Click boards™。
使用的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”替换为要显示的参数。

软件支持
库描述
该库包含 LP WiFi Click 驱动程序的 API。
关键功能:
lpwifi_send_cmd
- 发送命令函数。lpwifi_connect_to_ap
- 连接到AP函数。lpwifi_factory_reset_device
- 设备恢复出厂设置函数。
开源
代码示例
完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio。 应用程序代码也可以在MIKROE的GitHub账户中找到。
/*!
* @file main.c
* @brief LP WiFi Click Example.
*
* # Description
* This example reads and processes data from LP WiFi clicks.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and powers up the module, then connects to the desired AP
* and creates TCP and UDP servers on the desired local port.
*
* ## Application Task
* Logs all the data received from TCP/UDP clients on the USB UART.
*
* ## Additional Function
* - static void lpwifi_clear_app_buf ( void )
* - static err_t lpwifi_process ( void )
* - static void lpwifi_error_check( err_t error_flag )
* - static void lpwifi_log_app_buf ( void )
* - static err_t lpwifi_rsp_check ( void )
* - static void lpwifi_check_connection( void )
*
* @note
* In order for the example to work, user needs to set the AP SSID, password, and Local port
* on which the TCP server and UDP socket will be created.
* Enter valid data for the following macros: AP_SSID, AP_PASSWORD and LOCAL_PORT.
*
* @author Stefan Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "lpwifi.h"
#include "string.h"
#include "generic_pointer.h"
// Set AP SSID
#define AP_SSID ""
// Set AP password - if the AP is OPEN remain this NULL
#define AP_PASSWORD ""
// Set Local port on which the TCP server and UDP socket will be created.
#define LOCAL_PORT 1
#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 PROCESS_BUFFER_SIZE 400
#define WAIT_FOR_CONNECTION 0
#define CONNECTED_TO_AP 1
#define NOT_CONNECTED_TO_AP 2
static lpwifi_t lpwifi;
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 char assigned_ip_address[ 25 ] = { 0 };
static uint8_t app_connection_status = WAIT_FOR_CONNECTION;
static err_t app_error_flag;
/**
* @brief LP WiFi clearing application buffer.
* @details This function clears memory of application buffer and reset it's length and counter.
* @note None.
*/
static void lpwifi_clear_app_buf ( void );
/**
* @brief LP WiFi 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 lpwifi_process ( void );
/**
* @brief LP WiFi check for errors.
* @details This function checks for different types of errors and logs them on UART.
* @note None.
*/
static void lpwifi_error_check( err_t error_flag );
/**
* @brief LP WiFi logs application buffer.
* @details This function logs data from application buffer.
* @note None.
*/
static void lpwifi_log_app_buf ( void );
/**
* @brief LP WiFi 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 lpwifi_rsp_check ( void );
/**
* @brief LP WiFi check connection.
* @details This function checks connection to the AP, and fills the assigned_ip_address buffer and
* logs the response on the USB UART if it is connected successfully.
*
* @note None.
*/
static void lpwifi_check_connection( void );
/**
* @brief LP WiFi str cut chr function.
* @details This function removes all selected characters from string str,
* and returns it to the same str without those characters.
* @param str Address of string.
* @param chr Character to cut.
*/
static void lpwifi_str_cut_chr ( uint8_t *str, uint8_t chr );
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
lpwifi_cfg_t lpwifi_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 ( 100 );
// Click initialization.
lpwifi_cfg_setup( &lpwifi_cfg );
LPWIFI_MAP_MIKROBUS( lpwifi_cfg, MIKROBUS_1 );
err_t init_flag = lpwifi_init( &lpwifi, &lpwifi_cfg );
if ( UART_ERROR == init_flag )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
lpwifi_default_cfg( &lpwifi );
Delay_ms ( 500 );
// Initiate the communication
lpwifi_send_cmd( &lpwifi, LPWIFI_CMD_AT );
Delay_ms ( 1000 );
// Dummy read
lpwifi_process( );
lpwifi_clear_app_buf( );
log_printf( &logger, "\r\n --- Factory reset --- \r\n" );
lpwifi_factory_reset_device ( &lpwifi );
Delay_ms ( 500 );
// Enable Echo
lpwifi_send_cmd( &lpwifi, LPWIFI_CMD_ATE );
app_error_flag = lpwifi_rsp_check( );
lpwifi_error_check( app_error_flag );
Delay_ms ( 500 );
log_printf( &logger, " ----------------------------------------------- \r\n" );
log_printf( &logger, "\r\n --- Connecting to the access point --- \r\n" );
// Connect to AP
lpwifi_connect_to_ap( &lpwifi, AP_SSID, AP_PASSWORD );
app_error_flag = lpwifi_rsp_check( );
lpwifi_error_check( app_error_flag );
lpwifi_check_connection();
while ( CONNECTED_TO_AP != app_connection_status )
{
lpwifi_check_connection();
if ( NOT_CONNECTED_TO_AP == app_connection_status )
{
Delay_ms ( 500 );
app_connection_status = WAIT_FOR_CONNECTION;
// Connect to AP
lpwifi_connect_to_ap( &lpwifi, AP_SSID, AP_PASSWORD );
app_error_flag = lpwifi_rsp_check( );
lpwifi_error_check( app_error_flag );
}
}
log_printf( &logger, " ----------------------------------------------- \r\n" );
log_printf( &logger, "\r\n --- Creating a TCP server --- \r\n" );
// Create TCP Server
lpwifi_create_tcp_server( &lpwifi, LOCAL_PORT );
app_error_flag = lpwifi_rsp_check( );
lpwifi_error_check( app_error_flag );
Delay_ms ( 500 );
log_printf( &logger, " ----------------------------------------------- \r\n" );
log_printf( &logger, "\r\n --- Creating a UDP socket --- \r\n" );
// Create UDP socket
lpwifi_create_udp_socket( &lpwifi, LOCAL_PORT );
app_error_flag = lpwifi_rsp_check( );
lpwifi_error_check( app_error_flag );
Delay_ms ( 500 );
log_printf( &logger, " ----------------------------------------------- \r\n" );
log_printf( &logger, " TCP server and UDP socket are available at: \r\n" );
log_printf( &logger, " SSID: \"%s\"\r\n IP: %s\r\n Port: %u", ( char * ) AP_SSID,
( char * ) assigned_ip_address,
( uint16_t ) LOCAL_PORT );
log_printf( &logger, "\r\n ----------------------------------------------- \r\n" );
log_printf( &logger, " You can connect to it via a TCP/UDP client." );
log_printf( &logger, "\r\n ----------------------------------------------- \r\n" );
}
void application_task ( void )
{
lpwifi_process( );
lpwifi_log_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 lpwifi_clear_app_buf ( void )
{
memset( app_buf, 0, app_buf_len );
app_buf_len = 0;
app_buf_cnt = 0;
}
static err_t lpwifi_process ( void )
{
int32_t rx_size;
char rx_buff[ PROCESS_BUFFER_SIZE ] = { 0 };
rx_size = lpwifi_generic_read( &lpwifi, rx_buff, PROCESS_BUFFER_SIZE );
if ( rx_size > 0 )
{
int32_t buf_cnt = 0;
if ( app_buf_len + rx_size >= PROCESS_BUFFER_SIZE )
{
lpwifi_clear_app_buf( );
return LPWIFI_ERROR;
}
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--;
buf_cnt--;
}
}
return LPWIFI_OK;
}
return LPWIFI_ERROR;
}
static err_t lpwifi_rsp_check ( void )
{
uint16_t timeout_cnt = 0;
uint16_t timeout = 10000;
err_t error_flag = lpwifi_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 = lpwifi_process( );
if ( ( error_flag != 0 ) && ( error_flag != -1 ) )
{
return error_flag;
}
timeout_cnt++;
if ( timeout_cnt > timeout )
{
// Initialize AT command
while ( ( 0 == strstr( app_buf, RSP_OK ) ) && ( 0 == strstr( app_buf, RSP_ERROR ) ) )
{
lpwifi_send_cmd( &lpwifi, LPWIFI_CMD_ATZ );
lpwifi_process( );
Delay_ms ( 100 );
}
lpwifi_clear_app_buf( );
// Enable Echo
while ( ( 0 == strstr( app_buf, RSP_OK ) ) && ( 0 == strstr( app_buf, RSP_ERROR ) ) )
{
lpwifi_send_cmd( &lpwifi, LPWIFI_CMD_ATE );
lpwifi_process( );
Delay_ms ( 100 );
}
lpwifi_clear_app_buf( );
return APP_ERROR_TIMEOUT;
}
Delay_ms ( 1 );
}
lpwifi_log_app_buf();
return APP_OK;
}
static void lpwifi_error_check( err_t error_flag )
{
if ( ( error_flag != APP_OK ) && ( error_flag != APP_ERROR_DRIVER ) )
{
switch ( error_flag )
{
case APP_ERROR_OVERFLOW:
log_error( &logger, " Overflow!" );
break;
case APP_ERROR_TIMEOUT:
log_error( &logger, " Timeout!" );
break;
default:
break;
}
}
}
static void lpwifi_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 ] );
}
lpwifi_clear_app_buf( );
}
static void lpwifi_check_connection( void )
{
#define CONNECTED "+WFJAP:1"
#define NOT_CONNECTED "+WFJAP:0"
lpwifi_process( );
if ( 0 != strstr( app_buf, CONNECTED ) )
{
#define IP_DELIMITER "',"
char * __generic_ptr app_buf_ptr;
Delay_ms ( 200 );
lpwifi_process( );
app_buf_ptr = strstr( app_buf, IP_DELIMITER );
strcpy( assigned_ip_address, app_buf_ptr );
lpwifi_str_cut_chr( assigned_ip_address, '\'' );
lpwifi_str_cut_chr( assigned_ip_address, ',' );
lpwifi_str_cut_chr( assigned_ip_address, '\r' );
lpwifi_str_cut_chr( assigned_ip_address, '\n' );
lpwifi_log_app_buf( );
app_connection_status = CONNECTED_TO_AP;
}
else if ( 0 != strstr( app_buf, NOT_CONNECTED ) )
{
app_connection_status = NOT_CONNECTED_TO_AP;
}
}
static void lpwifi_str_cut_chr ( uint8_t *str, uint8_t chr )
{
uint16_t cnt_0, cnt_1;
for ( cnt_0 = 0; cnt_0 < strlen( str ); cnt_0++ )
{
if ( str[ cnt_0 ] == chr )
{
for ( cnt_1 = cnt_0; cnt_1 < strlen( str ); cnt_1++ )
{
str[ cnt_1 ] = str[ cnt_1 + 1 ];
}
}
}
}
// ------------------------------------------------------------------------ END