Beginner
10 min

Collect, store, and analyze data effortlessly across various applications with NORA-W256WS and PIC18F2550

Wire-free wonders await – Elevate your tech experience today!

IoT ExpressLink 3 Click with EasyPIC v8

Published Nov 01, 2023

Click board™

IoT ExpressLink 3 Click

Dev.Board

EasyPIC v8

Compiler

NECTO Studio

MCU

PIC18F2550

With IoT ExpressLink, you can unlock the potential of your projects and seamlessly connect to the Cloud. No need for specialized knowledge – we've got security covered!

A

A

Hardware Overview

How does it work?

IoT ExpressLink 3 Click is based on the NORA-W256WS, a standalone multi-radio module from u-blox. Under the hood is the ESP32-S3, a radio for wireless communication, and a dual-core MCU from Esspressif. This powerful 32-bit microcontroller has 512KB of RAM and 8192KB of flash memory. It features host software OTA, module firmware OTA, secure boot, end-to-end security (TLS), MQTT, stateless AT commands, WPA/WPA2/WPA3, and more. With pre-flashed AWS IoT ExpressLink software that offers out-of-the-box connectivity with Amazon Web Services (AWS), you can benefit from convenient cloud

access to applications and all other services that AWS provides. The NORA-W256WS module comes with a printed antenna that serves both radios. You can only use one at a time. The module also features an RGB LED that visualizes the system statuses. IoT ExpressLink 3 Click uses a standard 2-Wire UART interface to communicate with the host MCU, with commonly used UART RX and TX pins over the 115200bps baud rate. The ExpressLink events can be monitored over the EVT pin. The module enters a standby state and stops the Wi-Fi until the wake WK pin is asserted. Toggling this pin when the module is in deep sleep mode allows

the module to enter active wake mode. The module can be reset (rebooted) over the RST pin. You can also reset the module over the RESET button. In addition, you can reset the ExpressLink over the RSN pin. 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.

IoT ExpressLink 3 Click hardware overview image

Features overview

Development board

EasyPIC v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports many high pin count 8-bit PIC microcontrollers from Microchip, regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, EasyPIC v8 provides a fluid and immersive working experience, allowing access anywhere and under any

circumstances at any time. Each part of the EasyPIC v8 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 a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector.

Communication options such as USB-UART, USB DEVICE, and CAN are also included, including the well-established mikroBUS™ standard, two display options (graphical and character-based LCD), and several different DIP sockets. These sockets cover a wide range of 8-bit PIC MCUs, from the smallest PIC MCU devices with only eight up to forty pins. EasyPIC v8 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.

EasyPIC v8 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC

MCU Memory (KB)

32

Silicon Vendor

Microchip

Pin count

28

RAM (Bytes)

2048

Used MCU Pins

mikroBUS™ mapper

Reset Nora Module
RA3
AN
Device Enable / ID SEL
RA0
RST
Chip Select / ID COMM
RA5
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Module Wake Up
RC1
PWM
Event Interrupt
RB1
INT
UART TX
RC6
TX
UART RX
RC7
RX
NC
NC
SCL
NC
NC
SDA
NC
NC
5V
Ground
GND
GND
2

Take a closer look

Schematic

IoT ExpressLink 3 Click Schematic schematic

Step by step

Project assembly

EasyPIC v8 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the EasyPIC v8 as your development board.

EasyPIC v8 front image hardware assembly
Rotary B 2 Click front image hardware assembly
MCU DIP 28 hardware assembly
EasyPIC v8 28pin-DIP - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
NECTO Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto DIP image step 7 hardware assembly
Necto image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image hardware assembly

Track your results in real time

Application Output

After pressing the "FLASH" button on the left-side panel, it is necessary to open the UART terminal to display the achieved results. By clicking on the Tools icon in the right-hand panel, multiple different functions are displayed, among which is the UART Terminal. Click on the offered "UART Terminal" icon.

UART Application Output Step 1

Once the UART terminal is opened, the window takes on a new form. At the top of the tab are two buttons, one for adjusting the parameters of the UART terminal and the other for connecting the UART terminal. The tab's lower part is reserved for displaying the achieved results. Before connecting, the terminal has a Disconnected status, indicating that the terminal is not yet active. Before connecting, it is necessary to check the set parameters of the UART terminal. Click on the "OPTIONS" button.

UART Application Output Step 2

In the newly opened UART Terminal Options field, we check if the terminal settings are correct, such as the set port and the Baud rate of UART communication. If the data is not displayed properly, it is possible that the Baud rate value is not set correctly and needs to be adjusted to 115200. If all the parameters are set correctly, click on "CONFIGURE".

