compass8  2.1.0.0
Main Page

Compass 8 click

Compass 8 Click is a compact add-on board designed for precise compass applications. This board features the AK09919, a 3-axis electronic compass IC from AKM Semiconductor. The AK09919 is based on high-sensitivity Hall sensor technology for detecting terrestrial magnetism across the X, Y, and Z axes, has multiple operational modes, a built-in oscillator, and a Power On Reset circuit. It also includes a magnetic sensor overflow monitor and a 16-sample FIFO data buffer for efficient data handling.

click Product page


Click library

  • Author : Nenad Filipovic
  • Date : Feb 2024.
  • Type : I2C type

Software Support

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

Standard key functions :

Example key functions :

Example Description

This library contains API for the Compass 8 Click driver. The library initializes and defines the I2C drivers to write and read data from registers, as well as the default configuration for reading measurement data.

The demo application is composed of two sections :

Application Init

The initialization of the I2C module, log UART, and additional pins. After the driver init, the app executes a default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
compass8_cfg_t compass8_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
compass8_cfg_setup( &compass8_cfg );
COMPASS8_MAP_MIKROBUS( compass8_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == compass8_init( &compass8, &compass8_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( COMPASS8_ERROR == compass8_default_cfg ( &compass8 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

This example demonstrates the use of the Compass 8 Click board. Measures and displays magnetic flux density in microtesla (uT) for X-axis, Y-axis, and Z-axis. Results are being sent to the UART Terminal, where you can track their changes.

void application_task ( void )
{
if ( COMPASS8_OK == compass8_get_magnetic_data( &compass8, &axis ) )
{
log_printf( &logger, " X-axis: %.2f uT\r\n", axis.x );
log_printf( &logger, " Y-axis: %.2f uT\r\n", axis.y );
log_printf( &logger, " Z-axis: %.2f uT\r\n", axis.z );
log_printf( &logger, "--------------------\r\n" );
Delay_ms ( 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.Compass8

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.


compass8_sw_reset
err_t compass8_sw_reset(compass8_t *ctx)
Compass 8 soft reset function.
compass8_cfg_t
Compass 8 Click configuration object.
Definition: compass8.h:218
compass8_set_operation_mode
err_t compass8_set_operation_mode(compass8_t *ctx, uint8_t op_mode)
Compass 8 set operation mode function.
COMPASS8_ERROR
@ COMPASS8_ERROR
Definition: compass8.h:248
application_task
void application_task(void)
Definition: main.c:69
compass8_axes_t::x
float x
Definition: compass8.h:235
compass8_get_magnetic_data
err_t compass8_get_magnetic_data(compass8_t *ctx, compass8_axes_t *axis)
Compass 8 get magnetic data function.
compass8_axes_t::z
float z
Definition: compass8.h:237
compass8_axes_t
Compass 8 Click axes magnetic flux density data.
Definition: compass8.h:234
compass8_cfg_setup
void compass8_cfg_setup(compass8_cfg_t *cfg)
Compass 8 configuration object setup function.
COMPASS8_MAP_MIKROBUS
#define COMPASS8_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: compass8.h:188
compass8_t
Compass 8 Click context object.
Definition: compass8.h:201
application_init
void application_init(void)
Definition: main.c:33
compass8_init
err_t compass8_init(compass8_t *ctx, compass8_cfg_t *cfg)
Compass 8 initialization function.
COMPASS8_OK
@ COMPASS8_OK
Definition: compass8.h:247
compass8_axes_t::y
float y
Definition: compass8.h:236
compass8_default_cfg
err_t compass8_default_cfg(compass8_t *ctx)
Compass 8 default configuration function.