current5  2.0.0.0
Main Page

Current 5 click

<PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU>

[click Product page](<CLICK_PRODUCT_PAGE_LINK>)


Click library

  • Author : Luka Filipovic
  • Date : Sep 2021.
  • Type : SPI type

Software Support

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

Standard key functions :

Example key functions :

Example Description

This example application showcases ability of the device

to read raw adc data and calculate the current from it.

The demo application is composed of two sections :

Application Init

Initialization of communication modules(SPI, UART) and

additional pins for controlling device(RST, ALERT->INT).

void application_init ( void )
{
log_cfg_t log_cfg;
current5_cfg_t current5_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
current5_cfg_setup( &current5_cfg );
CURRENT5_MAP_MIKROBUS( current5_cfg, MIKROBUS_1 );
err_t init_flag = current5_init( &current5, &current5_cfg );
if ( SPI_MASTER_ERROR == init_flag )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

Read ADC data with SPI communication and calculate input current.

void application_task ( void )
{
float current = 0;
current5_get_current( &current5, &current );
log_printf( &logger, " > Current[ A ]: %.2f\r\n", current );
log_printf( &logger, "*************************************************\r\n" );
Delay_ms( 300 );
}

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

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.


current5_get_alert
uint8_t current5_get_alert(current5_t *ctx)
Get alert pin state.
current5_cfg_t
Current 5 Click configuration object.
Definition: current5.h:128
current5_get_adc
err_t current5_get_adc(current5_t *ctx, uint16_t *adc_data)
Read raw adc value.
CURRENT5_MAP_MIKROBUS
#define CURRENT5_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: current5.h:93
application_task
void application_task(void)
Definition: main.c:62
current5_get_current
err_t current5_get_current(current5_t *ctx, float *current)
Get current.
application_init
void application_init(void)
Definition: main.c:29
current5_t
Current 5 Click context object.
Definition: current5.h:109
current5_cfg_setup
void current5_cfg_setup(current5_cfg_t *cfg)
Current 5 configuration object setup function.
current5_init
err_t current5_init(current5_t *ctx, current5_cfg_t *cfg)
Current 5 initialization function.