nbiot4  2.0.0.0
Main Page

NB IoT 4 click

NB IoT 4 Click is a compact add-on board that contains a cellular IoT-based module with integrated eSIM for global data connectivity. This board features the C1-RM, a three-band NB-IoT, IoT/2G wireless communication module supporting Band 3, 5, and 8 mainly applied to low power data transmission service from Cavli Wireless.

click Product page


Click library

  • Author : Luka Filipovic
  • Date : Jun 2021.
  • Type : UART type

Software Support

We provide a library for the NBIoT4 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for NBIoT4 Click driver.

Standard key functions :

Example key functions :

Example Description

Application example shows device capability to connect

network and send SMS messages using standard "AT" commands.

The demo application is composed of two sections :

Application Init

Initializes UART communication modules and additional pins

wait for powerup or restarts device. Test communication and read information from device.

void application_init ( void )
{
log_cfg_t log_cfg;
nbiot4_cfg_t nbiot4_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
Delay_ms( 500 );
// Click initialization.
nbiot4_cfg_setup( &nbiot4_cfg );
NBIOT4_MAP_MIKROBUS( nbiot4_cfg, MIKROBUS_1 );
err_t init_flag = nbiot4_init( &nbiot4, &nbiot4_cfg );
if ( UART_ERROR == init_flag )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
nbiot4_default_cfg( &nbiot4 );
nbiot4_process( );
nbiot4_clear_app_buf( );
log_info( &logger, "Power up" );
nbiot4_restart_device( 5000 );
//Check communication
error_flag = nbiot4_rsp_check();
nbiot4_log_app_buf( );
nbiot4_clear_app_buf( );
//Check revision
error_flag = nbiot4_rsp_check();
nbiot4_log_app_buf( );
nbiot4_clear_app_buf( );
log_info( &logger, " Application Task " );
}

Application Task

First it confiures device for connection to network(sets

extern sim, selected apn). It waits until device gets information that is connected to home network. Then checks connection parameters. After that it configures device for one type of sending message TEXT or PDU mode. In the end it sends SMS message to selected number.

void application_task ( void )
{
switch ( example_state )
{
{
if ( !nbiot4_configure_for_connection() )
example_state++;
break;
}
{
nbiot4_wait_to_connect( );
example_state++;
break;
}
{
if ( !nbiot4_check_connection() )
example_state++;
break;
}
{
if ( !nbiot4_configure_for_sms() )
example_state++;
break;
}
{
nbiot4_send_meesage();
break;
}
default:
{
log_error( &logger, " Unknown example state." );
Delay_ms( 500 );
}
}
}

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.NBIoT4

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.


nbiot4_send_text_message
void nbiot4_send_text_message(nbiot4_t *ctx, char *phone_number, char *message_content)
Send SMS message to number in text mode.
nbiot4_set_sim_apn
void nbiot4_set_sim_apn(nbiot4_t *ctx, char *sim_apn)
Set SIM APN.
nbiot4_default_cfg
err_t nbiot4_default_cfg(nbiot4_t *ctx)
NB IoT 4 default configuration function.
nbiot4_init
err_t nbiot4_init(nbiot4_t *ctx, nbiot4_cfg_t *cfg)
NB IoT 4 initialization function.
nbiot4_cfg_setup
void nbiot4_cfg_setup(nbiot4_cfg_t *cfg)
NB IoT 4 configuration object setup function.
application_task
void application_task(void)
Definition: main.c:236
NBIOT4_CONFIGURE_FOR_SMS
Definition: main.c:79
NBIOT4_CMD_ATI
#define NBIOT4_CMD_ATI
Definition: nbiot4.h:59
nbiot4_send_cmd
void nbiot4_send_cmd(nbiot4_t *ctx, char *cmd)
Send command function.
nbiot4_cfg_t
NB IoT 4 Click configuration object.
Definition: nbiot4.h:156
nbiot4_t
NB IoT 4 Click context object.
Definition: nbiot4.h:136
application_init
void application_init(void)
Definition: main.c:182
NBIOT4_MESSAGES
Definition: main.c:80
NBIOT4_CONFIGURE_FOR_CONNECTION
Definition: main.c:76
NBIOT4_WAIT_FOR_CONNECTION
Definition: main.c:77
NBIOT4_MAP_MIKROBUS
#define NBIOT4_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: nbiot4.h:122
NBIOT4_CMD_AT
#define NBIOT4_CMD_AT
NB IoT 4 description register.
Definition: nbiot4.h:58
NBIOT4_CHECK_CONNECTION
Definition: main.c:78