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 " );
}
@ CURRENTSENS2_ERROR
Definition currentsens2.h:138
#define CURRENTSENS2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition currentsens2.h:95
#define CURRENTSENS2_NUM_OF_PASSES_1
Definition currentsens2.h:75
void currentsens2_set_prim_turn_no(currentsens2_t *ctx, uint8_t turns)
Current Sens 2 set number of primary coil turns function.
void application_init(void)
Definition main.c:29

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 );
}
}
@ CURRENTSENS2_OK
Definition currentsens2.h:137
void application_task(void)
Definition main.c:70

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.