HMC5883L on auxilary I2C of MPU6050 using STM32f103xx board

It has been almost one month and I’m back to write some progress made on my ARM STM32 based AHRS development. I was actually working on my board design in Eagle , BOM.
After the PCB designs have been sent to FAB house here in Korea, I’m back to programming the prototype board. I could communicate with HMC5883L which is connected to Auxiliary I2C bus of MPU6050.
There are two modes( I2C master mode, Pass-Through mode) to access I2C device connected to auxiliary I2C bus of MPU6050. If we want to configure the HMC5883L, we must use Pass-Through mode. It can be done by enabling interface bypass multiplexer. In this mode system processor I2C bus pins 23 and 24 (SDA and SCL) directly connected to the auxiliary sensor I2C bus pins 6 and 7 (AUX_DA and AUX_CL). Once the auxiliary sensors have been configured by the system processor, the interface bypass multiplexer should be disabled so that the MPU-6050 auxiliary I2C master can take control of the sensor I2C bus and gather data from the auxiliary sensors.
At present, I’m only collecting HMC5833L data through Pass-Through mode. If we want to collect Quaternion computed by DMP of MPU6050 ( which includes HMC5883L data for fusion), we must switch to I2C master mode. Here is the picture of raw data(Acceleration, Gyroscope, Magnetometer) streaming to computer through Virtual COM port.


At present basic streaming is reliable( tested for 2 hours, 100KHz I2C Speed in 50Hz, 100Hz, 150Hz, 200Hz Timer interrupt mode). HMC5883L data rate is set at 75Hz.  However it is not working when timer is set for 400Hz interrupts. I have to further investigate this . Sometime this week i will update GitHub I2C libraries repo &  Doxygen documentation for the MPU6050 & HMC5883L on STM32F103xx Platform. You can find the libraries along with documentation in compressed html (.chm) format at my GitHub repository:
These libraries are still in development stage. If you find any bugs or want to improve or have any suggestions, you are always welcome.

2 Responses to “HMC5883L on auxilary I2C of MPU6050 using STM32f103xx board”

  1. Marek Macner Says:

    I’ve just tested your code on STM32F103VC6 + MPU6050/ 100 Hz with data logging on SD card conneced via SDIO – works perfect and smooth for few hours. All work on FreeRTOS and some data also displaed on LCD connected via FSMC.
    Next steps: GPS interface via UART with interrupts and DMA (first 5/10Hz, then planned 100 Hz with Novatel OEM628 module + implementation of RTKLib for precise positioning), and HMC5883 – or new MPU9050.
    Whole system is planned to use as measurement and logger for automobile tests in our Tech University in Bielsko-Biala, Poland.

    Best regards and wish you success in work,


  2. Hari Says:

    In response to Joel “I do have a question that i hope you could help me to answer. The auxiliary i2c of the MPU, does it need to have pullup resistors? i noticed in your schemtics you put “DNP”, what does this mean?”

    No need of pullup resisters for connecting HMC5883L on auxilary bus of MPU6050.
    DNP means Do Not Populate ( In schematics you will draw the pullups, but if you specify DNP to PCB assembly, they do not solder those components on to board).

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 39 other followers

%d bloggers like this: