currentsens2  2.1.0.0
Main Page

Current Sens 2 click

Current Sens 2 Click is a compact add-on board designed for precise current measurements in industrial applications. This board features the HO 10-P, an AC/DC current transducer from LEM USA.

click Product page


Click library

  • Author : Stefan Ilic
  • Date : Nov 2023.
  • Type : ADC type

Software Support

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

Standard key functions :

Example key functions :

Example Description

This example demonstrates the use of Current Sens 2 click board by reading and

displaying the input current measurements.

The demo application is composed of two sections :

Application Init

Initializes the driver and logger.

void application_init ( void )
{
log_cfg_t log_cfg;
currentsens2_cfg_t currentsens2_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
currentsens2_cfg_setup( &currentsens2_cfg );
CURRENTSENS2_MAP_MIKROBUS( currentsens2_cfg, MIKROBUS_1 );
if ( ADC_ERROR == currentsens2_init( &currentsens2, &currentsens2_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_printf( &logger, " Remove Click from the electrical circuit \r\n" );
Delay_ms ( 1000 );
if ( CURRENTSENS2_ERROR == currentsens2_tare ( &currentsens2 ) )
{
log_error( &logger, " Click tare error." );
for ( ; ; );
}
log_printf( &logger, " Connect Click to the electrical circuit \r\n" );
log_info( &logger, " Application Task " );
}

Application Task

Reads the input current measurements and displays the results on the USB UART

approximately once per second.

void application_task ( void )
{
float current = 0;
if ( CURRENTSENS2_OK == currentsens2_get_current ( &currentsens2, &current ) )
{
log_printf( &logger, " Current : %.2f[A]\r\n\n", current );
Delay_ms ( 1000 );
}
}

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

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.


currentsens2_get_current
err_t currentsens2_get_current(currentsens2_t *ctx, float *current)
Current Sens 2 read current function.
currentsens2_cfg_setup
void currentsens2_cfg_setup(currentsens2_cfg_t *cfg)
Current Sens 2 configuration object setup function.
CURRENTSENS2_MAP_MIKROBUS
#define CURRENTSENS2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: currentsens2.h:95
CURRENTSENS2_NUM_OF_PASSES_1
#define CURRENTSENS2_NUM_OF_PASSES_1
Definition: currentsens2.h:75
application_task
void application_task(void)
Definition: main.c:70
currentsens2_get_int_pin
uint8_t currentsens2_get_int_pin(currentsens2_t *ctx)
Current Sens 2 get int pin state function.
currentsens2_t
Current Sens 2 Click context object.
Definition: currentsens2.h:107
CURRENTSENS2_OK
@ CURRENTSENS2_OK
Definition: currentsens2.h:137
currentsens2_set_prim_turn_no
void currentsens2_set_prim_turn_no(currentsens2_t *ctx, uint8_t turns)
Current Sens 2 set number of primary coil turns function.
CURRENTSENS2_ERROR
@ CURRENTSENS2_ERROR
Definition: currentsens2.h:138
currentsens2_init
err_t currentsens2_init(currentsens2_t *ctx, currentsens2_cfg_t *cfg)
Current Sens 2 initialization function.
application_init
void application_init(void)
Definition: main.c:29
currentsens2_cfg_t
Current Sens 2 Click configuration object.
Definition: currentsens2.h:122
currentsens2_tare
err_t currentsens2_tare(currentsens2_t *ctx)
Current Sens 2 tare function.