Mikroe 1577 that uses MPU6000

I'm getting confused with MPU IMU click. It is a Mikroe 1577 that uses MPU6000. How do I code it so that it measures acceleration and orientation. This is the description. Can anybody help me code it?

MPU IMU click carries the MPU-6000 integrated6-axis motion tracking device that combines a3-axis gyroscope, a 3-axis accelerometer, and aDMP (Digital Motion Processor) into a singlesmall chip.• IC/module: MPU-6000• Interface: SPI, I2C, RST and INT • Power supply: 3.3V • Supports 3D MotionProcessing • Gesture recognition

what is confusing you, exactly?

You mean this:

You can download the schematic from there:

From that you can see that the Click board is just a breakout board - it has no special magic or intelligence.

Therefore you code it exactly the same as you would code an MPU-6000 on any other breakout board - or even a bare chip wired on your own board.

To find Arduino examples, put "Arduino MPU6000" into your favourite internet search engine; eg,

Arduino MPU6000 - Google Search

The code for me does not work. Well it sort of does. It displays the same numbers over and over.
Numbers 2
As shown in the image, the numbers keep repeating itself. It seems like it took the measure at 1 point and is just printing the same numbers over and over. Even after moving it, it will still show the same numbers.
Is there a code that can help with this?
MPU IMU click carries the MPU-6000 integrated6-axis motion tracking device that combines a3-axis gyroscope, a 3-axis accelerometer, and aDMP (Digital Motion Processor) into a singlesmall chip.• IC/module: MPU-6000• Interface: SPI, I2C, RST and INT • Power supply: 3.3V • Supports 3D MotionProcessing • Gesture recognition
Im using Arduino UNO board and it is being directly connected to it without a breadboard because it is not needed. May you please assist me?

What code? You need to post it for anyone to be able to comment on it!

This will help: "How to get the best out of this forum " - in particular, " Posting code and common code problems"

R4, or R3 (or earlier)? They are very different!

Please also post your schematic, and some good, clear photos of your setup.

See: " Schematics or circuit diagrams" in the above post.

You've marked this as 'Solved' - but it seems that is not the case? :thinking:

Oh, shoot my bad. I also did not know the R3 is different from R4.
My Arduino board is the Arduino UNO R3


This is the code below

#include<Wire.h>
#define Addr 0x68

void setup()
{
  Wire.begin();
  Serial.begin(9600);

  Wire.beginTransmission(Addr);
  Wire.write(0x1B);
  Wire.write(0x18);
  Wire.endTransmission();

  Wire.beginTransmission(Addr);
  Wire.write(0x1C);
  Wire.write(0x18);
  Wire.endTransmission();

  Wire.beginTransmission(Addr);
  Wire.write(0x6B);
  Wire.write(0x01);
  Wire.endTransmission();
}

void loop()
{
  byte data[6];

  Wire.beginTransmission(Addr);
  Wire.write(0x3B);
  Wire.endTransmission();

  Wire.requestFrom(Addr, 6);
  data[0] = Wire.read();
  data[1] = Wire.read();
  data[2] = Wire.read();
  data[3] = Wire.read();
  data[4] = Wire.read();
  data[5] = Wire.read();

  // Convert the data
  int xAccl = data[0] * 256 + data[1];
  int yAccl = data[2] * 256 + data[3];
  int zAccl = data[4] * 256 + data[5];

  Wire.beginTransmission(Addr);
  Wire.write(0x43);
  Wire.endTransmission();

  // Request 6 bytes of data
  Wire.requestFrom(Addr, 6);
  data[0] = Wire.read();
  data[1] = Wire.read();
  data[2] = Wire.read();
  data[3] = Wire.read();
  data[4] = Wire.read();
  data[5] = Wire.read();

  // Convert the data
  int xGyro = data[0] * 256 + data[1];
  int yGyro = data[2] * 256 + data[3];
  int zGyro = data[4] * 256 + data[5];

  // Output data to serial monitor
  Serial.print("Acceleration in X-Axis : ");
  Serial.println(xAccl);

  Serial.print("Acceleration in Y-Axis : ");
  Serial.println(yAccl);

  Serial.print("Acceleration in Z-Axis : ");
  Serial.println(zAccl);

  Serial.print("X-Axis of Rotation : ");
  Serial.println(xGyro);

  Serial.print("Y-Axis of Rotation : ");
  Serial.println(yGyro);

  Serial.print("Z-Axis of Rotation : ");
  Serial.println(zGyro);
  Serial.print("=================================================");
  Serial.println();

  delay(1000);
}

Hi,
Are you Cross Posting?
https://forum.arduino.cc/t/programming-question/1177477/1

Tom.. :grinning: :+1: :coffee: :australia:

1 Like
#include<Wire.h> 

// MPU-6000 I2C address is 0x68(104)

#define Addr 0x68

void setup()

