magneto7 2.2.0
magneto7


Magneto 7 Click

Magneto 7 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : MikroE Team
  • Date : Dec 2019.
  • Type : I2C type

Software Support

Example Description

This demo application reads position of a magnet above the sensor.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Magneto7

Example Key Functions

Application Init

Initializes device.

void application_init ( void )
{
log_cfg_t log_cfg;
uint8_t init_status;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----\r\n" );
// Click initialization.
MAGNETO7_MAP_MIKROBUS( cfg, MIKROBUS_1 );
magneto7_init( &magneto7, &cfg );
Delay_ms ( 300 );
init_status = magneto7_default_cfg( &magneto7 );
if ( init_status == 0)
{
log_printf( &logger, "> app init done\r\n" );
}
else if ( init_status == 1 )
{
log_printf( &logger, "> app init fail\r\n" );
for ( ; ; );
}
}
#define MAGNETO7_MAP_MIKROBUS(cfg, mikrobus)
Definition magneto7.h:65
void application_init(void)
Definition main.c:32

Application Task

Waits for INT pin to go LOW, gets raw data, converts it to uT and logs results.

void application_task ( void )
{
uint8_t int_status;
float converted_data;
int16_t data_x;
int16_t data_y;
int16_t data_z;
int_status = magneto7_int_get( &magneto7 );
if ( int_status == 0 )
{
magneto7_get_data( &magneto7, &data_x, &data_y, &data_z );
converted_data = magneto7_convert_to_ut( &magneto7, data_x, MAGNETO7_SENSOR_RES_14_BIT );
log_printf( &logger, "> X Axis : %f [uT]\r\n", converted_data );
converted_data = magneto7_convert_to_ut( &magneto7, data_y, MAGNETO7_SENSOR_RES_14_BIT );
log_printf( &logger, "> Y Axis : %f [uT]\r\n", converted_data );
converted_data = magneto7_convert_to_ut( &magneto7, data_z, MAGNETO7_SENSOR_RES_14_BIT );
log_printf( &logger, "> Z Axis : %f [uT]\r\n", converted_data );
log_printf( &logger, "\r\n" );
Delay_ms ( 300 );
}
}
float magneto7_convert_to_ut(magneto7_t *ctx, int16_t raw_data, uint8_t sensor_resolution)
Getting fine data function.
void magneto7_get_data(magneto7_t *ctx, int16_t *x_axis, int16_t *y_axis, int16_t *z_axis)
Getting data function.
#define MAGNETO7_SENSOR_RES_14_BIT
Definition magneto7.h:145
void application_task(void)
Definition main.c:70

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.