Measuring angle between two IMUs (MPU 9250)

Hello everyone,

I’m fairly new to the community and Arduino itself. One of the projects that I picked up to work on is how to calculate the angle between two IMUs (I am using MPU 9250).

I am unable to figure out the coding part of this. I have tried multiple codes and haven’t had much success.

Can anyone help me out with a code to measure the angle between two MPUs?

I’m attaching the circuit diagram below for your convenience.

Thank you so much in advance. Hoping to learn a lot from this community.

Link to Circuit: How to wire SparkFun MPU-9250 - IMU Breakout, SparkFun MPU-9250 - IMU Breakout to Arduino Uno

I used circuit.io but if you guys have better suggestions on the circuit or circuit maker app, please do let me know.

Thanks again! :slight_smile:

First, define what you mean by the "angle between two IMUs".

In general, a rotation axis and an angle define the transformation that connects two arbitrary 3D orientations, but there are other ways, all involving more than one number to be determined.

You can use an AHRS program that defines the 3D orientation of each IMU with respect to the Earth. From the two quaternions, you can then calculate the transformation that connects them.

Show what you have tried and what the results are.
When you post code, USE CODE TAGS. (See the sticky: How to use this forum").

To get an angle between two IMU's, you need a reference common to both of them. But first, just get one IMU to show data on the console.

I have never heard of Circuit.io, and after looking at it, I would never use it. It is just too primitive

jremington:
First, define what you mean by the "angle between two IMUs".

In general, a rotation axis and an angle define the transformation that connects two arbitrary 3D orientations, but there are other ways, all involving more than one number to be determined.

You can use an AHRS program that defines the 3D orientation of each IMU with respect to the Earth. From the two quaternions, you can then calculate the transformation that connects them.

Apologies for not being clearer. So the way I am looking at it is, say we have one IMU as a reference placed on a stationary object and the other IMU is placed on a moving object. Now the angle calculated is for the moving IMU in reference to the stationary IMU.

I'm not sure if this makes sense but the main thing is I want one IMU's angle to be calculated with respect to the position of the other IMU.

Primarily, I am looking for an inclination angle.

SteveMann:
Show what you have tried and what the results are.
When you post code, USE CODE TAGS. (See the sticky: How to use this forum").

To get an angle between two IMU's, you need a reference common to both of them. But first, just get one IMU to show data on the console.

I have never heard of Circuit.io, and after looking at it, I would never use it. It is just too primitive

Sorry about that, I'll make sure to add in the CODE TAGS.

Here's the code that I tested and it worked fine:

So to your point, one IMU showing data on the console is done but what I am looking for is two IMUs setup.
You mentioned I need a reference common to both of them but can I just have one IMU as the reference and the other IMU calculating angle with respect to that?

I understand about the circuit.io. Can you please suggest some better alternatives?

Thanks

Sorry, that doesn't help. In general you need to know the 3D orientation of both sensors in order to work out the rotation that connects them. It is not a simple calculation, like subtracting two angles.

Good intro here https://yostlabs.com/wp/wp-content/uploads/pdf/Yost-Calculating-Angles-Between-Two-3-Space-Sensor-Devices-on-a-Human-Body.pdf

An "inclination angle" requires you to define an axis, usually horizontal or vertical.

Why not tell us what you are really trying to do?

get one working first. Measure Tilt Angle Using MPU6050 Gyro/Accelerometer & Arduino

Use the words "calculate angle using accelerometer" to search on to find a simple angle of tilt of the IMU.

Here’s the code that I tested and it worked fine:

Please use code tags to display (as text within your post) any code that you want to discuss.