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]
Rating:
Author: MIKROE
Last Updated: 2020-04-13
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Magnetic
Downloaded: 2534 times
Not followed.
License: MIT license
Compass 3 Click features MMC5883MA, a complete 3-axis magnetic sensor with on-chip signal processing and integrated I2C bus suitable for use in various applications.
Do you want to subscribe in order to receive notifications regarding "Compass 3 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Compass 3 click" changes.
Do you want to report abuse regarding "Compass 3 click".
Library Description
This library holds functions that can be used to read, write and measure magnetic field and temperature.
Key functions:
void compass3_write_byte ( uint8_t reg_adr, uint8_t data_in );
- Writes 8-bit data into register defined by 8-bit register address.void compass3_full_measurement ( float *x_val, float *y_val, float *z_val );
- Measures magnetic field surrounding the device.float compass3_read_temp ( );
- Function is used to measure temperature.Examples description
The application is composed of three sections :
void application_task ( )
{
if( compass3_check_int () == COMPASS3_INTERRUPT )
{
compass3_full_measurement ( &x_val, &y_val, &z_val );
FloatToStr( x_val, log_txt );
mikrobus_logWrite( " X-axis: ", _LOG_TEXT );
mikrobus_logWrite( log_txt, _LOG_TEXT );
mikrobus_logWrite( "mG", _LOG_LINE );
FloatToStr( y_val, log_txt );
mikrobus_logWrite( " Y-axis: ", _LOG_TEXT );
mikrobus_logWrite( log_txt, _LOG_TEXT );
mikrobus_logWrite( "mG", _LOG_LINE );
FloatToStr( z_val, log_txt );
mikrobus_logWrite( " Z-axis: ", _LOG_TEXT );
mikrobus_logWrite( log_txt, _LOG_TEXT );
mikrobus_logWrite( "mG", _LOG_LINE );
Delay_ms( 1000 );
mikrobus_logWrite( "--------------------", _LOG_LINE );
}
}
Other mikroE Libraries used in the example:
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. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.