ibutton  2.1.0.0
Main Page

iButton click

iButton click - is an iButton™ probe Click board™. The iButton is a Analog Devices technology based on Analog's 1-Wire® communication protocol, and a chip usually packed in a robust stainless steel casing. The button-shaped iButton device has two contacts - the lid and the base. These contacts carry the necessary connections down to a sensitive silicone chip, embedded inside the metal button. When the iButton touches the reader probe on the Click board™, it establishes the communication with the host MCU, via the 1-Wire® interface. The communication is almost instant, so it is enough to press the iButton lightly to the probe contacts.

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Feb 2024.
  • Type : One Wire type

Software Support

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

Standard key functions :

Example key functions :

  • ibutton_add_key This function reads the ROM address from a DS1990A Serial Number iButton and stores it in the ctx->key_rom buffer.
    err_t ibutton_add_key ( ibutton_t *ctx );
  • ibutton_remove_keys This function removes all stored keys by clearing the ctx->key_rom buffer.
  • ibutton_check_key This function reads the ROM address from a DS1990A Serial Number iButton and checks if it is already stored in the ctx->key_rom buffer.

Example Description

This example demonstrates the use of the iButton click boards by registering a DS1990A Serial Number iButton

key and then waiting until a key is detected on the reader and identifying if the key matches one of those stored in RAM.

The demo application is composed of two sections :

Application Init

Initializes the driver and registers a new DS1990A Serial Number iButton key and stores it in RAM.

void application_init ( void )
{
log_cfg_t log_cfg;
ibutton_cfg_t ibutton_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
ibutton_cfg_setup( &ibutton_cfg );
IBUTTON_MAP_MIKROBUS( ibutton_cfg, MIKROBUS_1 );
if ( ONE_WIRE_ERROR == ibutton_init( &ibutton, &ibutton_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
ibutton_register_keys ( &ibutton, NUMBER_OF_KEYS );
log_info( &logger, " Application Task " );
}

Application Task

Waits until a key is detected on the reader, and checks if there's a key found in the library that matches the one it has just read.

All data is being logged on the USB UART where you can track the program flow.

void application_task ( void )
{
err_t error_flag = IBUTTON_OK;
ibutton_led_indication ( &ibutton, IBUTTON_LED_DISABLE );
log_printf( &logger, " >>> Waiting for a key <<<\r\n" );
do
{
ibutton_led_indication ( &ibutton, IBUTTON_LED_WAIT_KEY );
error_flag = ibutton_check_key ( &ibutton );
}
while ( IBUTTON_ERROR == error_flag );
ibutton_led_indication ( &ibutton, IBUTTON_LED_DISABLE );
if ( IBUTTON_OK == error_flag )
{
log_printf( &logger, " MATCH, access allowed!\r\n" );
ibutton_led_indication ( &ibutton, IBUTTON_LED_SUCCESS );
}
else if ( IBUTTON_KEY_NO_MATCH == error_flag )
{
log_printf( &logger, " NO MATCH, access denied!\r\n" );
ibutton_led_indication ( &ibutton, IBUTTON_LED_WRONG_KEY );
}
ibutton_led_indication ( &ibutton, IBUTTON_LED_DISABLE );
log_printf( &logger, "--------------------------------\r\n\n" );
Delay_ms ( 500 );
}

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

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.


ibutton_cfg_t
iButton Click configuration object.
Definition: ibutton.h:159
IBUTTON_LED_SUCCESS
@ IBUTTON_LED_SUCCESS
Definition: ibutton.h:193
NUMBER_OF_KEYS
#define NUMBER_OF_KEYS
Definition: main.c:27
IBUTTON_LED_WRONG_KEY
@ IBUTTON_LED_WRONG_KEY
Definition: ibutton.h:194
IBUTTON_LED_DISABLE
@ IBUTTON_LED_DISABLE
Definition: ibutton.h:191
application_task
void application_task(void)
Definition: main.c:90
IBUTTON_OK
@ IBUTTON_OK
Definition: ibutton.h:178
ibutton_check_key
err_t ibutton_check_key(ibutton_t *ctx)
iButton check key function.
ibutton_cfg_setup
void ibutton_cfg_setup(ibutton_cfg_t *cfg)
iButton configuration object setup function.
IBUTTON_MAP_MIKROBUS
#define IBUTTON_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: ibutton.h:116
IBUTTON_ERROR
@ IBUTTON_ERROR
Definition: ibutton.h:179
ibutton_add_key
err_t ibutton_add_key(ibutton_t *ctx)
iButton add key function.
IBUTTON_KEY_NO_MATCH
@ IBUTTON_KEY_NO_MATCH
Definition: ibutton.h:181
IBUTTON_LED_WAIT_KEY
@ IBUTTON_LED_WAIT_KEY
Definition: ibutton.h:192
application_init
void application_init(void)
Definition: main.c:58
ibutton_t
iButton Click context object.
Definition: ibutton.h:141
ibutton_init
err_t ibutton_init(ibutton_t *ctx, ibutton_cfg_t *cfg)
iButton initialization function.
ibutton_remove_keys
void ibutton_remove_keys(ibutton_t *ctx)
iButton remove keys function.