I am using a Maduino Zero 4G LTE(CAT1 A7670) [Maduino Zero 4G LTE(CAT1 A7670) | Makerfabs]. It is an Arduino zero-based board. I'm trying to create a GPS tracker with a dead reckoning (DR) system. I use an MPU9250 sensor [MPU9250 9-DOF 3-Axis Accelerometer, Gyro, & Magnetometer - No Warranty – Makerlab Electronics] for my DR system, but I have a problem when I try it with the module. After uploading the code to the module to test the sensor, the module won't connect to my laptop. The port started malfunctioning, and I couldn't use my module after that. The USB device is not recognized anymore.
This is the code I uploaded:
#include "mpu9250.h"
// Define an MPU9250 object
bfs::Mpu9250 IMU;
void setup() {
Wire.begin();
Wire.setClock(400000);
bool status = IMU.Begin(); // Begin function does not require any arguments
if (status) {
// Handle error
Serial.println("Error initializing MPU9250");
while (1); // This will halt the program
}
}
void loop() {
// Read the IMU data
if (IMU.Read()) {
float ax = IMU.accel_x_mps2();
float ay = IMU.accel_y_mps2();
float az = IMU.accel_z_mps2();
float gx = IMU.gyro_x_radps();
float gy = IMU.gyro_y_radps();
float gz = IMU.gyro_z_radps();
float hx = IMU.mag_x_ut();
float hy = IMU.mag_y_ut();
float hz = IMU.mag_z_ut();
// Print the sensor data
Serial.print("Accel X: "); Serial.print(ax);
Serial.print("\tAccel Y: "); Serial.print(ay);
Serial.print("\tAccel Z: "); Serial.print(az);
Serial.print("\tGyro X: "); Serial.print(gx);
Serial.print("\tGyro Y: "); Serial.print(gy);
Serial.print("\tGyro Z: "); Serial.print(gz);
Serial.print("\tMag X: "); Serial.print(hx);
Serial.print("\tMag Y: "); Serial.print(hy);
Serial.print("\tMag Z: "); Serial.print(hz);
Serial.println();
delay(1000);
}
}
I used the bolder flight systems InvenSense IMU, eigen, and unit conversions. I didn't have any problem when compiling.
I wonder if this module has a code reset or hardware reset option. Can I fix this? I hope someone can help me; I can't afford to spend another module since I tried to budget with what I planned for my thesis.