UART Application Output Step 3

The next step is to click on the "CONNECT" button, after which the terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART Application Output Step 4

Software Support

Library Description

This library contains API for IoT ExpressLink 3 Click driver.

Key functions:

  • iotexpresslink3_reset_device - This function resets device by toggling the RST pin state.

  • iotexpresslink3_send_cmd - This function send command string by using UART serial interface.

Open Source

Code example

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

/*!
 * @file main.c
 * @brief IoT ExpressLink 3 Click Example.
 *
 * # Description
 * This example demonstrates the use of IoT ExpressLink 3 click board by bridging the USB UART
 * to mikroBUS UART which allows the click board to establish a connection with
 * the IoT ExpressLink 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, reads
 * and displays the vendor model and thing name on the USB UART, sets the WiFi credentials,
 * and attempts to connect to the AWS Cloud. If the initial attempt fails and the error
 * message "Failed to access network" or "Failed to login AWS (MQTT) broker" appears,
 * check the WiFi credentials and try running the example again.
 *
 * ## 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.
 *
 * ## Additional Function
 * - static void iotexpresslink3_clear_app_buf ( void )
 * - static err_t iotexpresslink3_process ( iotexpresslink3_t *ctx )
 * - static err_t iotexpresslink3_read_response ( iotexpresslink3_t *ctx )
 *
 * @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: 
 *    Mac: https://quickconnectexpresslinkutility.s3.us-west-2.amazonaws.com/QuickConnect_v1.9_macos.x64.tar.gz
 *    Windows: https://quickconnectexpresslinkutility.s3.us-west-2.amazonaws.com/QuickConnect_v1.9_windows.x64.zip
 *    Linux: https://quickconnectexpresslinkutility.s3.us-west-2.amazonaws.com/QuickConnect_v1.9_linux.x64.tar.gz
 * 3. Unzip the package, and follow the steps from the README file.
 * 
 * The demo will connect to IoT ExpressLink 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.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "iotexpresslink3.h"

// Enter valid WiFi credentials below
#define WIFI_SSID               "MikroE Public"     // WiFi SSID
#define WIFI_PASS               "mikroe.guest"      // WiFi Password

// Application buffer size
#define APP_BUFFER_SIZE         500
#define PROCESS_BUFFER_SIZE     200

static iotexpresslink3_t iotexpresslink3;
static log_t logger;

static uint8_t app_buf[ APP_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;

/**
 * @brief IoT ExpressLink 3 clearing application buffer.
 * @details This function clears memory of application buffer and reset its length.
 * @note None.
 */
static void iotexpresslink3_clear_app_buf ( void );

/**
 * @brief IoT ExpressLink 3 data reading function.
 * @details This function reads data from device and concatenates data to application buffer. 
 * @param[in] ctx : Click context object.
 * See #iotexpresslink3_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 iotexpresslink3_process ( iotexpresslink3_t *ctx );

/**
 * @brief IoT ExpressLink 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 #iotexpresslink_t object definition for detailed explanation.
 * @return @li @c  0 - OK response.
 *         @li @c -2 - Timeout error.
 *         @li @c -3 - Command error.
 *         @li @c -4 - Unknown error.
 * See #err_t definition for detailed explanation.
 * @note None.
 */
static err_t iotexpresslink3_read_response ( iotexpresslink3_t *ctx );

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    iotexpresslink3_cfg_t iotexpresslink3_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.
    iotexpresslink3_cfg_setup( &iotexpresslink3_cfg );
    IOTEXPRESSLINK3_MAP_MIKROBUS( iotexpresslink3_cfg, MIKROBUS_1 );
    if ( UART_ERROR == iotexpresslink3_init( &iotexpresslink3, &iotexpresslink3_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    log_printf( &logger, "Reset device\r\n\n" );
    iotexpresslink3_reset_device ( &iotexpresslink3 );
    Delay_ms ( 2000 );

    log_printf( &logger, "Factory reset\r\n" );
    strcpy ( app_buf, IOTEXPRESSLINK3_CMD_FACTORY_RESET );
    iotexpresslink3_send_cmd ( &iotexpresslink3, app_buf );
    iotexpresslink3_read_response ( &iotexpresslink3 );
    Delay_ms ( 2000 );
    
    log_printf( &logger, "Vendor model\r\n" );
    strcpy ( app_buf, IOTEXPRESSLINK3_CMD_CONF_CHECK );
    strcat ( app_buf, IOTEXPRESSLINK3_CMD_SEPARATOR );
    strcat ( app_buf, IOTEXPRESSLINK3_CONF_KEY_ABOUT );
    iotexpresslink3_send_cmd ( &iotexpresslink3, app_buf );
    iotexpresslink3_read_response ( &iotexpresslink3 );
    
    log_printf( &logger, "Thing name\r\n" );
    strcpy ( app_buf, IOTEXPRESSLINK3_CMD_CONF_CHECK );
    strcat ( app_buf, IOTEXPRESSLINK3_CMD_SEPARATOR );
    strcat ( app_buf, IOTEXPRESSLINK3_CONF_KEY_THING_NAME );
    iotexpresslink3_send_cmd ( &iotexpresslink3, app_buf );
    iotexpresslink3_read_response ( &iotexpresslink3 );
    
    log_printf( &logger, "WiFi SSID\r\n" );
    strcpy ( app_buf, IOTEXPRESSLINK3_CMD_CONF );
    strcat ( app_buf, IOTEXPRESSLINK3_CMD_SEPARATOR );
    strcat ( app_buf, IOTEXPRESSLINK3_CONF_KEY_SSID );
    strcat ( app_buf, IOTEXPRESSLINK3_CMD_SIGN_EQUAL );
    strcat ( app_buf, WIFI_SSID );
    iotexpresslink3_send_cmd ( &iotexpresslink3, app_buf );
    iotexpresslink3_read_response ( &iotexpresslink3 );
    
    log_printf( &logger, "WiFi Password\r\n" );
    strcpy ( app_buf, IOTEXPRESSLINK3_CMD_CONF );
    strcat ( app_buf, IOTEXPRESSLINK3_CMD_SEPARATOR );
    strcat ( app_buf, IOTEXPRESSLINK3_CONF_KEY_PASSPHRASE );
    strcat ( app_buf, IOTEXPRESSLINK3_CMD_SIGN_EQUAL );
    strcat ( app_buf, WIFI_PASS );
    iotexpresslink3_send_cmd ( &iotexpresslink3, app_buf );
    iotexpresslink3_read_response ( &iotexpresslink3 );
    
    log_printf( &logger, "Try to connect\r\n" );
    strcpy ( app_buf, IOTEXPRESSLINK3_CMD_CONNECT );
    iotexpresslink3_send_cmd ( &iotexpresslink3, app_buf );
    iotexpresslink3_read_response ( &iotexpresslink3 );
    
    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 );
}

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

void main ( void ) 
{
    application_init( );

    for ( ; ; ) 
    {
        application_task( );
    }
}

static void iotexpresslink3_clear_app_buf ( void ) 
{
    memset( app_buf, 0, APP_BUFFER_SIZE );
    app_buf_len = 0;
}

static void iotexpresslink3_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 iotexpresslink3_process ( iotexpresslink3_t *ctx ) 
{
    uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
    int32_t overflow_bytes = 0;
    int32_t rx_cnt = 0;
    int32_t rx_size = iotexpresslink3_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 IOTEXPRESSLINK3_OK;
    }
    return IOTEXPRESSLINK3_ERROR;
}


static err_t iotexpresslink3_read_response ( iotexpresslink3_t *ctx ) 
{
    uint32_t timeout_cnt = 0;
    uint32_t timeout = 30000;
    iotexpresslink3_clear_app_buf ( );
    iotexpresslink3_process( ctx );
    while ( ( 0 == strstr( app_buf, IOTEXPRESSLINK3_RSP_OK ) ) &&
            ( 0 == strstr( app_buf, IOTEXPRESSLINK3_RSP_ERR ) ) )
    {
        iotexpresslink3_process( ctx );
        if ( timeout_cnt++ > timeout )
        {
            iotexpresslink3_clear_app_buf( );
            return IOTEXPRESSLINK3_ERROR_TIMEOUT;
        }
        Delay_ms( 1 );
    }
    Delay_ms ( 100 );
    iotexpresslink3_process( ctx );
    if ( app_buf_len > 0 ) 
    {
        log_printf( &logger, "%s\r\n", app_buf );
    }
    if ( strstr( app_buf, IOTEXPRESSLINK3_RSP_OK ) )
    {
        iotexpresslink3_clear_app_buf( );
        return IOTEXPRESSLINK3_OK;
    }
    else if ( strstr( app_buf, IOTEXPRESSLINK3_RSP_ERR ) )
    {
        iotexpresslink3_clear_app_buf( );
        return IOTEXPRESSLINK3_ERROR_CMD;
    }
    iotexpresslink3_clear_app_buf( );
    return IOTEXPRESSLINK3_ERROR_UNKNOWN;
}

// ------------------------------------------------------------------------ END

Additional Support

Resources