1

I am trying to smoke test my Seeeduino XIAO (Arduino-compatible) board with an IMU sensor, the MPU 6050. I mainly care about the accelerometer and gyroscope values.

But when I run my Arduino code on the XIAO, I am only getting -1 values in the Serial Monitor. When I first smoke tested the MPU 6050, I actually saw regular X,Y,Z values (e.g. 123, -456, etc), but it disappeared after a few readings. Both the microcontroller and IMU chips are able to power on, since they both display the LED light. The XIAO seems to display a blue LED light when it is transmitting/receiving data, but I am not entirely sure that is what is going on.

The MPU 6050 communicates via I2C, so I have connected Vcc to 3.3V on the XIAO since I read somewhere that the MPU 6050 runs on 3.3V, Gnd to Gnd, SCL to Pin 5 on the XIAO, SDA to Pin 4, and the INT pin to Pin 2 (not sure if I need the INT pin or not, but I read that it helped clear the buffer I think). Then I have the XIAO connected to my laptop's 5V USB port. Also not sure if I need to connect to 3.3V or 5V from the MPU to the XIAO.

Any idea why I am getting -1 values? I also occasionally get 0 values, but mostly -1s. Here is a snippet of the output I am getting on the Serial Monitor:

12:06:32.476 -> AccX = 0 || AccY = 0 || AccZ = 0 || Temp = 36.53 || GyroX = 0 || GyroY = 0 || GyroZ = 0
12:06:32.578 -> AccX = 0 || AccY = 0 || AccZ = 0 || Temp = 36.53 || GyroX = 0 || GyroY = 0 || GyroZ = 0
12:06:32.681 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:33.057 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:33.159 -> AccX = 0 || AccY = 0 || AccZ = 0 || Temp = 36.53 || GyroX = 0 || GyroY = 0 || GyroZ = 0
12:06:33.465 -> AccX = 0 || AccY = 0 || AccZ = 0 || Temp = 36.53 || GyroX = 0 || GyroY = 0 || GyroZ = 0
12:06:33.566 -> AccX = 0 || AccY = 0 || AccZ = 0 || Temp = 36.53 || GyroX = 0 || GyroY = 0 || GyroZ = 0
12:06:33.738 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:33.841 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:34.014 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:34.390 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:34.492 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:34.596 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:34.699 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:34.903 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:36.378 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:36.480 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:36.584 -> AccX = 0 || AccY = 0 || AccZ = 0 || Temp = 36.53 || GyroX = 0 || GyroY = 0 || GyroZ = 0
12:06:37.064 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:37.710 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:38.122 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:38.257 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:38.393 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:38.529 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1
12:06:38.664 -> AccX = -1 || AccY = -1 || AccZ = -1 || Temp = 36.53 || GyroX = -1 || GyroY = -1 || GyroZ = -1

Here is the code I found on some tutorial website: https://www.electronicshub.org/getting-started-arduino-mpu6050/

#include<Wire.h>
const int MPU6050_addr=0x68;
int16_t AccX,AccY,AccZ,Temp,GyroX,GyroY,GyroZ;
void setup(){
  Wire.begin();
  Wire.beginTransmission(MPU6050_addr);
  Wire.write(0x6B);
  Wire.write(0);
  Wire.endTransmission(true);
  Serial.begin(9600);
}
void loop(){
  Wire.beginTransmission(MPU6050_addr);
  Wire.write(0x3B);
  Wire.endTransmission(false);
  Wire.requestFrom(MPU6050_addr,14,true);
  AccX=Wire.read()<<8|Wire.read();
  AccY=Wire.read()<<8|Wire.read();
  AccZ=Wire.read()<<8|Wire.read();
  Temp=Wire.read()<<8|Wire.read();
  GyroX=Wire.read()<<8|Wire.read();
  GyroY=Wire.read()<<8|Wire.read();
  GyroZ=Wire.read()<<8|Wire.read();
  Serial.print("AccX = "); Serial.print(AccX);
  Serial.print(" || AccY = "); Serial.print(AccY);
  Serial.print(" || AccZ = "); Serial.print(AccZ);
  Serial.print(" || Temp = "); Serial.print(Temp/340.00+36.53);
  Serial.print(" || GyroX = "); Serial.print(GyroX);
  Serial.print(" || GyroY = "); Serial.print(GyroY);
  Serial.print(" || GyroZ = "); Serial.println(GyroZ);
  delay(100);
}

Attached is my current electronics setup. Yes, I know I should have used a breadboard, but I did not have one on me at the time. The connection was not stable, so maybe that messed with the readings.

enter image description here

8
  • -1 is usually all 1's and 0 is all zeros. So it looks like you are not getting any data. The code appears to be set up for an I2C device at address 0x68. The 6050 can be set to appear at that address or at address 0x69. What is pin 9 of the 6050 chip connected to?
    – st2000
    Commented Nov 27, 2020 at 18:42
  • Oh ok. I ran i2c device scanning code that I found online and it said the address at 0x68 was available, along with the rest of that address space. The 6050 only has 8 pins.
    – rmutalik
    Commented Nov 27, 2020 at 18:48
  • I am not sure what "running i2c device scanning code" means. It sounds like the scan did not find anything at 0x68 and as such indicated that address was available. BTW, the 6050 chip has 24 pins. The board the 6050 chip is soldered onto has 8 pins. For more help, you need to let us know where you got that board from. As we need the board's schematic to do a good job at figuring this out.
    – st2000
    Commented Nov 27, 2020 at 19:00
  • Yes, the scan indicated that the address at 0x68 was available. Oh ok. Diymore 6DOF MPU-6050 GY-521. That's the name of the board.
    – rmutalik
    Commented Nov 27, 2020 at 19:11
  • A quick look around and I can not find the schematic. If you know where to find one please let us know. I did find this project which is what you are doing only they are using a real Arduino Uno board. I am now wondering if the XIAO is as compatible as needed for this project.
    – st2000
    Commented Nov 27, 2020 at 20:57

1 Answer 1

1

There may be a couple of issues to consider:

  1. In the 6050 specification we see that the 6050 can be configured to show up at address 0x68 or 0x69. In the photo there appears to be no connection to a pin (AD0?) which may control the 6050 address. The code appears to expect the 6050 at address 0x68. (Note: The board the 6050 comes on may already deal with this issue by including a pull up or pull down resistor.)

  2. An I2C bus normally needs pull up resistors on the data and clock lines as all drivers are normally of type open collector. Here is part of a figure from the 6850's specification document:

enter image description here

(Note: The board the 6050 comes on may already deal with this issue by including 2 pull up resistor.)

  1. Look for a working project which is the same or nearly the same as yours. Here is a project that uses the same 6050 board connected to an Arduino Uno.

  2. Consider if the libraries and other supporting software are truly abstracting your XIAO hardware (in this case an SAMD21CortexM0+ processor) (the real Arduino Uno uses a ATmega328P processor). It would not be the first time trying to emulate an Arduino using different and more powerful processors has affected otherwise working sketches with unexpected behaviors.

  3. Finally, there appears to be many schematics many with and a few without a 5 volt to 3.3 volt LDO regulators. It may be even with a Low Drop Out regulator that supplying the board with 3.3 volts will not result in 3.3 volts at the 6050 chip. This may lead to problems. But supplying a board with no regulator with 5 volts may damage the 6050 chip. Here is one of the schematics found:

enter image description here

(Note: In this schematic, the data and clock lines are pulled high on the board. And pin 9 (AD0) of the 6050 chip is pulled low.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.