TOP Contributors

  1. MIKROE (2784 codes)
  2. Alcides Ramos (405 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (133 codes)
  5. Bugz Bensce (97 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (142085 times)
  2. FAT32 Library (75308 times)
  3. Network Ethernet Library (59504 times)
  4. USB Device Library (49526 times)
  5. Network WiFi Library (45290 times)
  6. FT800 Library (44928 times)
  7. GSM click (31442 times)
  8. mikroSDK (30467 times)
  9. microSD click (27804 times)
  10. PID Library (27625 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

LR 2 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.11

mikroSDK Library: 2.0.0.0

Category: LoRa

Downloaded: 318 times

Not followed.

License: MIT license  

LR 2 Click is a compact add-on board that contains a low-power, long-range transceiver. This board features the RN2903, RF technology-based SRD transceiver, which operates at a frequency of 915MHz from Microchip Technology. This Click board™ features an embedded LoRaWAN Class A compliant stack, providing a long-range spread spectrum communication with high interference immunity. The RN2903 module is fully compliant with the United States (FCC) and Canada (IC) regulations combined with the advanced and straightforward command interface allowing easy integration into the final application.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "LR 2 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "LR 2 Click" changes.

Do you want to report abuse regarding "LR 2 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


LR 2 Click

LR 2 Click is a compact add-on board that contains a low-power, long-range transceiver. This board features the RN2903, RF technology-based SRD transceiver, which operates at a frequency of 915MHz from Microchip Technology. This Click board™ features an embedded LoRaWAN Class A compliant stack, providing a long-range spread spectrum communication with high interference immunity. The RN2903 module is fully compliant with the United States (FCC) and Canada (IC) regulations combined with the advanced and straightforward command interface allowing easy integration into the final application.

lr_2_click.png

Click Product page


Click library

  • Author : Stefan Ilic
  • Date : Jun 2021.
  • Type : UART type

Software Support

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

Standard key functions :

  • lr2_cfg_setup Config Object Initialization function.

    void lr2_cfg_setup ( lr2_cfg_t *cfg );
  • lr2_init Initialization function.

    err_t lr2_init ( lr2_t *ctx, lr2_cfg_t *cfg );
  • lr2_default_cfg Click Default Configuration function.

    void lr2_default_cfg ( lr2_t *ctx, bool cb_default, void ( *response_p )( char *response ) );

Example key functions :

  • lr2_mac_tx Function for writing mac parameters

    uint8_t lr2_mac_tx ( lr2_t *ctx, lr2_mac_t *mac );
  • lr2_join Function for setting join mode

    uint8_t lr2_join ( lr2_t *ctx, char *join_mode, char *response );
  • lr2_tick_conf Timer Configuration

    void lr2_tick_conf ( lr2_t *ctx, uint32_t timer_limit );

Example Description

This example shows the usage of the LR 2 Click board by transmitting and receiving data.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs default configuration and reads System version.


void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    lr2_cfg_t lr2_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.
    lr2_cfg_setup( &lr2_cfg );
    LR2_MAP_MIKROBUS( lr2_cfg, MIKROBUS_1 );
    if ( UART_ERROR == lr2_init( &lr2, &lr2_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    lr2_default_cfg( &lr2, 0, 0 );
    lr2_process( );

    lr2_cmd( &lr2, LR2_CMD_SYS_GET_VER, resp_buf );
    log_printf( &logger, " System VER: %s \r\n", resp_buf );

    lr2_cmd( &lr2, LR2_CMD_MAC_PAUSE, resp_buf );
    log_printf( &logger, " MAC PAUSE: %s \r\n", resp_buf );

    lr2_cmd( &lr2, LR2_CMD_RADIO_SET_WDT, resp_buf );
    log_printf( &logger, " RADIO SET WDT 0: %s \r\n", resp_buf );

#ifdef DEMO_APP_TRANSMITTER
    log_printf( &logger, " Application Mode: Transmitter\r\n" );
#else
    log_printf( &logger, " Application Mode: Receiver\r\n" );
#endif
    log_info( &logger, " Application Task " );
}

Application Task

Transmitter mode - sends a desired message each second and checks if it is sent successfully. Receiver mode - displays all the received characters on USB UART.


void application_task ( void ) 
{
    lr2_process( );

#ifdef DEMO_APP_TRANSMITTER
    uint8_t hex_buf[ 50 ] = { 0 };
    uint8_t cnt = 0;
    for ( cnt = 0; cnt < strlen( send_message ); cnt++ ) 
    {
        uint8_to_hex( send_message[ cnt ], &hex_buf[ cnt * 2 ] );
    }
    if ( LR2_OK == lr2_tx( &lr2, hex_buf ) ) 
    {
        log_printf( &logger, " Sent message: %s", send_message );
        log_printf( &logger, " Response : %s\r\n", resp_buf );
    }
    Delay_ms ( 1000 );
#else
    if ( LR2_OK == lr2_rx( &lr2, LR2_ARG_0, resp_buf ) ) 
    {
        uint8_t text_buf[ 20 ] = { 0 };
        uint8_t hex_buf[ 3 ] = { 0 };
        uint8_t cnt = 0;
        for ( cnt = 0; cnt < ( strlen( resp_buf ) - 10 ); cnt += 2 )
        {
            hex_buf[ 0 ] = resp_buf[ 10 + cnt ];
            hex_buf[ 1 ] = resp_buf[ 11 + cnt ];
            text_buf[ cnt / 2 ] = hex_to_uint8( hex_buf );
        }
        log_printf( &logger, "Received message: %s\r\n", text_buf );
    }
#endif
}

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

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.


ALSO FROM THIS AUTHOR

UT-S 7 SEG R click

0

UT-S 7 SEG R click uses two SMD ultra-thin DSM7UA 7-SEG LED displays, made with the patented technology that delivers thickness of only 2.1 mm. These displays are driven by the MAX6969, a constant current LED integrated driver from Maxim Integrated, which uses the SPI serial interface for communication.

[Learn More]

Nano GPS 2 click

5

Nano GPS 2 Click features the smallest GPS module with an integrated patch antenna, the ORG1510-MK05 a module from OriginGPS. It’s the world’s smallest multi-constellation antenna module enabling high-performance in a variety of applications.

[Learn More]

Analog MUX 2 Click

0

Analog MUX 2 Click is a compact add-on board that switches one of the eight inputs to one output. This board features the ADG728, a low voltage, CMOS 8-channel analog matrix switch with a serially controlled 2-wire interface from Analog Devices. The ADG728 can operate equally well as either multiplexer, demultiplexer, or switch array easily connected to a 9 pole spring action block terminal. It provides flexibility and features a low on-resistance closely matched between switches and very flat over the full signal range. This Click board™ is suitable for a wide range of applications, from industrial and instrumentation to medical, consumer, communications, and automotive systems.

[Learn More]