nullmainmethod
Member
I wired my Teensy LC up to an MPU-9250 using i2c, and for some reason I can't pry anything out of the sensor. I'm using this library for the MPU-9250, and the most recent versions of Teensyduino (1.40) and Arduino IDE (1.8.5).
Here's a picture of my wiring (5v for the MPU-9250 coming from other Arduino Uno hooked up to a USB port). I haven't added any pullup resistors because the MPU-9250 I linked from Amazon has onboard pullup resistors between its onboard 3.3v LDO regulator output and the i2c SCL/SDA lines. Again, the MPU-9250 is powered from a separate 5v source, it has an onboard LDO regulator (maybe this somehow is causing my problem?)
The code I'm running is practically an example, the only change being the addition of I2C_PINS_18_19 to the MPU9250's constructor and a couple of debugging print lines. When I run the code, I get one of the Serial.println() messages I added: "Starting..." and then nada after that.
Here's the code I'm currently using:
Thanks in advance.
Here's a picture of my wiring (5v for the MPU-9250 coming from other Arduino Uno hooked up to a USB port). I haven't added any pullup resistors because the MPU-9250 I linked from Amazon has onboard pullup resistors between its onboard 3.3v LDO regulator output and the i2c SCL/SDA lines. Again, the MPU-9250 is powered from a separate 5v source, it has an onboard LDO regulator (maybe this somehow is causing my problem?)
The code I'm running is practically an example, the only change being the addition of I2C_PINS_18_19 to the MPU9250's constructor and a couple of debugging print lines. When I run the code, I get one of the Serial.println() messages I added: "Starting..." and then nada after that.
Here's the code I'm currently using:
Code:
#include "MPU9250.h"
// an MPU9250 object with its I2C address
// of 0x68 (ADDR to GRND) and on Teensy bus 0
MPU9250 IMU(0x68, 0, I2C_PINS_18_19);
float ax, ay, az, gx, gy, gz, hx, hy, hz, t;
int beginStatus;
void setup() {
// serial to display data
Serial.begin(115200);
// start communication with IMU and
// set the accelerometer and gyro ranges.
// ACCELEROMETER 2G 4G 8G 16G
// GYRO 250DPS 500DPS 1000DPS 2000DPS
Serial.println("Starting...");
beginStatus = IMU.begin(ACCEL_RANGE_4G,GYRO_RANGE_250DPS);
Serial.println("Started");
}
void loop() {
if(beginStatus < 0) {
delay(1000);
Serial.println("IMU initialization unsuccessful");
Serial.println("Check IMU wiring or try cycling power");
delay(10000);
}
else{
/* get the individual data sources */
/* This approach is only recommended if you only
* would like the specified data source (i.e. only
* want accel data) since multiple data sources
* would have a time skew between them.
*/
// get the accelerometer data (m/s/s)
IMU.getAccel(&ax, &ay, &az);
// get the gyro data (rad/s)
IMU.getGyro(&gx, &gy, &gz);
// get the magnetometer data (uT)
IMU.getMag(&hx, &hy, &hz);
// get the temperature data (C)
IMU.getTemp(&t);
// print the data
printData();
// delay a frame
delay(50);
/* get multiple data sources */
/* In this approach we get data from multiple data
* sources (i.e. both gyro and accel). This is
* the recommended approach since there is no time
* skew between sources - they are all synced.
* Demonstrated are:
* 1. getMotion6: accel + gyro
* 2. getMotion7: accel + gyro + temp
* 3. getMotion9: accel + gyro + mag
* 4. getMotion10: accel + gyro + mag + temp
*/
/* getMotion6 */
// get both the accel (m/s/s) and gyro (rad/s) data
IMU.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
// get the magnetometer data (uT)
IMU.getMag(&hx, &hy, &hz);
// get the temperature data (C)
IMU.getTemp(&t);
// print the data
printData();
// delay a frame
delay(50);
/* getMotion7 */
// get the accel (m/s/s), gyro (rad/s), and temperature (C) data
IMU.getMotion7(&ax, &ay, &az, &gx, &gy, &gz, &t);
// get the magnetometer data (uT)
IMU.getMag(&hx, &hy, &hz);
// print the data
printData();
// delay a frame
delay(50);
/* getMotion9 */
// get the accel (m/s/s), gyro (rad/s), and magnetometer (uT) data
IMU.getMotion9(&ax, &ay, &az, &gx, &gy, &gz, &hx, &hy, &hz);
// get the temperature data (C)
IMU.getTemp(&t);
// print the data
printData();
// delay a frame
delay(50);
// get the accel (m/s/s), gyro (rad/s), and magnetometer (uT), and temperature (C) data
IMU.getMotion10(&ax, &ay, &az, &gx, &gy, &gz, &hx, &hy, &hz, &t);
// print the data
printData();
// delay a frame
delay(50);
}
}
void printData(){
// print the data
Serial.print(ax,6);
Serial.print("\t");
Serial.print(ay,6);
Serial.print("\t");
Serial.print(az,6);
Serial.print("\t");
Serial.print(gx,6);
Serial.print("\t");
Serial.print(gy,6);
Serial.print("\t");
Serial.print(gz,6);
Serial.print("\t");
Serial.print(hx,6);
Serial.print("\t");
Serial.print(hy,6);
Serial.print("\t");
Serial.print(hz,6);
Serial.print("\t");
Serial.println(t,6);
}
Thanks in advance.