Skip to main content
Visitor
July 26, 2026
Solved

The LSM303AGR magnetometer fails to initialize

  • July 26, 2026
  • 2 replies
  • 80 views

The magnetometer doesn’t start over I2C and doesn’t output data via UART. Please help solve the problem; the files are attached.

Best answer by Dor_RH

Hello ​@Profanity,

I recommend referring to the LSM303AGR integration available in STM32CubeF4: Link (here)

2 replies

Dor_RHBest answer
ST Employee
July 27, 2026

Hello ​@Profanity,

I recommend referring to the LSM303AGR integration available in STM32CubeF4: Link (here)

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Dor_RH
Andrew Neil
Super User
July 27, 2026

As ​@Dor_RH said, have you tried ST’s provided example?

What hardware are you using?

 

The magnetometer doesn’t start over I2C

Have you checked hardware connections?

Correct pullups?

Correct slave address, and correctly presented in the software?

Have you used an oscilloscope and/or logic analyser to see what’s actually happening on the bus?

 

doesn’t output data via UART

The LSM303AGR doesn’t have a UART.

 

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.