rfid  2.0.0.0
Main Page

RFID click

RFid click features CR95HF 13.56 MHz contactless transceiver as well as trace antenna.

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Apr 2021.
  • Type : SPI type

Software Support

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

Standard key functions :

Example key functions :

Example Description

This example demonstrates the use of RFID Click board by reading MIFARE ISO/IEC 14443 type A tag UID.

The demo application is composed of two sections :

Application Init

Initializes the driver, selects the communication interface and performs the click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
rfid_cfg_t rfid_cfg;
// Logger initialization.
LOG_MAP_USB_UART( log_cfg );
log_cfg.level = LOG_LEVEL_DEBUG;
log_cfg.baud = 115200;
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
Delay_ms( 100 );
// Click initialization.
rfid_cfg_setup( &rfid_cfg );
RFID_MAP_MIKROBUS( rfid_cfg, MIKROBUS_1 );
err_t error_flag = rfid_init( &rfid, &rfid_cfg );
if ( error_flag != RFID_OK )
{
log_error( &logger, " Please, run program again... " );
for ( ; ; );
}
log_printf( &logger, " Selecting communication interface... \r\n" );
if ( error_flag != RFID_OK )
{
log_error( &logger, " Please, run program again... " );
for ( ; ; );
}
log_printf( &logger, " Configuring the device... \r\n" );
error_flag = rfid_default_cfg ( &rfid );
if ( error_flag != RFID_OK )
{
log_error( &logger, " Please, run program again... " );
for ( ; ; );
}
log_printf( &logger, " The device has been configured! \r\n" );
}

Application Task

If there's a tag detected, it reads its UID and displays it on USB UART.

void application_task ( void )
{
uint8_t tag_uid[ 20 ] = { 0 };
uint8_t tag_len = rfid_get_tag_uid( &rfid, RFID_ISO_14443A, tag_uid );
if ( tag_len > 0 )
{
log_printf( &logger, " TAG UID: " );
for ( uint8_t cnt = 0; cnt < tag_len; cnt++ )
{
log_printf( &logger, "0x%.2X ", ( uint16_t ) tag_uid[ cnt ] );
}
log_printf( &logger, "\r\n----------------------------------\r\n" );
Delay_ms( 1000 );
}
}

Note

It is recommended to tie SSI_0, SSI_1 to VCC/GND at power-up, depending on the communication interface selection by A and B on-board jumpers. SSI_0 - UART: 0 SPI: 1 SSI_1 - UART: 0 SPI: 0

Only tags with 4-byte or 7-byte UIDs are compatible with this example. We recommend MIKROE-1475 - an RFiD tag 13.56MHz compliant with ISO14443-A standard.

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

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.


rfid_select_communication_interface
err_t rfid_select_communication_interface(rfid_t *ctx, uint8_t com_interface)
Select communication interface.
rfid_cfg_setup
void rfid_cfg_setup(rfid_cfg_t *cfg)
RFID configuration object setup function.
rfid_t
RFID Click context object.
Definition: rfid.h:161
application_task
void application_task(void)
Definition: main.c:83
RFID_MAP_MIKROBUS
#define RFID_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: rfid.h:135
rfid_cfg_t
RFID Click configuration object.
Definition: rfid.h:195
rfid_init
err_t rfid_init(rfid_t *ctx, rfid_cfg_t *cfg)
RFID initialization function.
RFID_OK
Definition: rfid.h:233
RFID_SPI
#define RFID_SPI
Definition: rfid.h:104
RFID_ISO_14443A
#define RFID_ISO_14443A
Definition: rfid.h:95
rfid_get_device_id
err_t rfid_get_device_id(rfid_t *ctx, uint8_t *device_id)
RFID get device id function.
rfid_get_tag_uid
err_t rfid_get_tag_uid(rfid_t *ctx, uint8_t rfid_protocol, uint8_t *tag_uid)
RFID get RFID tag uid function.
application_init
void application_init(void)
Definition: main.c:39
rfid_default_cfg
err_t rfid_default_cfg(rfid_t *ctx)
RFID default configuration function.