mpu 9250 sparkfun library doesn't work

The Rocketry Forum

Help Support The Rocketry Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

Johann

Member
Joined
Feb 24, 2024
Messages
12
Reaction score
3
Location
germany
hello

I'm trying to use the Sparkfun library to manipulate the mpu9250 sensor on my flight controller, but I'm running into problems, because it doesn't work. Is there anyone who can help me?
 
hello

I'm trying to use the Sparkfun library to manipulate the mpu9250 sensor on my flight controller, but I'm running into problems, because it doesn't work. Is there anyone who can help me?
Specifically what doesn't work?
 
hear is the example of the library:

#include "quaternionFilters.h"
#include "MPU9250.h"
#define I2Cclock 400000
#define I2Cport Wire
#define MPU9250_ADDRESS MPU9250_ADDRESS_AD0 // Use either this line or the next to select which I2C address your device is using
//#define MPU9250_ADDRESS MPU9250_ADDRESS_AD1
MPU9250 myIMU0(MPU9250_ADDRESS_AD0, I2Cport, I2Cclock);
MPU9250 myIMU1(MPU9250_ADDRESS_AD1, I2Cport, I2Cclock);
byte c = 0x00;
byte d = 0x00;
bool ledOn = true;
void setup() {
// put your setup code here, to run once:
Serial.begin(38400);
while(!Serial){};
pinMode(13, OUTPUT);

}
void loop() {
// put your main code here, to run repeatedly:
c = myIMU0.readByte(MPU9250_ADDRESS_AD0, WHO_AM_I_MPU9250);
d = myIMU1.readByte(MPU9250_ADDRESS_AD1, WHO_AM_I_MPU9250);
Serial.print("Received AD0: 0x");
Serial.print(c, HEX);
Serial.print(", AD1: 0x");
Serial.println(d, HEX);
digitalWrite(13, ledOn);
ledOn = !ledOn;
delay(100);
}
 
So your hardware is not communicating. Are you using I2C or SPI? Do you have some type of a logic analyzer so you can see the signals on the i2C or SPI bus?
 
yes I'm sure. and I was getting a correct output from it before I change my windows.
yes it is i2c connection. wire2.
the microcontroller is teensy
 
So your hardware is not communicating. Are you using I2C or SPI? Do you have some type of a logic analyzer so you can see the signals on the i2C or SPI bus?
If you do anything with SPI/I2C much beyond the plug-in Arduino shields, you HAVE to get a logic analyzer. I'm partial to Salae, but there are others out there there are cheaper. Case in point: When I was working on the new Proton update, the ADXL375 accelerometer chip wasn't behaving as it should. Turns out that the SPI library for the ESP8266 can't do SPI Mode 3, even though it says that it can, even after making some code changes to the library. I fixed it with a glue logic chip. There's no way that I would have figured this out without a logic analyzer.
 
yes I'm sure. and I was getting a correct output from it before I change my windows.
yes it is i2c connection. wire2.
the microcontroller is teensy
I can't help you debug a communication (hardware issue) without a logic analyzer. If you are getting 0xFF with a WHO_AM_I command you have a communication issue.

>>and I was getting a correct output from it before I change my windows
What does this ^ mean?
 
>>and I was getting a correct output from it before I change my windows
What does this ^ mean?
Might mean he had 2 instances of Arduino IDE running simultaneously in Windoze. Or Windoze has forced an upgrade on him in the middle of trying to work. Either of which needs a reboot as a minimum.....and maybe an update of Arduino IDE with 6 cups of tea/coffee while that happens.
 
Hi guys,
thanks for the reply, I already solved the issue which was due to a mis compatibility on the libraries.
 
Back
Top