TOP Contributors

  1. MIKROE (2663 codes)
  2. Alcides Ramos (358 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (137082 times)
  2. FAT32 Library (70223 times)
  3. Network Ethernet Library (56095 times)
  4. USB Device Library (46418 times)
  5. Network WiFi Library (42034 times)
  6. FT800 Library (41378 times)
  7. GSM click (29109 times)
  8. mikroSDK (26558 times)
  9. PID Library (26487 times)
  10. microSD click (25486 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

Compass 6 click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-03

Package Version: 2.1.0.8

mikroSDK Library: 2.0.0.0

Category: Magnetic

Downloaded: 131 times

Not followed.

License: MIT license  

Compass 6 Click is a compact add-on board perfect for implementation in applications such as an electronic compass. This board features the HSCDTD008A, a high-sensitivity geomagnetic sensor from ALPS Alpine.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Compass 6 click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Compass 6 click" changes.

Do you want to report abuse regarding "Compass 6 click".

  • Information
  • Comments (0)

mikroSDK Library Blog


Compass 6 click

Compass 6 Click is a compact add-on board perfect for implementation in applications such as an electronic compass. This board features the HSCDTD008A, a high-sensitivity geomagnetic sensor from ALPS Alpine.

compass_6_click.png

click Product page


Click library

  • Author : Luka Filipovic
  • Date : Aug 2021.
  • Type : I2C type

Software Support

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

Standard key functions :

  • compass6_cfg_setup Config Object Initialization function.

    void compass6_cfg_setup ( compass6_cfg_t *cfg );
  • compass6_init Initialization function.

    err_t compass6_init ( compass6_t *ctx, compass6_cfg_t *cfg );
  • compass6_default_cfg Click Default Configuration function.

    err_t compass6_default_cfg ( compass6_t *ctx );

Example key functions :

  • compass6_get_axes_data Magnetic axes data reading.

    err_t compass6_get_axes_data ( compass6_t *ctx, compass6_axes_t *axes_data );
  • compass6_data_ready Get data ready pin state.

    uint8_t compass6_data_ready ( compass6_t *ctx );
  • compass6_generic_read Reading function.

    err_t compass6_generic_read ( compass6_t *ctx, uint8_t reg, uint8_t *rx_data );

Example Description

This example is a showcase the ability of the device to read 3 axis data of magnetic raw value when data is ready.

The demo application is composed of two sections :

Application Init

Initialization of communication modules (I2C, UART) and data ready pin as input. Then reads identification data and checks if some of them have wrong value, and configures device for reading.


void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    compass6_cfg_t compass6_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    compass6_cfg_setup( &compass6_cfg );
    COMPASS6_MAP_MIKROBUS( compass6_cfg, MIKROBUS_1 );
    err_t init_flag = compass6_init( &compass6, &compass6_cfg );
    if ( I2C_MASTER_ERROR == init_flag ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }

    uint8_t temp_data = 0;
    compass6_generic_read( &compass6, COMPASS6_REG_WHO_I_AM, &temp_data );
    log_printf( &logger, " > Who am I: 0x%.2X\r\n", ( uint16_t )temp_data );
    if ( COMPASS6_WHO_AM_I != temp_data )
    {
        log_error( &logger, " Who am I. " );
    }

    compass6_generic_read( &compass6, COMPASS6_REG_INFO_VERSION, &temp_data );
    log_printf( &logger, " > Version: 0x%.2X\r\n", ( uint16_t )temp_data );
    if ( COMPASS6_VERSION != temp_data )
    {
        log_error( &logger, " Version. " );
    }

    compass6_generic_read( &compass6, COMPASS6_REG_INFO_ALPS, &temp_data );
    log_printf( &logger, " > ALPS: 0x%.2X\r\n", ( uint16_t )temp_data );
    if ( COMPASS6_ALPS != temp_data )
    {
        log_error( &logger, " ALPS. " );
    }

    compass6_default_cfg ( &compass6 );

    log_info( &logger, " Application Task " );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
}

Application Task

Checks Data ready pin and if asserted high it will read data of all 3 axes(x, y, z) and log data to Terminal.


void application_task ( void ) 
{
    if ( compass6_data_ready( &compass6 ) )
    {      
        compass6_axes_t axes_data;
        compass6_get_axes_data( &compass6, &axes_data );
        log_printf( &logger, " > X: %d\r\n", axes_data.x );
        log_printf( &logger, " > Y: %d\r\n", axes_data.y );
        log_printf( &logger, " > Z: %d\r\n", axes_data.z );
        log_printf( &logger, "*********************\r\n" );
    }
}

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

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.


ALSO FROM THIS AUTHOR

Tamper click

5

Tamper click is equipped with SDS001, a low profile side-actuated detect switch, made by C&K company. The click is additionally equipped with the RC filter that minimizes the bouncing effect, making this click a reliable solution for any contact detection application.

[Learn More]

ADC 8 click

5

ADC 8 Click is a high precision, low-power, 16-bit analog-to-digital converter (ADC), based around the ADS1115 IC. It is capable of sampling signals on four single-ended or two differential input channels.

[Learn More]

I2C Isolator 6 click

0

I2C Isolator 6 Click is a compact add-on board that offers completely isolated bidirectional communication. This board features the ADUM2250, a two-channel, 5kVRMS I2C digital isolator from Analog Devices. The ADUM2250 provides two bidirectional channels, supporting a completely isolated I2C interface that eliminates the need for splitting I2C signals into separate transmit and receive signals for use with standalone optocouplers. It supports data rates from DC up to 1MHz and has a hot swap circuitry to prevent data glitches.

[Learn More]