Your go-to solution for any project requiring easy-to-use and dependable Bluetooth LE functionality
A
A
Hardware Overview
How does it work?
MDBT42Q Click is based on the MDBT42Q-AT2 module from RAYTAC designed to provide Bluetooth Low Energy (BLE) connectivity. This certified BT 5.2 stack module is based on the Nordic nRF52810 SoC, a highly integrated solution that combines a 32-bit ARM Cortex-M4F processor with 192kB of Flash memory and 24kB of RAM, ensuring efficient operation in wireless applications. Acting exclusively in the peripheral/slave role, the module comes preloaded with RAYTAC’s AT command firmware, which simplifies configuration and control through a UART interface. As a recommended third-party module by Nordic Semiconductor, MDBT42Q-AT2 meets multiple international standards, being certified for FCC, IC, CE, Telec (MIC), KC, SRRC, and NCC compliance, while its onboard chip antenna guarantees excellent connectivity performance in compact embedded designs. The module offers flexible configuration options, allowing users to choose on-air data rates of either 1Mbps or 2Mbps, set transmission power across five selectable levels, and adjust advertising time. For better user interaction, it supports customizable LED indication patterns that reflect advertising and connection status, with a yellow CONN/ADV LED as a clear status marker. To optimize energy consumption, it provides both DC-to-DC and LDO power modes, a dedicated power-down state with GPIO wake-up
support, and efficient use of resources to extend battery life in portable systems. Its data handling capabilities include support for a maximum MTU size of 247 bytes, enabling payloads of up to 244 bytes, ensuring reliable and flexible data exchange in BLE applications. With these features, MDBT42Q Click is ideal for IoT devices, wireless sensors, smart home automation, asset tracking systems, healthcare and fitness monitors, and other scenarios where low-power, short-range wireless connectivity is required. This Click board™ establishes communication between the MDBT42Q-AT2 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. In addition to the UART pins for communication with the module, this Click board also features a PD active-high pin used to enable the UART interface, a reset pin (RST) enabling easy module resetting, blue IND LED indicator for Bluetooth connection status (also available through IND pin), and SWD pads designed for use with MIKROE's 6-pin Needle Cable, providing an optional flash and debug SWD (Serial Wire Debug) interface functionality. The board integrates dedicated wake-up buttons that provide a reliable way to bring the module out of deep sleep mode. Since the wake-up mechanism is
logic-selective, it requires a clearly defined signal transition to activate the module, which is why two separate buttons are provided: one tied to the 3V3 rail and the other to GND. By pressing either of these, a valid high or low logic level is momentarily introduced, triggering the wake-up event in accordance with the module’s power management logic. The board is also equipped with a set of carefully placed test points that provide developers with easy access to key signals for debugging, monitoring, and feature expansion. A dedicated group of test points labeled P12 through P19 enables support for up to eight programmable GPIO outputs, offering flexibility to configure these pins according to application requirements. In addition to general-purpose I/O, an ADC test point is also provided, allowing straightforward retrieval of analog-to-digital conversion values. This feature is particularly useful for monitoring supply conditions, most notably battery voltage levels, ensuring that power status can be tracked in real time and incorporated into the system’s operation logic. 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
Nucleo-64 with STM32F410RB 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-M4
MCU Memory (KB)
128
Silicon Vendor
STMicroelectronics
Pin count
64
RAM (Bytes)
32768
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
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
MDBT42Q 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 MDBT42Q Click board by processing data from a connected BT device.
Key functions:
mdbt42q_cfg_setup- This function initializes Click configuration structure to initial values.mdbt42q_init- This function initializes all necessary pins and peripherals used for this Click board.mdbt42q_get_ind_pin- This function returns the BT connection active indicator (IND) pin logic state.mdbt42q_reset_device- This function resets the device by toggling the reset pin logic state.mdbt42q_cmd_run- This function sends a specified command to the Click module.mdbt42q_cmd_set- This function sets a value to a specified command of the Click module.
Application Init
Initializes the driver and logger.
Application Task
Application task is split in few stages:
MDBT42Q_POWER_UP- Powers up the device, performs a factory reset and reads system information.MDBT42Q_CONFIG_EXAMPLE- Sets the BT device name.MDBT42Q_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 MDBT42Q Click Example.
*
* # Description
* This example demonstrates the use of MDBT42Q 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:
* - MDBT42Q_POWER_UP:
* Powers up the device, performs a factory reset and reads system information.
* - MDBT42Q_CONFIG_EXAMPLE:
* Sets the BT device name.
* - MDBT42Q_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 mdbt42q_clear_app_buf ( void )
* - static void mdbt42q_log_app_buf ( void )
* - static err_t mdbt42q_process ( mdbt42q_t *ctx )
* - static err_t mdbt42q_read_response ( mdbt42q_t *ctx )
* - static err_t mdbt42q_power_up ( mdbt42q_t *ctx )
* - static err_t mdbt42q_config_example ( mdbt42q_t *ctx )
* - static err_t mdbt42q_example ( mdbt42q_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 "mdbt42q.h"
// Message content
#define MESSAGE_CONTENT "MDBT42Q Click board - demo example."
// Device name.
#define DEVICE_NAME "MDBT42Q Click"
static mdbt42q_t mdbt42q;
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
{
MDBT42Q_POWER_UP = 1,
MDBT42Q_CONFIG_EXAMPLE,
MDBT42Q_EXAMPLE
} mdbt42q_app_state_t;
static mdbt42q_app_state_t app_state = MDBT42Q_POWER_UP;
/**
* @brief MDBT42Q clearing application buffer.
* @details This function clears memory of application buffer and reset its length.
* @note None.
*/
static void mdbt42q_clear_app_buf ( void );
/**
* @brief MDBT42Q log application buffer.
* @details This function logs data from application buffer to USB UART.
* @note None.
*/
static void mdbt42q_log_app_buf ( void );
/**
* @brief MDBT42Q data reading function.
* @details This function reads data from device and concatenates data to application buffer.
* @param[in] ctx : Click context object.
* See #mdbt42q_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 mdbt42q_process ( mdbt42q_t *ctx );
/**
* @brief MDBT42Q 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 #mdbt42q_t object definition for detailed explanation.
* @return @li @c 0 - OK response.
* @li @c -2 - Timeout error.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t mdbt42q_read_response ( mdbt42q_t *ctx );
/**
* @brief MDBT42Q power up function.
* @details This function powers up the device, performs a factory reset and reads system information.
* @param[in] ctx : Click context object.
* See #mdbt42q_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 mdbt42q_power_up ( mdbt42q_t *ctx );
/**
* @brief MDBT42Q config example function.
* @details This function sets the BT device name.
* @param[in] ctx : Click context object.
* See #mdbt42q_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 mdbt42q_config_example ( mdbt42q_t *ctx );
/**
* @brief MDBT42Q 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 #mdbt42q_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 mdbt42q_example ( mdbt42q_t *ctx );
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
mdbt42q_cfg_t mdbt42q_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.
mdbt42q_cfg_setup( &mdbt42q_cfg );
MDBT42Q_MAP_MIKROBUS( mdbt42q_cfg, MIKROBUS_1 );
if ( MDBT42Q_OK != mdbt42q_init( &mdbt42q, &mdbt42q_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
app_state = MDBT42Q_POWER_UP;
log_printf( &logger, ">>> APP STATE - POWER UP <<<\r\n\n" );
}
void application_task ( void )
{
switch ( app_state )
{
case MDBT42Q_POWER_UP:
{
if ( MDBT42Q_OK == mdbt42q_power_up( &mdbt42q ) )
{
app_state = MDBT42Q_CONFIG_EXAMPLE;
log_printf( &logger, ">>> APP STATE - CONFIG EXAMPLE <<<\r\n\n" );
}
break;
}
case MDBT42Q_CONFIG_EXAMPLE:
{
if ( MDBT42Q_OK == mdbt42q_config_example( &mdbt42q ) )
{
app_state = MDBT42Q_EXAMPLE;
log_printf( &logger, ">>> APP STATE - EXAMPLE <<<\r\n\n" );
}
break;
}
case MDBT42Q_EXAMPLE:
{
mdbt42q_example( &mdbt42q );
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 mdbt42q_clear_app_buf ( void )
{
memset( app_buf, 0, app_buf_len );
app_buf_len = 0;
}
static void mdbt42q_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 mdbt42q_process ( mdbt42q_t *ctx )
{
uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
int32_t overflow_bytes = 0;
int32_t rx_cnt = 0;
int32_t rx_size = mdbt42q_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 MDBT42Q_OK;
}
return MDBT42Q_ERROR;
}
static err_t mdbt42q_read_response ( mdbt42q_t *ctx )
{
#define READ_RESPONSE_TIMEOUT_MS 60000
uint32_t timeout_cnt = 0;
mdbt42q_clear_app_buf ( );
while ( MDBT42Q_ERROR == mdbt42q_process( ctx ) )
{
if ( timeout_cnt++ > READ_RESPONSE_TIMEOUT_MS )
{
log_error( &logger, " Timeout!" );
return MDBT42Q_ERROR_TIMEOUT;
}
Delay_ms ( 1 );
}
Delay_ms ( 500 );
mdbt42q_process( ctx );
mdbt42q_log_app_buf( );
log_printf( &logger, "\r\n--------------------------------\r\n" );
return MDBT42Q_OK;
}
static err_t mdbt42q_power_up ( mdbt42q_t *ctx )
{
err_t error_flag = MDBT42Q_OK;
log_printf( &logger, ">>> Hardware reset.\r\n" );
mdbt42q_reset_device ( ctx );
log_printf( &logger, ">>> Restore default settings.\r\n" );
mdbt42q_cmd_run( ctx, MDBT42Q_CMD_RESTORE_DEFAULT );
error_flag |= mdbt42q_read_response( ctx );
log_printf( &logger, ">>> Get version.\r\n" );
mdbt42q_cmd_run( ctx, MDBT42Q_CMD_GET_VERSION );
error_flag |= mdbt42q_read_response( ctx );
return error_flag;
}
static err_t mdbt42q_config_example ( mdbt42q_t *ctx )
{
err_t error_flag = MDBT42Q_OK;
log_printf( &logger, ">>> Set device name.\r\n" );
mdbt42q_cmd_set( ctx, MDBT42Q_CMD_SET_PARAM_DEVICE_NAME, DEVICE_NAME );
error_flag |= mdbt42q_read_response( ctx );
log_printf( &logger, ">>> Save settings.\r\n" );
mdbt42q_cmd_run( ctx, MDBT42Q_CMD_RESET );
error_flag |= mdbt42q_read_response( ctx );
return error_flag;
}
static err_t mdbt42q_example ( mdbt42q_t *ctx )
{
err_t error_flag = MDBT42Q_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 "Acknowledged, 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"
log_printf( &logger, ">>> Waiting for a BT peer to establish connection with the Click board...\r\n" );
while ( mdbt42q_get_ind_pin ( ctx ) );
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, ">>> BT peer has connected.\r\n" );
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 ( ; ; )
{
mdbt42q_clear_app_buf( );
if ( MDBT42Q_OK == mdbt42q_process( ctx ) )
{
Delay_ms ( 100 );
timeout_cnt = 0;
mdbt42q_process( ctx );
mdbt42q_log_app_buf( );
if ( strstr( app_buf, TERMINATION_CMD ) )
{
log_printf( &logger, ">>> Terminate connection on demand.\r\n" );
mdbt42q_generic_write ( ctx, TERMINATION_RESPONSE, strlen ( TERMINATION_RESPONSE ) );
mdbt42q_generic_write ( ctx, NEW_LINE_STRING, strlen ( NEW_LINE_STRING ) );
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 );
mdbt42q_generic_write ( ctx, MESSAGE_CONTENT, strlen ( MESSAGE_CONTENT ) );
mdbt42q_generic_write ( ctx, NEW_LINE_STRING, strlen ( NEW_LINE_STRING ) );
}
if ( BT_TERMINAL_TIMEOUT_MS < timeout_cnt )
{
log_printf( &logger, ">>> Terminate connection due to 60s timeout expiration.\r\n" );
mdbt42q_generic_write ( ctx, TERMINATION_TIMEOUT, strlen ( TERMINATION_TIMEOUT ) );
mdbt42q_generic_write ( ctx, NEW_LINE_STRING, strlen ( NEW_LINE_STRING ) );
break;
}
Delay_ms ( 1 );
}
Delay_ms ( 1000 );
log_printf( &logger, ">>> Closing BT peer connection.\r\n" );
mdbt42q_cmd_run( ctx, MDBT42Q_CMD_DISCONNECT );
error_flag |= mdbt42q_read_response( ctx );
return error_flag;
}
// ------------------------------------------------------------------------ END
Additional Support
Resources
Category:BT/BLE

































