cancel
Showing results for 
Search instead for 
Did you mean: 

How to interface with HMC5883L?

M7890.1
Associate III

Hi. I want to use HMC5833L for my project but I couldn't find any library to be used as a reference. Can someone briefly explain what are the steps needed to read data from the sensor? I have a little piece of code below but it doesn't work.

HAL_I2C_Mem_Read(&hi2c1, GY271_ADDR, 0x10, 1, &check, 1, 1000);
if (check == 'H') {
	sprintf(data, "OK\r\n");
	HAL_UART_Transmit(&huart1, (uint8_t *) data, sizeof(data), 100);
	memset(data, '\0', sizeof(data));
}

 The value that I get for check is 8.

1 ACCEPTED SOLUTION

Accepted Solutions
Eleon BORLINI
ST Employee

Hi @M7890.1​ ,

please note that the HMC5883L magnetometer is a product from Honeywell, so I suggest you to ask for help on their support page.

For a C library, I suggest to check this repository on Github.

Or, if you have the GY-271 product, you might refer to this wiki page.

Check also the suggested hardware connections.

-Eleon

View solution in original post

1 REPLY 1
Eleon BORLINI
ST Employee

Hi @M7890.1​ ,

please note that the HMC5883L magnetometer is a product from Honeywell, so I suggest you to ask for help on their support page.

For a C library, I suggest to check this repository on Github.

Or, if you have the GY-271 product, you might refer to this wiki page.

Check also the suggested hardware connections.

-Eleon