Problem with getting analog readings from Pololu MinIMU-9 v5 module

Hi everyone!
I’m working on project, that needs to be oriented in space. So, I have decided to use module with acceloremeter, gyro, and barometer.
Everything works fine with accelerometer/gyro X and Y axis, but I have same problems with Z axis.
Readings are different from that what I expected.

Here is code I used:

#include <Wire.h>
#include <LSM6.h>

LSM6 imu;

char report[80];

void setup()
{
  Serial.begin(9600);
  
  Wire.begin();
  imu.init();
  imu.enableDefault();
}

void loop()
{
  imu.read();
  snprintf(report, sizeof(report), "A: %6d %6d %6d    G: %6d %6d %6d",
    imu.a.x, imu.a.y, imu.a.z,
    imu.g.x, imu.g.y, imu.g.z);
  Serial.println(report);
  delay(100);
}

Here are connections:

SCL - SCL

SDA - SDA

GND - GND

VIN - 5V

And here is video with readings that I get:

I’m using Arduino Leonardo. The problem must be related to code.
If you get here, I’m really thankful, because I know my English is tough to understand. :slight_smile:
Thanks in advance! :slight_smile:

Share the link of Arduino Library for Pololu MinIMU-9, which you are using. I have never seen LSM6.h before.

Here it is:

I must admit, that I have also Pololu AltIMU-10 v5 module, and I'm receving same readings alike, so module cannot be damaged.
Maybe Z axis doesn't work, like I think it should? In my thoughts, it should work in way, like it is on this photo.

If my imagination about this is wrong, please, explain it to me how it should work.

Thanks for your reply! :slight_smile:

Readings are different from that what I expected.

What are your expectations, and what are the readings?

If the Z axis is pointing up or down, it should be measuring the acceleration due to the Earth's gravity along Z.

jremington:
What are your expectations, and what are the readings?

If the Z axis is pointing up or down, it should be measuring the acceleration due to the Earth's gravity along Z.

Yeah, that were my expectations, but when I rotate it around Z-axis (at least Z-axis as photo above describes it)
readings aren't changing. Moreover, when I rotate it around X-axis, readings from Z-axis are changing the most.

Thanks for your reply! :slight_smile:

Moreover, when I rotate it around X-axis, readings from Z-axis are changing the most.

That is what I would expect, so I don’t see the problem.

Is it simply too difficult for you to post the actual readings?

jremington:
That is what I would expect, so I don’t see the problem.

Is it simply too difficult for you to post the actual readings?

I don’t know what you mean by saying actual, but I posted video with readings.
I made another one, where readings are more clear.

Here is code:

#include <Wire.h>
#include <LSM6.h>


LSM6 imu;

int axisx, axisy, axisz;
char report[80];

void setup()
{
  Serial.begin(9600);
  
  Wire.begin();
  imu.init();
  imu.enableDefault();
}

void loop()
{
  imu.read();
  snprintf(report, sizeof(report), "A: %6d %6d %6d    G: %6d %6d %6d",
    imu.a.x, imu.a.y, imu.a.z,
    imu.g.x, imu.g.y, imu.g.z);
 
  axisx = map(imu.a.x, -16000, 16000, 0, 180);
  axisy = map(imu.a.y, -16000, 16000, 0, 180);
  axisz = map(imu.a.z, -16000, 16000, 0, 180);
  Serial.print("Axis x: ");
  Serial.println(axisx);
  Serial.print("Axis y: ");
  Serial.println(axisy);
  Serial.print("Axis z: ");
  Serial.println(axisz);
  Serial.println("-------");
  delay(500);
}

And here is video:

Last axis is important for me. Is there any option to get readings, that would change according to the motion I made?

Bump