cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F446 I2C connection, weird behaviour with MPU6050 and HMC5883L

Isoclem
Associate III

Hello everyone,

 

I'm trying to use MPU6050, HMC5883L and MS5611 all together in a project with an STM32F446RE. The problem is, while every components all work fine alone, when is use MPU6050 and HMC5883L together, it doesn't work. By not working, I'm meaning that the datas collected are all wrong. What's also weird is that : MPU6050 and MS5611 work fine together, same for HMC5883L and MS5611.

So let's focus on MPU6050 and HMC5883L only I guess...

 

For the connections I just did that :

board.drawio (1).png

So in my case, I connect the two sensors to the same SCL and SDA. Which should work, but I suspect that the problem might come from this connection. Indeed, even thought I'm assuming the right addresses are written in the code, could it be possible that troughout I2C, parts of the data are overwritten ? If so, what can I do ?

 

 

If you have any other ideas of where the problem could be, feel free to share it ^^

 

I attached all the code i use. 

Thanks for your help !

 

1 ACCEPTED SOLUTION

Accepted Solutions

The Green is the pull-up / level shifter, the Orange is the "5V/VIN" side 2K2's.

The Red is the 3V3 Regulator

1716400547181_markedup.jpg

I'd probably lose the orange resistors and the 6-pin IC, and then bridge the SCL/SDA at the pull-up to the respective pads on the ones removed.

gy_85_level.jpg

gy_85_level_modded.jpg

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

18 REPLIES 18
AScha.3
Chief

Hi,

just to understand: 

>MPU6050 and MS5611 work fine together, same for HMC5883L and MS5611.

>MPU6050 and HMC5883L together, it doesn't work.

You have them all 3 always on the I2C connected and just address / work only with 2 , 

or you physically remove the "other" 3rd from connection and program ?

If you feel a post has answered your question, please click "Accept as Solution".

Hi,

 

I physically remove the other 3rd connection and program.

Also while doing those pairs of sensor the connection is the same, I always connect on the same SDA and SCL.

 

That is why it is weird. I thought the problem was how I connected everything at first, but since MS5611 is working fine using only MPU with it and same while using only HMC with it, but MPU and HMC together is not working, it seems that this connection is the problem...

 

Besides, what Emma the AI, telling...

what happens, if MPU6050 and HMC5883L together on the bus , but you only address one of them ?

If you feel a post has answered your question, please click "Accept as Solution".

How wired?

Just chips? On modules with regulators and level shifters?

Combo module like GY-86  https://store.open-electronics.org/GY-86

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Isoclem
Associate III

"what happens, if MPU6050 and HMC5883L together on the bus , but you only address one of them ?"

 

The problem is still the same. 🤔 I tried addressing mpu6050 only and hmc5883l only with the other one still there physically... 

 

"How wired?

Just chips? On modules with regulators and level shifters?

Combo module like GY-86  https://store.open-electronics.org/GY-86"

 

This is not a combo module, the two sensors are apart, i'm going to show pics of my montage so you can have a better idea : (colors mean the same as the colors in the diagram I sent)

 

2.jpg1.jpg

 

Hope you can see everything fine.

 

I'm honestly even more confused now.. x)

 

 

 

So arguably circuit a lot more complex than diagrammed?

Link to module schematics? 

VCC is what here?

Pull up resistors on every board?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Yep,

You can find the datasheet here for mpu 6050: https://pdf1.alldatasheet.fr/datasheet-pdf/view/517744/ETC1/MPU-6050.html

and here for HMC5883L : https://www.farnell.com/datasheets/1683374.pdf

 

VCC is yellow, corresponding to 5V.

 

"Pull up resistors on every board ?" 

I don't have any, it might be the problem.... 

The thing is, it is said that mpu6050 and HMC5883L can work together without the need of pull up resistors.. ://

 

I'm going to get resistors tomorrow, and test this week, i'll keep you updated.

If you have any other ideas, feel free to share !

>I don't have any, it might be the problem.... 

🙂

If you set I2C clock to low speed, maybe 20kHz, the internal pullups could be ok for a test:

set port/pins SCL/SDA with pullup on. 

If you feel a post has answered your question, please click "Accept as Solution".

Ok, so now I do have better values, they are getting closer to the expected values for the magnetometer. I get for the MPU a sort of "flash" of data every 4 seconds with the correct values then it returns to incorrect values. But it's already much better, and it shows us that the problem must come from there !

 

Thanks for helping ! I'll keep you updated ! 🙂