Complete RF solution with an integrated 2.4GHz antenna for applications like beacons, building automation, and remote control toys
A
A
Hardware Overview
How does it work?
B102C Click is based on the B102C, a Bluetooth 5.0 (BLE) module from Amphenol. This module is built around the Realtek RTL8762CMF, offering BLE v5.0 support, a robust 20MHz Arm® Cortex® M4F processor, and exceptional power efficiency. It provides a complete RF solution with an integrated antenna operating in the 2.4GHz range (2402 - 2480MHz), along with a low-power crystal that optimizes power consumption by enabling advanced power-saving modes. Ideal for various applications, B102C Click can be used in beacons, building automation, remote control toys, lighting products, and many more. The B102C module comes preloaded with Amphenol firmware, supporting Bluetooth Low Energy Serial Port Service and simultaneous peripheral and central roles, all configurable through AT commands. It also allows full flexibility in adding custom applications on its built-in Cortex-M4 with 4Mbits of Flash, 4Kb eFuse, and 160KB SRAM. Regarding
the board's connectivity features, this Click board™ uses a UART interface for communication with the host MCU, using standard UART RX and TX pins to exchange AT commands. By default, it communicates at a baud rate of 115200bps. Additionally, the Click board™ is equipped with a USB Type-C connector, allowing power supply and configuration via a PC. This is achieved by the CP2102, a highly integrated USB-to-UART bridge, and a TPS727 LDO regulator, which provides the necessary 3.3V power supply for the module out of the USB supply. Additionally, on the left side of the board, there is an unpopulated PROG header that provides full support for debugging and programming. This header allows the user to utilize a Serial Wire Debug (SWD) interface for programming and debugging via the SWD interface pins. Along with the communication and control pins, this Click board™ also includes a reset pin (RST) and a RESET button, enabling easy module
resetting. All GPIO pins of the module are routed to two unpopulated J1 and J2 headers. These pins are fully programmable, with selectable pull-up and pull-down resistors for each pin. They retain their last state when the system enters Sleep mode and allow the module to be awakened by any GPIO while in Sleep mode. Three of these pins are also routed to the mikroBUS™ socket (P01, P22, and P23) to the AN, PWM, and INT default positions, allowing users to use these functions or configure them as desired, given that they are user-configurable pins. 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
EasyPIC v7a is the seventh generation of PIC development boards specially designed for the needs of rapid development of embedded applications. It supports a wide range of 8-bit PIC microcontrollers from Microchip and has a broad set of unique functions, such as the first-ever embedded debugger/programmer over USB-C. The development board is well organized and designed so that the end-user has all the necessary elements in one place, such as switches, buttons, indicators, connectors, and others. With four different connectors for each port, EasyPIC v7a allows you to connect accessory boards, sensors, and custom electronics more efficiently than ever. Each part of the EasyPIC v7a development board
contains the components necessary for the most efficient operation of the same board. In addition to the advanced integrated CODEGRIP programmer/debugger module, which offers many valuable programming/debugging options and seamless integration with the Mikroe software environment, the board also includes a clean and regulated power supply module for the development board. It can use various external power sources, including an external 12V power supply, 7-23V AC or 9-32V DC via DC connector/screw terminals, and a power source via the USB Type-C (USB-C) connector. Communication options such as USB-UART and RS-232 are also included, alongside the well-
established mikroBUS™ standard, three display options (7-segment, graphical, and character-based LCD), and several different DIP sockets. These sockets cover a wide range of 8-bit PIC MCUs, from PIC10F, PIC12F, PIC16F, PIC16Enh, PIC18F, PIC18FJ, and PIC18FK families. EasyPIC v7a is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.
Microcontroller Overview
MCU Card / MCU