{  

// Initialise I2C communication as Master 

Wire.begin();  

// Initialise serial communication, set baud rate = 9600  

Serial.begin(9600);    

// Start I2C transmission  

Wire.beginTransmission(Addr);  

// Select gyroscope configuration register  

Wire.write(0x1B);  

// Full scale range = 2000 dps  

Wire.write(0x18);  

// Stop I2C transmission  

Wire.endTransmission();    

// Start I2C transmission  

Wire.beginTransmission(Addr);  

// Select accelerometer configuration register  

Wire.write(0x1C);  

// Full scale range = +/-16g  

Wire.write(0x18);  

// Stop I2C transmission  

Wire.endTransmission();    

// Start I2C transmission  

Wire.beginTransmission(Addr);  

// Select power management register  

Wire.write(0x6B);  

// PLL with xGyro reference  

Wire.write(0x01);  

// Stop I2C transmission  

Wire.endTransmission();  

delay(300);

}
void loop()

{  

unsigned int data[6];

// Start I2C transmission  

Wire.beginTransmission(Addr);  

// Select data register  

Wire.write(0x3B);  

// Stop I2C transmission  

Wire.endTransmission();    

// Request 6 bytes of data  

Wire.requestFrom(Addr, 6);    

// Read 6 byte of data   

if(Wire.available() == 6)  

{    

data[0] = Wire.read();    

data[1] = Wire.read();    

data[2] = Wire.read();    

data[3] = Wire.read();    

data[4] = Wire.read();    

data[5] = Wire.read();   

}    

// Convert the data  

int xAccl = data[0] * 256 + data[1];  

int yAccl = data[2] * 256 + data[3];  

int zAccl = data[4] * 256 + data[5];

// Start I2C transmission  

Wire.beginTransmission(Addr);  

// Select data register   

Wire.write(0x43);  

// Stop I2C transmission  

Wire.endTransmission();    

// Request 6 bytes of data  

Wire.requestFrom(Addr, 6);    

// Read 6 byte of data   

if(Wire.available() == 6) 

{    

data[0] = Wire.read();    

data[1] = Wire.read();    

data[2] = Wire.read();    

data[3] = Wire.read();    

data[4] = Wire.read();    

data[5] = Wire.read();   

}  

// Convert the data  

int xGyro = data[0] * 256 + data[1];  

int yGyro = data[2] * 256 + data[3];  

int zGyro = data[4] * 256 + data[5];

// Output data to serial monitor  

Serial.print("Acceleration in X-Axis : ");  

Serial.println(xAccl);  

Serial.print("Acceleration in Y-Axis : ");  

Serial.println(yAccl);  

Serial.print("Acceleration in Z-Axis : ");  

Serial.println(zAccl);  

Serial.print("X-Axis of Rotation : ");  

Serial.println(xGyro);  

Serial.print("Y-Axis of Rotation : ");  

Serial.println(yGyro);  

Serial.print("Z-Axis of Rotation : ");  

Serial.println(zGyro);  

delay(500);

}

This code is being used for the Mikroe 1577. I want to continuously display data but with this code it only displays code once. May anybody help me solve this issue?
Also my wiring is directly connected to the Arduino board. The ground to ground, 3.3V to 3.3V, SDA to A4, SCL to A5. May you tell me if my wiring is wrong,
or it is missing something? Thank you.

Try the following sketch whch is a formatted version of your sketch of post #1:

#include<Wire.h>
#define Addr 0x68

void setup()
{
  Wire.begin();
  Serial.begin(9600);

  Wire.beginTransmission(Addr);
  Wire.write(0x1B);
  Wire.write(0x18);
  Wire.endTransmission();

  Wire.beginTransmission(Addr);
  Wire.write(0x1C);
  Wire.write(0x18);
  Wire.endTransmission();

  Wire.beginTransmission(Addr);
  Wire.write(0x6B);
  Wire.write(0x01);
  Wire.endTransmission();
}

void loop()
{
  byte data[6];

  Wire.beginTransmission(Addr);
  Wire.write(0x3B);
  Wire.endTransmission();

  Wire.requestFrom(Addr, 6);
  data[0] = Wire.read();
  data[1] = Wire.read();
  data[2] = Wire.read();
  data[3] = Wire.read();
  data[4] = Wire.read();
  data[5] = Wire.read();

  // Convert the data
  int xAccl = data[0] * 256 + data[1];
  int yAccl = data[2] * 256 + data[3];
  int zAccl = data[4] * 256 + data[5];

  Wire.beginTransmission(Addr);
  Wire.write(0x43);
  Wire.endTransmission();

  // Request 6 bytes of data
  Wire.requestFrom(Addr, 6);
  data[0] = Wire.read();
  data[1] = Wire.read();
  data[2] = Wire.read();
  data[3] = Wire.read();
  data[4] = Wire.read();
  data[5] = Wire.read();

  // Convert the data
  int xGyro = data[0] * 256 + data[1];
  int yGyro = data[2] * 256 + data[3];
  int zGyro = data[4] * 256 + data[5];

  // Output data to serial monitor
  Serial.print("Acceleration in X-Axis : ");
  Serial.println(xAccl);

  Serial.print("Acceleration in Y-Axis : ");
  Serial.println(yAccl);

  Serial.print("Acceleration in Z-Axis : ");
  Serial.println(zAccl);

  Serial.print("X-Axis of Rotation : ");
  Serial.println(xGyro);

  Serial.print("Y-Axis of Rotation : ");
  Serial.println(yGyro);

  Serial.print("Z-Axis of Rotation : ");
  Serial.println(zGyro);
  Serial.print("=================================================");
  Serial.println();

  delay(1000);
}

