awsiot  2.1.0.0
Main Page

AWS IoT click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Stefan Filipovic
  • Date : Mar 2023.
  • Type : UART type

Software Support

We provide a library for the AWS IoT 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 AWS IoT Click driver.

Standard key functions :

Example key functions :

  • awsiot_reset_device This function resets device by toggling the RST pin state.
  • awsiot_send_cmd This function send command string by using UART serial interface.
    void awsiot_send_cmd ( awsiot_t *ctx, uint8_t *cmd );

Example Description

This example demonstrates the use of AWS IoT click board by bridging the USB UART

to mikroBUS UART which allows the click board to establish a connection with the AWS IoT over the Quick Connect demo application without an AWS account.

The demo application is composed of two sections :

Application Init

Initializes the driver, resets the click board to factory default settings, then

reads and displays the vendor model and thing name on the USB UART.

void application_init ( void )
{
log_cfg_t log_cfg;
awsiot_cfg_t awsiot_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
awsiot_cfg_setup( &awsiot_cfg );
AWSIOT_MAP_MIKROBUS( awsiot_cfg, MIKROBUS_1 );
if ( UART_ERROR == awsiot_init( &awsiot, &awsiot_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_printf( &logger, "Reset device\r\n\n" );
awsiot_reset_device ( &awsiot );
Delay_ms ( 2000 );
log_printf( &logger, "Factory reset\r\n" );
strcpy ( app_buf, AWSIOT_CMD_FACTORY_RESET );
awsiot_send_cmd ( &awsiot, app_buf );
awsiot_read_response ( &awsiot );
Delay_ms ( 2000 );
log_printf( &logger, "Vendor model\r\n" );
strcpy ( app_buf, AWSIOT_CMD_CONF_CHECK );
strcat ( app_buf, AWSIOT_CMD_SEPARATOR );
strcat ( app_buf, AWSIOT_CONF_KEY_ABOUT );
awsiot_send_cmd ( &awsiot, app_buf );
awsiot_read_response ( &awsiot );
log_printf( &logger, "Thing name\r\n" );
strcpy ( app_buf, AWSIOT_CMD_CONF_CHECK );
strcat ( app_buf, AWSIOT_CMD_SEPARATOR );
strcat ( app_buf, AWSIOT_CONF_KEY_THING_NAME );
awsiot_send_cmd ( &awsiot, app_buf );
awsiot_read_response ( &awsiot );
log_info( &logger, " Application Task " );
log_printf( &logger, "Now close the UART terminal and switch to the QuickConnect app\r\n" );
Delay_ms ( 1000 );
uart_set_blocking( &logger.uart, false );
}

Application Task

All data received from the USB UART will be forwarded to mikroBUS UART, and vice versa.

At this point you should disconnect from the UART terminal and run the Quick Connect demo application.

void application_task ( void )
{
app_buf_len = uart_read( &logger.uart, app_buf, PROCESS_BUFFER_SIZE );
if ( app_buf_len > 0 )
{
uart_write ( &awsiot.uart, app_buf, app_buf_len );
awsiot_clear_app_buf( );
}
app_buf_len = uart_read( &awsiot.uart, app_buf, PROCESS_BUFFER_SIZE );
if ( app_buf_len > 0 )
{
uart_write ( &logger.uart, app_buf, app_buf_len );
awsiot_clear_app_buf( );
}
}

Note

To run the demo, follow the below steps:

  1. If you opened a terminal application in the previous step, be sure to > disconnect that application from the serial port.
  2. Download the Quick Connect executable:
  1. Unzip the package, and follow the steps from the README file.

The demo will connect to AWS IoT and give you an URL that you can use to visualize data

flowing from the device to the cloud using AT+SEND commands. The demo will run for up to two minutes, and afterwards, you will be able to type AT+SEND commands yourself and see the data coming in on the visualizer.

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.AWSIoT

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.


AWSIOT_CMD_SEPARATOR
#define AWSIOT_CMD_SEPARATOR
Definition: awsiot.h:76
AWSIOT_CMD_FACTORY_RESET
#define AWSIOT_CMD_FACTORY_RESET
Definition: awsiot.h:66
AWSIOT_CONF_KEY_ABOUT
#define AWSIOT_CONF_KEY_ABOUT
AWS IoT config key parameters list.
Definition: awsiot.h:82
awsiot_cfg_setup
void awsiot_cfg_setup(awsiot_cfg_t *cfg)
AWS IoT configuration object setup function.
AWSIOT_MAP_MIKROBUS
#define AWSIOT_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: awsiot.h:130
awsiot_init
err_t awsiot_init(awsiot_t *ctx, awsiot_cfg_t *cfg)
AWS IoT initialization function.
application_task
void application_task(void)
Definition: main.c:148
PROCESS_BUFFER_SIZE
#define PROCESS_BUFFER_SIZE
Definition: main.c:49
AWSIOT_CONF_KEY_THING_NAME
#define AWSIOT_CONF_KEY_THING_NAME
Definition: awsiot.h:85
awsiot_reset_device
void awsiot_reset_device(awsiot_t *ctx)
AWS IoT reset device function.
awsiot_t
AWS IoT Click context object.
Definition: awsiot.h:146
application_init
void application_init(void)
Definition: main.c:90
AWSIOT_CMD_CONF_CHECK
#define AWSIOT_CMD_CONF_CHECK
Definition: awsiot.h:72
awsiot_cfg_t
AWS IoT Click configuration object.
Definition: awsiot.h:169
awsiot_send_cmd
void awsiot_send_cmd(awsiot_t *ctx, uint8_t *cmd)
AWS IoT send cmd function.