Bluetooth LE connectivity with advanced features like direction finding and NFC
A
A
Hardware Overview
How does it work?
BL653 Click is based on the BL653, a longer-range Bluetooth LE module for next-generation industrial IoT from Ezurio. This module, powered by Nordic’s nRF52833 silicon, integrates a powerful Cortex-M4F microcontroller, offering 512kB of flash memory and 128kB of RAM for hostless operation and efficient application processing. With its multi-wireless capabilities (Bluetooth v5.4 and NFC) and modular certifications for FCC, ISED, EU, RCM, MIC, KC, AS/NZS, and Bluetooth SIG, the BL653 Click ensures quick and hassle-free deployment in global markets. It represents the future of wireless Industrial Internet of Things (IIoT) connectivity to implement reliable wireless communication in even the harshest operating environments. This Click board™ provides a wide range of configurable interfaces, including UART, I2C, SPI, USB, and NFC, allowing easy integration into diverse industrial systems. It supports peripheral and central Bluetooth LE roles, enabling data collection, device control, and proximity-sensing applications. Its support for Bluetooth 5.4 features like direction finding (AoA and AoD) and multiple data rates, including 2Mbps, 1Mbps, and 125kbps coded PHY, ensures high-performance communication over long distances. It can be easily programmed using a simple AT command set, Zephyr RTOS, or the
Nordic SDK, allowing developers to create event-driven, automated applications or implement custom solutions. This Click board™ establishes communication between the BL653 module and the host MCU through a UART interface, using standard UART RX and TX pins and hardware flow control via CTS and RTS pins. The default communication speed is set at 115200bps, ensuring efficient data exchange. The host MCU configures communication and other features using high-level AT commands, making it easy to manage without requiring in-depth knowledge of Bluetooth protocol. Additionally, the board includes an SPI interface with a maximum clock speed of 8MHz and an I2C interface with a maximum clock speed of 400kHz. In addition to the interface pins, the board features a reset (RST) pin for hard resetting the module when necessary and an ARN pin as AutoRUN signal of the BL653 module that selects between the two BL653 operating modes at power-up: self-contained run mode or interactive/development mode. This board also includes a USB Type-C connector for USB 2.0 Full Speed 12Mbps hardware capability, allowing both power supply and configuration via a PC. This functionality is enabled by the CP2102N, a highly integrated USB-to-UART bridge, along with the
NCP1117 LDO regulator, which converts the USB supply to the necessary 3.3V for the module. BL653 Click also includes dedicated pins for NFC support, fully compliant with the NFC Forum specification. This feature operates at 13.56MHz with a data rate of 106kbps, supporting NFC Type 2 and Type 4 tag emulation. It offers multiple modes of operation, including disable, sense, and activated, providing flexibility for integrating advanced NFC functionalities into your applications. Additionally, the board features two user-configurable buttons (BTN1 and BTN2) and two user-configurable LED indicators (a blue LED1 and an orange LED2) for customizable user interaction and status indication. For development and debugging purposes, the Click board™ is equipped with unsoldered pins for an SWD interface, enabling easy access to programming and debugging functionalities. 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. It also comes equipped with a library containing functions and example code that can be used as a reference for further development.
Features overview
Development board
Arduino UNO is a versatile microcontroller board built around the ATmega328P chip. It offers extensive connectivity options for various projects, featuring 14 digital input/output pins, six of which are PWM-capable, along with six analog inputs. Its core components include a 16MHz ceramic resonator, a USB connection, a power jack, an
ICSP header, and a reset button, providing everything necessary to power and program the board. The Uno is ready to go, whether connected to a computer via USB or powered by an AC-to-DC adapter or battery. As the first USB Arduino board, it serves as the benchmark for the Arduino platform, with "Uno" symbolizing its status as the
first in a series. This name choice, meaning "one" in Italian, commemorates the launch of Arduino Software (IDE) 1.0. Initially introduced alongside version 1.0 of the Arduino Software (IDE), the Uno has since become the foundational model for subsequent Arduino releases, embodying the platform's evolution.
Microcontroller Overview
MCU Card / MCU