Numbers
It still shows the same numbers over and over again. The numbers also seem to be larger.

1. Your original problem was as quoted above -- is that solved?

2. Now, you are reporting the problem that your program is not updating the sensor value?
Read data sheets and check if the sensor needs "Start Command"? If yes, then issue "Start Command" and wait until acquisition/conversion is complete and then read data from the sensor.

3. What is the type number of your sensor?

Sorry for not being clear. The code you formatted is displaying the same data over and over. So, no the problem is not yet solved
The type number of the sensor is Mikroe 1577. MPU IMU click carries the MPU-6000 integrated6-axis motion tracking device that combines a3-axis gyroscope, a 3-axis accelerometer, and aDMP (Digital Motion Processor) into a singlesmall chip.• IC/module: MPU-6000• Interface: SPI, I2C, RST and INT • Power supply: 3.3V • Supports 3D MotionProcessing • Gesture recognition MPU IMU click - Board with MPU-6000 integrated 6-axis motion tracking device

If you are using Arduino UNO, then use level shifter (Fig-1) to connect the sensor as the sensor is a 3.3V device and the UNO is a 5V device. The levl shifter is needed for safe operation and logic level matching.
i2c3V3UNO
Figure-1:

1 Like

I see a UNO in the background, that is 5V logic level.

The Mikroe board looks like its designed for 3.3V logic systems.

1 Like

Oh I see. Still, I think the code I have is not working as intended.
Numbers 2
As shown in the image, the numbers keep repeating. The data seems to be taken at one point then it kept repeating itself even when I was moving the sensor. Also, I think the numbers are way too high. So, I was wondering if anybody may help in this coding? I need it to measure acceleration and orientation.

There is an internal temperature sensor within the IMU (MPU-6000) of your Breakout Board. Preapre a simple sketch to acquire temperature signal just to veryfy that your is correct and the sensor is apparently functional.

Upload the following sketch and check if it works. This is a sketch that I made long time ago for my MPU-6050 IMU which is dead now.

#include<Wire.h>
#define MPUaddr 0x68

void setup()
{
  Serial.begin(9600);
  Wire.begin();
  Wire.beginTransmission(MPUaddr);
  byte busStatus = Wire.endTransmission();
  if (busStatus != 0)
  {
    Serial.print("MPU is not found!");
    while (true); //wait for ever
  }
  Serial.println("MPU is found");
}

void loop()
{
  Wire.beginTransmission(MPUaddr);     //Start communication with the MPU
  Wire.write(0x6B);               //We want to write to the PWR_MGMT_1 register (6B hex).
  Wire.write(0x00);   //
  Wire.endTransmission();

  //----pointing temp sensor-----------------
  Wire.beginTransmission(MPUaddr);  //Start communication with the MPU
  Wire.write(0x41);      //pointing Temp_Out_High Reg                                           //Set the register bits as 00000000 to activate the gyro.
  Wire.endTransmission();

  Wire.requestFrom(MPUaddr, 2); //two-byte temp data 
  byte x1 = Wire.read();
  byte x2 = Wire.read();
  int x = (int)(x1 << 8) | (int)x2;

  //------compute temp from x-----
  float mpuTemp = (float)(x / 340.0 + 36.53); //formula from data sheets
  Serial.print("Temp = ");
  Serial.print(mpuTemp, 2);  //2-digit after decimal point
  Serial.println(" degC");
  delay(1000);
}

Well, it can upload. Is it supposed to say MPU not found?

There are two messages in the sketch of post #9 -- which one you expect?

 if (busStatus != 0)
  {
    Serial.print("MPU is not found!");
    while (true); //wait for ever
  }
  Serial.println("MPU is found");
1 Like

The value 4294967295 is exactly the maximum value of an unsigned variable of type 4 bytes as a unsigned long. I think this suggests some kind of variable type problem.

2 Likes

I have merged your cross-posts @timgeo.

Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting can result in a suspension from the forum.

In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

1 Like

Ah, I'm sorry. I was getting desperate for a final year project. Won't repeat it again.

1 Like