Experience a new era of seamless connectivity as we introduce our innovative ultra-low-power Wi-Fi solution, redefining the way you stay connected on the go.
A
A
Hardware Overview
How does it work?
LP WiFi Click is based on the DA16200MOD-AA, a highly integrated ultra-low power WiFi module with the best RF performance and a comfortable development environment from Renesas. It consists of the DA16200 SoC, 4MB flash memory, RF components, crystal oscillator, RF lumped filter, and an onboard 2.4GHz chip antenna. Such low-power operation can extend the battery life for a year or more, depending on the application, even when the board is continuously connected to the WiFi network. This module also features strong IoT security, including WPA3 and TLS for authentication and encryption at WiFi and higher stack layers. The DA16200MOD has an integrated RTC block (36-bit real-time counter) with a 32.768kHz clock source necessary for the free-running counter in the RTC block of the SoC, which provides power management and function control for low-power operation. The RTC block
is always powered ON when an onboard switch labeled POWER is set to the appropriate ON position during normal operation. This optimizes power consumption and is used for power ON/OFF purposes. Also, the upper left header of the board, labeled as RTC Block Pads, is connected to the internal RTC block to connect and receive external event signals from an external device like a sensor. LP WiFi Click communicates with MCU using the UART interface as its default communication protocol. Users can use other interfaces, such as SPI and I2C, to improve and communicate with peripherals. It should be noted that the DA16200 module comes with firmware that only supports UART communication with the host microcontroller and I2C with peripherals such as sensors (SPI interface is not supported by default and can be enabled by firmware update). Additional options that this board has are certain
buttons and headers. The onboard pushbuttons are labeled RESET, and WPS represents a Factory reset button and WiFi Protected Setup (WPS) button. As for the headers, the first one marked with TX and RX signals is suitable for debugging purposes using the UART interface, while the second lets you add a small but bright and crisp OLED display to your design by connecting it to the upper-right header with I2C signals suitable for controlling the OLED. This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used as a reference for further development.
Features overview
Development board
Nucleo-64 with STM32G071RB MCU offers a cost-effective and adaptable platform for developers to explore new ideas and prototype their designs. This board harnesses the versatility of the STM32 microcontroller, enabling users to select the optimal balance of performance and power consumption for their projects. It accommodates the STM32 microcontroller in the LQFP64 package and includes essential components such as a user LED, which doubles as an ARDUINO® signal, alongside user and reset push-buttons, and a 32.768kHz crystal oscillator for precise timing operations. Designed with expansion and flexibility in mind, the Nucleo-64 board features an ARDUINO® Uno V3 expansion connector and ST morpho extension pin
headers, granting complete access to the STM32's I/Os for comprehensive project integration. Power supply options are adaptable, supporting ST-LINK USB VBUS or external power sources, ensuring adaptability in various development environments. The board also has an on-board ST-LINK debugger/programmer with USB re-enumeration capability, simplifying the programming and debugging process. Moreover, the board is designed to simplify advanced development with its external SMPS for efficient Vcore logic supply, support for USB Device full speed or USB SNK/UFP full speed, and built-in cryptographic features, enhancing both the power efficiency and security of projects. Additional connectivity is
provided through dedicated connectors for external SMPS experimentation, a USB connector for the ST-LINK, and a MIPI® debug connector, expanding the possibilities for hardware interfacing and experimentation. Developers will find extensive support through comprehensive free software libraries and examples, courtesy of the STM32Cube MCU Package. This, combined with compatibility with a wide array of Integrated Development Environments (IDEs), including IAR Embedded Workbench®, MDK-ARM, and STM32CubeIDE, ensures a smooth and efficient development experience, allowing users to fully leverage the capabilities of the Nucleo-64 board in their projects.
Microcontroller Overview
MCU Card / MCU
Architecture
ARM Cortex-M0
MCU Memory (KB)
128
Silicon Vendor
STMicroelectronics
Pin count
64
RAM (Bytes)
36864
You complete me!
Accessories
Click Shield for Nucleo-64 comes equipped with two proprietary mikroBUS™ sockets, allowing all the Click board™ devices to be interfaced with the STM32 Nucleo-64 board with no effort. This way, Mikroe allows its users to add any functionality from our ever-growing range of Click boards™, such as WiFi, GSM, GPS, Bluetooth, ZigBee, environmental sensors, LEDs, speech recognition, motor control, movement sensors, and many more. More than 1537 Click boards™, which can be stacked and integrated, are at your disposal. The STM32 Nucleo-64 boards are based on the microcontrollers in 64-pin packages, a 32-bit MCU with an ARM Cortex M4 processor operating at 84MHz, 512Kb Flash, and 96KB SRAM, divided into two regions where the top section represents the ST-Link/V2 debugger and programmer while the bottom section of the board is an actual development board. These boards are controlled and powered conveniently through a USB connection to program and efficiently debug the Nucleo-64 board out of the box, with an additional USB cable connected to the USB mini port on the board. Most of the STM32 microcontroller pins are brought to the IO pins on the left and right edge of the board, which are then connected to two existing mikroBUS™ sockets. This Click Shield also has several switches that perform functions such as selecting the logic levels of analog signals on mikroBUS™ sockets and selecting logic voltage levels of the mikroBUS™ sockets themselves. Besides, the user is offered the possibility of using any Click board™ with the help of existing bidirectional level-shifting voltage translators, regardless of whether the Click board™ operates at a 3.3V or 5V logic voltage level. Once you connect the STM32 Nucleo-64 board with our Click Shield for Nucleo-64, you can access hundreds of Click boards™, working with 3.3V or 5V logic voltage levels.
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project assembly
Track your results in real time
Application Output via Debug Mode
1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.
2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.
Software Support
Library Description
This library contains API for LP WiFi Click driver.
Key functions:
lpwifi_send_cmd
- Send command function.lpwifi_connect_to_ap
- Connect to AP function.lpwifi_factory_reset_device
- Device factory reset function.
Open Source
Code example
This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.
/*!
* @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