Architecture
PIC
MCU Memory (KB)
32
Silicon Vendor
Microchip
Pin count
40
RAM (Bytes)
1536
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
This library contains API for B102C Click driver.
Key functions:
b102c_send_cmd
- This function sends a specified command to the B102C Click module.b102c_send_cmd_with_params
- This function sends a command with specified parameter to the click module.b102c_send_cmd_params_check
- This function checks the command that is sent.
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 B102C Click Example.
*
* # Description
* This example demonstrates the use of B102C click board by processing
* the incoming data and displaying them on the USB UART.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver, then performs a factory reset and sets the local device name.
*
* ## Application Task
* Reads and processes all incoming data and displays them on the USB UART.
*
* ## Additional Function
* - static void b102c_clear_app_buf ( void )
* - static void b102c_log_app_buf ( void )
* - static err_t b102c_process ( b102c_t *ctx )
* - static err_t b102c_rsp_check ( b102c_t *ctx, uint8_t *response )
* - static void b102c_error_check( err_t error_flag )
*
* @note
* For communication with B102C click use the android application on the link:
* https://play.google.com/store/apps/details?id=com.macdom.ble.blescanner
*
* @author Stefan Ilic
*
*/
#include "board.h"
#include "log.h"
#include "b102c.h"
// Application buffer size
#define APP_BUFFER_SIZE 500
#define PROCESS_BUFFER_SIZE 200
static b102c_t b102c;
static log_t logger;
static uint8_t app_buf[ APP_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;
static err_t app_error_flag;
/**
* @brief B102C clearing application buffer.
* @details This function clears memory of application buffer and reset its length.
* @note None.
*/
static void b102c_clear_app_buf ( void );
/**
* @brief B102C log application buffer.
* @details This function logs data from application buffer to USB UART.
* @note None.
*/
static void b102c_log_app_buf ( void );
/**
* @brief B102C data reading function.
* @details This function reads data from device and concatenates data to application buffer.
* @param[in] ctx : Click context object.
* See #b102c_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 b102c_process ( b102c_t *ctx );
/**
* @brief B102C response read function.
* @details This function reads the response of the sent command and writes it on the USB UART.
* @param[in] ctx : Click context object.
* See #b102c_t object definition for detailed explanation.
* @param[in] response : Expected response.
* @return @li @c 0 - Response OK.
* @li @c -1 - Response ERROR.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t b102c_rsp_check ( b102c_t *ctx, uint8_t *response );
/**
* @brief Check for errors.
* @details This function checks for different types of
* errors and logs them on UART or logs the response if no errors occured.
* @param[in] error_flag : Response to be checked.
* @note None.
*/
static void b102c_error_check( err_t error_flag );
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
b102c_cfg_t b102c_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.
b102c_cfg_setup( &b102c_cfg );
B102C_MAP_MIKROBUS( b102c_cfg, MIKROBUS_1 );
if ( UART_ERROR == b102c_init( &b102c, &b102c_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
Delay_ms ( 100 );
log_printf( &logger, " Software reset. \r\n" );
b102c_send_cmd( &b102c, B102C_CMD_RESET );
app_error_flag = b102c_rsp_check( &b102c, B102C_RSP_READY );
log_printf( &logger, " Factory reset. \r\n" );
b102c_send_cmd( &b102c, B102C_CMD_DEFAULT );
app_error_flag = b102c_rsp_check( &b102c, B102C_RSP_READY );
log_printf( &logger, " Set device name. \r\n" );
#define DEVICE_NAME "B102C Click"
b102c_send_cmd_with_params( &b102c, B102C_CMD_NAME, DEVICE_NAME );
app_error_flag = b102c_rsp_check( &b102c, B102C_RSP_OK );
log_printf( &logger, " Set Auto broadcast mode. \r\n" );
#define AUTO_BROADCAST "1"
b102c_send_cmd_with_params( &b102c, B102C_CMD_ADVMOD, AUTO_BROADCAST );
app_error_flag = b102c_rsp_check( &b102c, B102C_RSP_OK );
log_info( &logger, " Application Task " );
log_printf( &logger, " Connect to device. " );
}
void application_task ( void )
{
if ( B102C_OK == b102c_process( &b102c ) )
{
b102c_log_app_buf( );
b102c_clear_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 b102c_clear_app_buf ( void )
{
memset( app_buf, 0, app_buf_len );
app_buf_len = 0;
}
static void b102c_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 b102c_process ( b102c_t *ctx )
{
uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
int32_t overflow_bytes = 0;
int32_t rx_cnt = 0;
int32_t rx_size = b102c_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 B102C_OK;
}
return B102C_ERROR;
}
static err_t b102c_rsp_check ( b102c_t *ctx, uint8_t *response )
{
uint16_t timeout_cnt = 0;
uint16_t timeout = 50000;
err_t error_flag = b102c_process( ctx );
if ( ( error_flag != 0 ) && ( error_flag != -1 ) )
{
return error_flag;
}
while ( ( strstr( app_buf, response ) == 0 ) && ( strstr( app_buf, B102C_RSP_ERROR ) == 0 ) )
{
error_flag = b102c_process( ctx );
if ( ( error_flag != 0 ) && ( error_flag != -1 ) )
{
return error_flag;
}
timeout_cnt++;
if ( timeout_cnt > timeout )
{
return B102C_TIMEOUT;
}
Delay_ms ( 1 );
}
for ( int32_t buf_cnt = 0; buf_cnt < app_buf_len; buf_cnt++ )
{
log_printf( &logger, "%c", app_buf[ buf_cnt ] );
}
log_printf( &logger, "\r\n" );
b102c_clear_app_buf( );
Delay_ms ( 500 );
log_printf( &logger, "-----------------------------------\r\n" );
}
static void b102c_error_check( err_t error_flag )
{
if ( ( error_flag != 0 ) && ( error_flag != B102C_ERROR ) )
{
switch ( error_flag )
{
case B102C_OVERFLOW:
{
log_error( &logger, " Overflow!" );
break;
}
case B102C_TIMEOUT:
{
log_error( &logger, " Timeout!" );
break;
}
default:
{
break;
}
}
}
}
// ------------------------------------------------------------------------ END