loadcell8 2.1.0.0
Main Page

Load Cell 8 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Stefan Ilic
  • Date : Dec 2023.
  • Type : I2C type

Software Support

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

Standard key functions :

Example key functions :

  • loadcell8_read_raw_adc This function reads raw ADC value by using I2C serial interface.
    err_t loadcell8_read_raw_adc ( loadcell8_t *ctx, uint32_t *raw_adc );
    err_t loadcell8_read_raw_adc(loadcell8_t *ctx, uint32_t *raw_adc)
    Load Cell 8 read raw ADC value function.
  • loadcell8_tare_scale This function calculates the cell_data which is the raw ADC readings of the empty container by using I2C serial interface.
    err_t loadcell8_tare_scale(loadcell8_t *ctx, loadcell8_data_t *cell_data)
    Load Cell 8 read raw ADC value function.
    Load Cell 8 Click data object.
    Definition: loadcell8.h:159
  • loadcell8_calibration_weight This function calibrates the weight by calculating the cell_data for the input calibration weight by using I2C serial interface.
    err_t loadcell8_calibration_weight ( loadcell8_t *ctx, uint16_t cal_val, loadcell8_data_t *cell_data );
    err_t loadcell8_calibration_weight(loadcell8_t *ctx, uint16_t cal_val, loadcell8_data_t *cell_data)
    Load Cell 8 calibrate weight function.

Example Description

This example demonstrates the use of Load Cell 8 click by measuring the weight

in grams of the goods from the load cell sensor connected to the click board.

The demo application is composed of two sections :

Application Init

Initializes the driver and reads the tare scale of the empty container, and after

that, it calibrates the weight scale with a known calibration weight.

void application_init ( void )
{
log_cfg_t log_cfg;
loadcell8_cfg_t loadcell8_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
loadcell8_cfg_setup( &loadcell8_cfg );
LOADCELL8_MAP_MIKROBUS( loadcell8_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == loadcell8_init( &loadcell8, &loadcell8_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( LOADCELL8_ERROR == loadcell8_default_cfg ( &loadcell8 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_printf( &logger, " Remove all goods from the scale in the following 5 sec.\r\n" );
Delay_ms( 5000 );
log_printf( &logger, " Calculating tare scale...\r\n" );
if ( LOADCELL8_OK == loadcell8_tare_scale( &loadcell8, &cell_data ) )
{
log_printf( &logger, " Tarring complete!\r\n\n" );
}
else
{
log_error( &logger, " Calculating tare scale." );
for ( ; ; );
}
log_printf( &logger, " Place a %ug calibration weight on the scale in the following 5 sec.\r\n",
( uint16_t ) LOADCELL8_WEIGHT_100G );
Delay_ms( 5000 );
log_printf( &logger, " Calibrating weight...\r\n" );
if ( LOADCELL8_OK == loadcell8_calibration_weight( &loadcell8, LOADCELL8_WEIGHT_100G, &cell_data ) )
{
log_printf( &logger, " Calibration complete!\r\n\n" );
}
else
{
log_error( &logger, " Calibrating weight." );
for ( ; ; );
}
log_printf( &logger, " ___________________\r\n" );
log_printf( &logger, " Start measurements:\r\n" );
log_printf( &logger, " ___________________\r\n" );
Delay_ms( 500 );
}
#define LOADCELL8_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: loadcell8.h:108
#define LOADCELL8_WEIGHT_100G
Definition: loadcell8.h:76
@ LOADCELL8_ERROR
Definition: loadcell8.h:182
@ LOADCELL8_OK
Definition: loadcell8.h:181
void application_init(void)
Definition: main.c:32

Application Task

The demo application measures weight and shows the measurement of scales in grams [ g ].

Results are being sent to the Usart Terminal where you can track their changes.

void application_task ( void )
{
float weight_g = 0;
if ( LOADCELL8_OK == loadcell8_get_weight( &loadcell8, &cell_data, &weight_g ) )
{
log_printf( &logger, " Weight : %.2f g \r\n", weight_g );
}
Delay_ms( 100 );
}
err_t loadcell8_get_weight(loadcell8_t *ctx, loadcell8_data_t *cell_data, float *weight_g)
Load Cell 8 get weight function.
void application_task(void)
Definition: main.c:100

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

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.