We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Everything is implemented right. I am getting data from every other sensor but the magnetometer is ust stucked at:
Here is my CODE:
#include "IMU.h" IMU::IMU() { Wire.begin(); pinMode(G_LED_PORT, OUTPUT); pinMode(BUZZER1_PORT, OUTPUT); setWire(&Wire); beginAccel(); beginGyro(); beginMag(); accelUpdate(); gyroUpdate(); // CALIBRATE SENSORs Serial.println("PREPARE FOR CALIBRAION!"); tone(BUZZER1_PORT, 10000); digitalWrite(G_LED_PORT, HIGH); delay(500); Serial.println("CALIBRATING SENSORS..."); accelXCalibrationValue = accelX(); accelYCalibrationValue = accelY(); accelZCalibrationValue = accelZ(); gyroXCalibrationValue = gyroX(); gyroYCalibrationValue = gyroY(); gyroZCalibrationValue = gyroZ(); noTone(BUZZER1_PORT); digitalWrite(G_LED_PORT, LOW); Serial.println("ALL SENSORS CALIBRATED"); } D3 IMU::calibratedAccelData(){ D3 accelData(accelX() - accelXCalibrationValue, accelZ() - accelZCalibrationValue, -accelY() + accelYCalibrationValue); return accelData; } D3 IMU::calibratedGyroData(){ D3 gyroData(gyroX() - gyroXCalibrationValue, gyroZ() - gyroZCalibrationValue, -gyroY() + gyroYCalibrationValue); return gyroData; } float IMU::getSpeed() { return sqrt(accData.X * accData.X + accData.Y * accData.Y + accData.Z * accData.Z) * 9.8; } // float IMU::getPitch() { return pitchKalmanFilter.updateEstimate(atan2((-accData.X), sqrt(accData.Y * accData.Y + accData.Z * accData.Z)) * 57.3); } // float IMU::getRoll() { return atan2(accData.Y, accData.Z) * 57.3; } // float IMU::getYaw() { return atan(accData.Z / sqrt(accData.X * accData.X + accData.Z * accData.Z)) * 57.3; } void IMU::updateSensors() { accelUpdate(); gyroUpdate(); accData = calibratedAccelData(); gyroData = calibratedGyroData(); speed = getSpeed(); // pitch = getPitch(); // roll = getRoll(); // yaw = getYaw(); } void IMU::output() { Serial.println(" "); // Serial.println("Accel:"); // Serial.println(accData.X); // Serial.println(accData.Y); // Serial.println(accData.Z); // Serial.println("Pitch: " + String(getPitch()) + "°"); // Serial.println("Yaw: " + String(getYaw()) + "°"); // Serial.println("Roll: " + String(getRoll()) + "°"); // Serial.println("SPEED " + String(speed) + "m/s"); // Serial.println("Gyro:"); // Serial.println(gyroData.X); // Serial.println(gyroData.Y); // Serial.println(gyroData.Z); magUpdate(); Serial.println("MAG:"); Serial.println(magX()); Serial.println(magY()); Serial.println(magZ()); Serial.println(magHorizDirection()); }
This is how i have connected my sensor with the arduino board:
Can someone help?
The text was updated successfully, but these errors were encountered:
Did you tried example code? (What is IMU.h? Is it orher library?) https://github.com/asukiaaa/MPU9250_asukiaaa/blob/master/examples/GetData/GetData.ino If there is problem with the example, the hardware (IC) or circuit may have problem.
Sorry, something went wrong.
No branches or pull requests
Everything is implemented right. I am getting data from every other sensor but the magnetometer is ust stucked at:
Here is my CODE:
This is how i have connected my sensor with the arduino board:
Can someone help?
The text was updated successfully, but these errors were encountered: