Intermediate
20 min

Maximize your data transmission capabilities with EMB-LR1276S and PIC24F16KA102

Reaching new horizons with 868MHz long-range transceivers

Nano LR Click with EasyPIC v8 for PIC24/dsPIC33

Published Nov 01, 2023

Click board™

Nano LR Click

Dev Board

EasyPIC v8 for PIC24/dsPIC33

Compiler

NECTO Studio

MCU

PIC24F16KA102

Our 868MHz long-range transceiver is meticulously engineered to extend the reach of your wireless communication, allowing you to collect and transmit critical data from remote and challenging locations with unmatched reliability.

A

A

Hardware Overview

How does it work?

Nano LR Click is based on the EMB-LR1276S, a sub-1GHz wireless module that supports the LoRaWAN long-range wireless protocol based on the SAMR34 SiP from Embit. It offers a long-range spread spectrum communication with high interference immunity. Nano LR Click is ideal for various applications, such as IoT, home and building automation, wireless alarm and security systems, automated meter readings, industrial monitoring and control, and more. The EMB-LR1276S can be configured as an embedded microsystem or a simple data modem for

low-power applications in the 868MHz and 915MHz radio bands. It is equipped with up to 256 KB of Flash and up to 40 KB of SRAM, and it supports long-range and FSK modulation. Nano LR Click communicates with MCU using the UART interface with commonly used UART RX and TX pins with the hardware flow control pins UART CTS, RTS, RI (Clear to Send, Ready to Send, and Ring Indicator). Besides these pins, Nano LR Click also has GP1 and STAT pins, which are routed to the PWM and AN pins of the mikroBUS™ socket, respectively. STAT pin is also wired to a separate

LED indicator labeled STAT to enable quick and easy module status indication. Nano LR Click features the U.FL antenna connector with an impedance of 50Ω, so it can be equipped with the appropriate antenna that MIKROE offers. 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.

Nano LR Click hardware overview image

Features overview

Development board

EasyPIC v8 for PIC24/dsPIC33 is a development board specially designed for the needs of rapid development of embedded applications. It supports a wide range of 16-bit PIC24/dsPIC33 microcontrollers from Microchip and has 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 for PIC24/dsPIC33 provides a fluid and immersive working experience, allowing access anywhere and under any circumstances. Each part of the EasyPIC

v8 for PIC24/dsPIC33 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 HOST/DEVICE, USB-UART, CAN, and LIN 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 16-bit PIC24/dsPIC33 MCUs, from the smallest PIC24/dsPIC33 MCUs with only 14 up to 28 pins. EasyPIC v8 for PIC24/dsPIC33 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 for PIC24/dsPIC33 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Architecture

dsPIC

MCU Memory (KB)

16

Silicon Vendor

Microchip

Pin count

28

RAM (Bytes)

1536

You complete me!

Accessories

Rubber Antenna GSM/GPRS Right Angle is the perfect companion for all GSM Click boards™ in our extensive lineup. This specialized antenna is designed to optimize your wireless connectivity with impressive features. With a wide frequency range spanning 824-894/1710-1990MHz or 890-960/1710-1890MHz, it can handle various frequency bands, ensuring a seamless and reliable connection. The antenna boasts an impedance of 50 Ohms and a gain of 2dB, enhancing signal reception and transmission. Its 70/180MHz bandwidth provides flexibility for diverse applications. The vertical polarization further enhances its performance. With a maximum input power capacity of 50W, this antenna ensures robust communication even under demanding conditions. Measuring a compact 50mm in length and featuring an SMA male connector, the Rubber Antenna GSM/GPRS Right Angle is a versatile and compact solution for your wireless communication needs.

Nano LR Click accessories 1 image

IPEX-SMA cable is a type of RF (radio frequency) cable assembly. "IPEX" refers to the IPEX connector, a miniature coaxial connector commonly used in small electronic devices. "SMA" stands for SubMiniature Version A and is another coaxial connector commonly used in RF applications. An IPEX-SMA cable assembly has an IPEX connector on one end and an SMA connector on the other, allowing it to connect devices or components that use these specific connectors. These cables are often used in applications like WiFi or cellular antennas, GPS modules, and other RF communication systems where a reliable and low-loss connection is required.

Nano LR Click accessories 2 image

Used MCU Pins

mikroBUS™ mapper

Module Status
RA0
AN
Reset
RB4
RST
UART CTS
RA4
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
General-Purpose I/O
RB13
PWM
UART RTS
RB7
INT
UART TX
RB0
TX
UART RX
RB1
RX
NC
NC
SCL
NC
NC
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Schematic

Nano LR Click Schematic schematic

Step by step

Project assembly

EasyPIC v8 for PIC24/dsPIC33 front image hardware assembly

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

EasyPIC v8 for PIC24/dsPIC33 front image hardware assembly
GNSS2 Click front image hardware assembly
MCU DIP 28 hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
EasyPIC PIC24/dsPIC33 v8 Access DIP MB 1 - 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 Nano LR Click driver.

Key functions:

  • nanolr_send_data - This function sends data command depends on the chosen network protocol.

  • nanolr_uart_isr - This function reads response bytes from the device and sets flag after each received byte.

  • nanolr_rsp_rdy - This function checks if the response is ready.

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 
 * \brief NanoLR Click example
 * 
 * # Description
 * This example reads and processes data from Nano LR clicks.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes the driver, and performs the click default configuration.
 * 
 * ## Application Task  
 * Depending on the selected mode, it reads all the received data or sends a desired message
 * every 2 seconds. All data is being displayed on the USB UART.
 * 
 * ## Additional Function
 * - nanolr_process ( ) - Waits until a new message is ready, then parses it and displays the message
 *                        info on the USB UART.
 * 
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "nanolr.h"
#include "string.h"

// ------------------------------------------------------------------ VARIABLES

// #define DEMO_APP_RECEIVER
#define DEMO_APP_TRANSMITTER

#define TEXT_TO_SEND "MikroE - Nano LR click"

static nanolr_t nanolr;
static log_t logger;

// ------------------------------------------------------- ADDITIONAL FUNCTIONS

void nanolr_process( )
{
    uint8_t tmp_buf[ 200 ];
    
    // Clear RX buffer
    nanolr_generic_read( &nanolr, tmp_buf, 200 );
    
    while ( nanolr_rsp_rdy( &nanolr ) == 0 )
    {
        nanolr_uart_isr ( &nanolr );
        Delay_ms( 1 ); 
    }

    nanolr_err_t error;
    nanolr_rsp_t response;

    error = nanolr_parser_rsp( &nanolr, &response );

    if ( error == 0 )
    {
        log_printf( &logger, "** Message received!\r\n" );
        log_printf( &logger, "** Message Length: %u\r\n", response.length );
        log_printf( &logger, "** Notification ID: 0x%.2X\r\n", ( uint16_t ) response.message_id );
        log_printf( &logger, "** Options: 0x%.4X\r\n", ( response.payload[ 0 ] << 8 ) | response.payload[ 1 ] );
        log_printf( &logger, "** RSSI in dBm: %d\r\n", ( response.payload[ 2 ] << 8 ) | ~response.payload[ 3 ] );
        log_printf( &logger, "** Source Address: 0x%.4X\r\n", ( response.payload[ 4 ] << 8 ) | response.payload[ 5 ] );
        log_printf( &logger, "** Destination Address: 0x%.4X\r\n", ( response.payload[ 6 ] << 8 ) | response.payload[ 7 ] );
        log_printf( &logger, "** Message Content: " );
        for ( uint16_t cnt = 8; cnt < response.length - 4; cnt++ )
        {
            log_printf( &logger, "%c", ( uint16_t ) response.payload[ cnt ] );
        }

        log_printf( &logger, "\r\n** Checksum: 0x%.2X\r\n", ( uint16_t ) response.crc );
    }
    else
    {
        log_printf( &logger, "** Message Error!\r\n" );
    }
    log_printf( &logger, "------------------------------------\r\n" );

    log_printf( &logger, "\r\n" );
}

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    log_cfg_t log_cfg;
    nanolr_cfg_t cfg;

    /** 
     * 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.

    nanolr_cfg_setup( &cfg );
    NANOLR_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    nanolr_init( &nanolr, &cfg );

    nanolr_default_cfg( &nanolr );

    log_printf( &logger,  "----  Nano LR Click ----\r\n" );

#ifdef DEMO_APP_RECEIVER
    log_printf( &logger,  "---- RECEIVER MODE ----\r\n" );
#endif
    
#ifdef DEMO_APP_TRANSMITTER
    log_printf( &logger,  "---- TRANSMITER MODE ----\r\n" );
#endif 
    Delay_ms( 2000 );
}

void application_task ( void )
{    
#ifdef DEMO_APP_RECEIVER
    nanolr_process( );
#endif

#ifdef DEMO_APP_TRANSMITTER
    nanolr_send_data( &nanolr, TEXT_TO_SEND, strlen( TEXT_TO_SEND ) );
    log_printf( &logger, "The message \"%s\" has been sent!\r\n", ( uint8_t * ) TEXT_TO_SEND );
    log_printf( &logger, "------------------------------------------------------------\r\n" );
    Delay_ms( 2000 );
#endif
}

void main ( void )
{
    application_init( );

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

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

Additional Support

Resources