Architecture
AVR
MCU Memory (KB)
32
Silicon Vendor
Microchip
Pin count
28
RAM (Bytes)
2048
You complete me!
Accessories
Click Shield for Arduino UNO has two proprietary mikroBUS™ sockets, allowing all the Click board™ devices to be interfaced with the Arduino UNO board without effort. The Arduino Uno, a microcontroller board based on the ATmega328P, provides an affordable and flexible way for users to try out new concepts and build prototypes with the ATmega328P microcontroller from various combinations of performance, power consumption, and features. The Arduino Uno has 14 digital input/output pins (of which six can be used as PWM outputs), six analog inputs, a 16 MHz ceramic resonator (CSTCE16M0V53-R0), a USB connection, a power jack, an ICSP header, and reset button. Most of the ATmega328P 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 Arduino UNO board with our Click Shield for Arduino UNO, 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
Click board™ Schematic

Step by step
Project assembly
Track your results in real time
Application Output
1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support
Library Description
BL653 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Example Description
This example demonstrates the use of BL653 Click board by processing data from a connected BT device.
Key functions:
bl653_cfg_setup
- Config Object Initialization function.bl653_init
- Initialization function.bl653_cmd_run
- This function sends a specified command with or without parameters to the Click module.bl653_cmd_set
- This function sets a value to a specified command parameter of the Click module.bl653_cmd_get
- This function is used to get the value of a given command parameter from the Click module.
Application Init
Initializes the driver and logger.
Application Task
Application task is split in few stages:
BL653_POWER_UP:
Powers up the device and reads the system information.BT653_CONFIG_EXAMPLE:
Sets the BT device name.BT653_EXAMPLE:
Performs a BT terminal example by processing all data from a connected BT device and sending back an adequate response messages.
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* @file main.c
* @brief BL653 Click Example.
*
* # Description
* This example demonstrates the use of BL653 Click board by processing data
* from a connected BT device.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and logger.
*
* ## Application Task
* Application task is split in few stages:
* - BL653_POWER_UP:
* Powers up the device and reads the system information.
* - BL653_CONFIG_EXAMPLE:
* Sets the BT device name.
* - BL653_EXAMPLE:
* Performs a BT terminal example by processing all data from a connected BT device
* and sending back an adequate response messages.
*
* ## Additional Function
* - static void bl653_clear_app_buf ( void )
* - static void bl653_log_app_buf ( void )
* - static err_t bl653_process ( bl653_t *ctx )
* - static err_t bl653_read_response ( bl653_t *ctx, uint8_t *rsp )
* - static err_t bl653_power_up ( bl653_t *ctx )
* - static err_t bl653_config_example ( bl653_t *ctx )
* - static err_t bl653_example ( bl653_t *ctx )
*
* @note
* We have used the Serial Bluetooth Terminal smartphone application for the test.
*
* @author Stefan Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "bl653.h"
// Message content
#define MESSAGE_CONTENT "BL653 Click board - demo example."
// Local device name.
#define DEVICE_NAME "BL653 Click"
static bl653_t bl653;
static log_t logger;
// Application buffer size
#define APP_BUFFER_SIZE 600
#define PROCESS_BUFFER_SIZE 200
static uint8_t app_buf[ APP_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;
/**
* @brief Example states.
* @details Predefined enum values for application example state.
*/
typedef enum
{
BL653_POWER_UP = 1,
BL653_CONFIG_EXAMPLE,
BL653_EXAMPLE
} bl653_app_state_t;
static bl653_app_state_t app_state = BL653_POWER_UP;
/**
* @brief BL653 clearing application buffer.
* @details This function clears memory of application buffer and reset its length.
* @note None.
*/
static void bl653_clear_app_buf ( void );
/**
* @brief BL653 log application buffer.
* @details This function logs data from application buffer to USB UART.
* @note None.
*/
static void bl653_log_app_buf ( void );
/**
* @brief BL653 data reading function.
* @details This function reads data from device and concatenates data to application buffer.
* @param[in] ctx : Click context object.
* See #bl653_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 bl653_process ( bl653_t *ctx );
/**
* @brief BL653 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 #bl653_t object definition for detailed explanation.
* @param[in] rsp Expected response.
* @return @li @c 0 - OK response.
* @li @c -2 - Timeout error.
* @li @c -3 - Command error.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t bl653_read_response ( bl653_t *ctx, uint8_t *rsp );
/**
* @brief BL653 power up function.
* @details This function powers up the device, and reads the system information.
* @param[in] ctx : Click context object.
* See #bl653_t object definition for detailed explanation.
* @return @li @c 0 - OK.
* @li @c != 0 - Read response error.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t bl653_power_up ( bl653_t *ctx );
/**
* @brief BL653 config example function.
* @details This function sets the BT device name.
* @param[in] ctx : Click context object.
* See #bl653_t object definition for detailed explanation.
* @return @li @c 0 - OK.
* @li @c != 0 - Read response error.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t bl653_config_example ( bl653_t *ctx );
/**
* @brief BL653 example function.
* @details This function performs a BT terminal example by processing all data from
* a connected BT device and sending back an adequate response messages.
* @param[in] ctx : Click context object.
* See #bl653_t object definition for detailed explanation.
* @return @li @c 0 - OK.
* @li @c != 0 - Read response error.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t bl653_example ( bl653_t *ctx );
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
bl653_cfg_t bl653_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.
bl653_cfg_setup( &bl653_cfg );
BL653_MAP_MIKROBUS( bl653_cfg, MIKROBUS_1 );
if ( UART_ERROR == bl653_init( &bl653, &bl653_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
app_state = BL653_POWER_UP;
log_printf( &logger, ">>> APP STATE - POWER UP <<<\r\n\n" );
}
void application_task ( void )
{
switch ( app_state )
{
case BL653_POWER_UP:
{
if ( BL653_OK == bl653_power_up( &bl653 ) )
{
app_state = BL653_CONFIG_EXAMPLE;
log_printf( &logger, ">>> APP STATE - CONFIG EXAMPLE <<<\r\n\n" );
}
break;
}
case BL653_CONFIG_EXAMPLE:
{
if ( BL653_OK == bl653_config_example( &bl653 ) )
{
app_state = BL653_EXAMPLE;
log_printf( &logger, ">>> APP STATE - EXAMPLE <<<\r\n\n" );
}
break;
}
case BL653_EXAMPLE:
{
bl653_example( &bl653 );
break;
}
default:
{
log_error( &logger, " APP STATE." );
break;
}
}
}
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 bl653_clear_app_buf ( void )
{
memset( app_buf, 0, app_buf_len );
app_buf_len = 0;
}
static void bl653_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 bl653_process ( bl653_t *ctx )
{
uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
int32_t overflow_bytes = 0;
int32_t rx_cnt = 0;
int32_t rx_size = bl653_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 BL653_OK;
}
return BL653_ERROR;
}
static err_t bl653_read_response ( bl653_t *ctx, uint8_t *rsp )
{
#define READ_RESPONSE_TIMEOUT_MS 30000
uint32_t timeout_cnt = 0;
bl653_clear_app_buf ( );
bl653_process( ctx );
while ( ( 0 == strstr( app_buf, rsp ) ) &&
( 0 == strstr( app_buf, BL653_RSP_ERROR ) ) )
{
bl653_process( ctx );
if ( timeout_cnt++ > READ_RESPONSE_TIMEOUT_MS )
{
bl653_log_app_buf( );
bl653_clear_app_buf( );
log_error( &logger, " Timeout!" );
return BL653_ERROR_TIMEOUT;
}
Delay_ms( 1 );
}
Delay_ms ( 200 );
bl653_process( ctx );
bl653_log_app_buf( );
if ( strstr( app_buf, rsp ) )
{
log_printf( &logger, "--------------------------------\r\n" );
return BL653_OK;
}
return BL653_ERROR_CMD;
}
static err_t bl653_power_up ( bl653_t *ctx )
{
err_t error_flag = BL653_OK;
log_printf( &logger, ">>> Reset device.\r\n" );
bl653_reset_device( &bl653 );
while ( BL653_OK == bl653_process( ctx ) )
{
bl653_log_app_buf( );
bl653_clear_app_buf ( );
}
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, ">>> Factory reset.\r\n" );
bl653_cmd_run( &bl653, BL653_CMD_FACTORY_RESET, NULL );
error_flag |= bl653_read_response( &bl653, BL653_RSP_OK );
log_printf( &logger, ">>> Check communication.\r\n" );
bl653_cmd_run( &bl653, BL653_CMD_AT, NULL );
error_flag |= bl653_read_response( &bl653, BL653_RSP_OK );
log_printf( &logger, ">>> Get device type.\r\n" );
bl653_cmd_run( ctx, BL653_CMD_GET_INFO, BL653_PARAM_DEVICE_TYPE );
error_flag |= bl653_read_response( ctx, BL653_RSP_OK );
log_printf( &logger, ">>> Get firmware version.\r\n" );
bl653_cmd_run( ctx, BL653_CMD_GET_INFO, BL653_PARAM_FW_VERSION );
error_flag |= bl653_read_response( ctx, BL653_RSP_OK );
log_printf( &logger, ">>> Get BT address.\r\n" );
bl653_cmd_run( ctx, BL653_CMD_GET_INFO, BL653_PARAM_BT_ADDRESS );
error_flag |= bl653_read_response( ctx, BL653_RSP_OK );
return error_flag;
}
static err_t bl653_config_example ( bl653_t *ctx )
{
err_t error_flag = BL653_OK;
log_printf( &logger, ">>> Set device name to \"%s\".\r\n", ( char * ) DEVICE_NAME );
bl653_cmd_set( ctx, BL653_CMD_PARAM_ACCESS_STR, BL653_PARAM_ID_DEVICE_NAME, DEVICE_NAME );
error_flag |= bl653_read_response( ctx, BL653_RSP_OK );
log_printf( &logger, ">>> Save settings.\r\n" );
bl653_cmd_run( &bl653, BL653_CMD_SAVE_SETTINGS, NULL );
error_flag |= bl653_read_response( ctx, BL653_RSP_OK );
log_printf( &logger, ">>> Reboot.\r\n" );
bl653_cmd_run( ctx, BL653_CMD_WARM_RESET, NULL );
error_flag |= bl653_read_response( ctx, BL653_RSP_OK );
return error_flag;
}
static err_t bl653_example ( bl653_t *ctx )
{
err_t error_flag = BL653_OK;
uint32_t timeout_cnt = 0;
#define BT_TERMINAL_TIMEOUT_MS 60000
#define BT_TERMINAL_MESSAGE_FREQ_MS 5000
#define TERMINATION_CMD "END"
#define TERMINATION_RESPONSE "END command received, the connection will be terminated in a few seconds."
#define TERMINATION_TIMEOUT "Timeout, closing the connection in a few seconds."
#define NEW_LINE_STRING "\r\n"
#define DISCONNECT_PEER "0"
log_printf( &logger, ">>> Waiting for a BT peer to establish connection with the Click board...\r\n" );
for ( ; ; )
{
bl653_clear_app_buf( );
if ( BL653_OK == bl653_process( ctx ) )
{
Delay_ms ( 200 );
bl653_process( ctx );
bl653_log_app_buf( );
if ( strstr( app_buf, BL653_RSP_CONNECT ) )
{
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, ">>> BT peer has connected.\r\n" );
break;
}
}
}
log_printf( &logger, ">>> Waiting for data (up to 60 seconds)...\r\n" );
log_printf( &logger, ">>> Connection will be terminated if the Click receives an \"END\" string.\r\n" );
for ( ; ; )
{
bl653_clear_app_buf( );
if ( BL653_OK == bl653_process( ctx ) )
{
Delay_ms ( 200 );
timeout_cnt = 0;
bl653_process( ctx );
bl653_log_app_buf( );
if ( strstr( app_buf, TERMINATION_CMD ) )
{
log_printf( &logger, ">>> Terminating connection on demand.\r\n" );
bl653_generic_write ( ctx, TERMINATION_RESPONSE, strlen ( TERMINATION_RESPONSE ) );
bl653_generic_write ( ctx, NEW_LINE_STRING, strlen ( NEW_LINE_STRING ) );
Delay_ms ( 100 );
log_printf( &logger, ">>> Disconnecting BT peer.\r\n" );
// Sending 4 escape chars with at least 250ms intervening delay
bl653_generic_write ( ctx, BL653_CMD_VSP_ESCAPE_CHAR, strlen ( BL653_CMD_VSP_ESCAPE_CHAR ) );
Delay_ms ( 300 );
bl653_generic_write ( ctx, BL653_CMD_VSP_ESCAPE_CHAR, strlen ( BL653_CMD_VSP_ESCAPE_CHAR ) );
Delay_ms ( 300 );
bl653_generic_write ( ctx, BL653_CMD_VSP_ESCAPE_CHAR, strlen ( BL653_CMD_VSP_ESCAPE_CHAR ) );
Delay_ms ( 300 );
bl653_generic_write ( ctx, BL653_CMD_VSP_ESCAPE_CHAR, strlen ( BL653_CMD_VSP_ESCAPE_CHAR ) );
Delay_ms ( 300 );
error_flag |= bl653_read_response( ctx, BL653_RSP_NO_CARRIER );
break;
}
else if ( strstr( app_buf, BL653_RSP_NO_CARRIER ) )
{
log_printf( &logger, ">>> BT peer has disconnected.\r\n" );
break;
}
}
timeout_cnt++;
if ( 0 == ( timeout_cnt % BT_TERMINAL_MESSAGE_FREQ_MS ) )
{
log_printf( &logger, ">>> Sending \"%s\" message to connected device.\r\n", ( char * ) MESSAGE_CONTENT );
bl653_generic_write ( ctx, MESSAGE_CONTENT, strlen ( MESSAGE_CONTENT ) );
bl653_generic_write ( ctx, NEW_LINE_STRING, strlen ( NEW_LINE_STRING ) );
Delay_ms ( 100 );
}
if ( BT_TERMINAL_TIMEOUT_MS < timeout_cnt )
{
log_printf( &logger, ">>> Terminating connection due to 60s timeout expiration.\r\n" );
bl653_generic_write ( ctx, TERMINATION_TIMEOUT, strlen ( TERMINATION_TIMEOUT ) );
bl653_generic_write ( ctx, NEW_LINE_STRING, strlen ( NEW_LINE_STRING ) );
Delay_ms ( 100 );
log_printf( &logger, ">>> Disconnecting BT peer.\r\n" );
// Sending 4 escape chars with at least 250ms intervening delay
bl653_generic_write ( ctx, BL653_CMD_VSP_ESCAPE_CHAR, strlen ( BL653_CMD_VSP_ESCAPE_CHAR ) );
Delay_ms ( 300 );
bl653_generic_write ( ctx, BL653_CMD_VSP_ESCAPE_CHAR, strlen ( BL653_CMD_VSP_ESCAPE_CHAR ) );
Delay_ms ( 300 );
bl653_generic_write ( ctx, BL653_CMD_VSP_ESCAPE_CHAR, strlen ( BL653_CMD_VSP_ESCAPE_CHAR ) );
Delay_ms ( 300 );
bl653_generic_write ( ctx, BL653_CMD_VSP_ESCAPE_CHAR, strlen ( BL653_CMD_VSP_ESCAPE_CHAR ) );
Delay_ms ( 300 );
error_flag |= bl653_read_response( ctx, BL653_RSP_NO_CARRIER );
break;
}
Delay_ms ( 1 );
}
return error_flag;
}
// ------------------------------------------------------------------------ END
Additional Support
Resources
Category:BT/BLE