nbiot 2.0.0.0
Main Page

NB IoT click

NB IoT click is a Click boardâ„¢ that allows LTE Cat NB1 connectivity by utilizing Quectel BC95-G, a specialized multi-band IoT module with very low power requirements and compact form factor, making it perfectly suited for various IoT-based applications.

click Product page


Click library

  • Author : MikroE Team
  • Date : Jun 2020.
  • Type : UART GSM/IOT type

Software Support

We provide a library for the NbIot 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 form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

‍This library contains API for NbIot Click driver.

Standard key functions :

  • NB IoT configuration object setup function.

    ‍void nbiot_cfg_setup ( nbiot_cfg_t *cfg );

    - NB IoT initialization function.

    ‍err_t nbiot_init ( nbiot_t *ctx, nbiot_cfg_t *cfg );

Example key functions :

  • Send command function.

    ‍void nbiot_send_cmd ( nbiot_t *ctx, char *cmd );

    - NB IoT module power on.

    ‍void nbiot_power_on ( nbiot_t *ctx );

  • NB IoT data writing function.

    ‍err_t nbiot_generic_write ( nbiot_t *ctx, char *data_buf, uint16_t len );

    Examples Description

‍This example reads and processes data from NB IoT clicks.

The demo application is composed of two sections :

Application Init

‍Initializes driver, wake-up module and sets default configuration for connecting device to network.

void application_init ( void )
{
log_cfg_t log_cfg;
nbiot_cfg_t nbiot_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
Delay_ms ( 1000 );
// Click initialization.
nbiot_cfg_setup( &nbiot_cfg );
NBIOT_MAP_MIKROBUS( nbiot_cfg, MIKROBUS_1 );
err_t init_flag = nbiot_init( &nbiot, &nbiot_cfg );
if ( init_flag == UART_ERROR )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
log_info( &logger, " Power on device... " );
nbiot_power_on( &nbiot );
// dummy read
app_error_flag = nbiot_rsp_check( );
nbiot_error_check( app_error_flag );
// AT
app_error_flag = nbiot_rsp_check( );
nbiot_error_check( app_error_flag );
Delay_ms ( 500 );
// ATI - product information
app_error_flag = nbiot_rsp_check( );
nbiot_error_check( app_error_flag );
Delay_ms ( 500 );
// CGMR - firmware version
app_error_flag = nbiot_rsp_check( );
nbiot_error_check( app_error_flag );
Delay_ms ( 1000 );
// COPS - deregister from network
app_error_flag = nbiot_rsp_check( );
nbiot_error_check( app_error_flag );
Delay_ms ( 1000 );
// CFUN - full funtionality
app_error_flag = nbiot_rsp_check( );
nbiot_error_check( app_error_flag );
Delay_ms ( 500 );
// COPS - automatic mode
app_error_flag = nbiot_rsp_check( );
nbiot_error_check( app_error_flag );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
// CEREG - network registration status
app_error_flag = nbiot_rsp_check( );
nbiot_error_check( app_error_flag );
Delay_ms ( 500 );
// CIMI - request IMSI
app_error_flag = nbiot_rsp_check( );
nbiot_error_check( app_error_flag );
Delay_ms ( 500 );
app_buf_len = 0;
app_buf_cnt = 0;
app_connection_status = WAIT_FOR_CONNECTION;
log_info( &logger, " Application Task " );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
#define NBIOT_CMD_CIMI
Definition nbiot.h:95
#define NBIOT_CMD_AT
Definition nbiot.h:88
#define NBIOT_CMD_CFUN
Definition nbiot.h:92
#define NBIOT_CMD_CEREG
Definition nbiot.h:93
#define NBIOT_CMD_COPS
Definition nbiot.h:99
#define NBIOT_CMD_ATI
Definition nbiot.h:89
#define NBIOT_CMD_CGMR
Definition nbiot.h:90
#define NBIOT_MAP_MIKROBUS(cfg, mikrobus)
Definition nbiot.h:67
void nbiot_power_on(nbiot_t *ctx)
NB IoT module power on.
err_t nbiot_init(nbiot_t *ctx, nbiot_cfg_t *cfg)
NB IoT initialization function.
void nbiot_send_cmd_with_parameter(nbiot_t *ctx, char *at_cmd_buf, char *param_buf)
Send command function with parameter.
void nbiot_cfg_setup(nbiot_cfg_t *cfg)
NB IoT configuration object setup function.
void nbiot_send_cmd(nbiot_t *ctx, char *cmd)
Send command function.
void application_init(void)
Definition main.c:117
#define WAIT_FOR_CONNECTION
Definition main.c:48
Click configuration structure definition.
Definition nbiot.h:142

Application Task

‍Waits for device to connect to network and then checks the signal quality every 5 seconds. All data is being logged on USB UART where you can track their changes.

void application_task ( void )
{
if ( app_connection_status == WAIT_FOR_CONNECTION )
{
// CGATT - request IMSI
app_error_flag = nbiot_rsp_check( );
nbiot_error_check( app_error_flag );
Delay_ms ( 500 );
// CEREG - network registration status
app_error_flag = nbiot_rsp_check( );
nbiot_error_check( app_error_flag );
Delay_ms ( 500 );
// CSQ - signal quality
app_error_flag = nbiot_rsp_check( );
nbiot_error_check( app_error_flag );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
else
{
log_info( &logger, "CONNECTED TO NETWORK" );
log_info( &logger, "CHECKING SIGNAL QUALITY" );
app_error_flag = nbiot_rsp_check( );
nbiot_error_check( app_error_flag );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
}
#define NBIOT_CMD_CSQ
Definition nbiot.h:97
#define NBIOT_CMD_CGATT
Definition nbiot.h:96
void nbiot_send_cmd_check(nbiot_t *ctx, char *at_cmd_buf)
Check the sent command.
void application_task(void)
Definition main.c:214

Note

‍In order for the example to work, a valid SIM card needs to be entered.

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.NbIot

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. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.