I am using a Adafruit MPU6050 accelerometer and gyroscope in one. but it needs to be calibrated but the as the accelerometer is reading 7.5 m/s^2 instead of 9.8.
any help on calibrating it would be great
thanks you
by the way this is when the accelerometer is flat of the table
Standard code? What on earth would that be?
You didn't get the message. Post the code here. Formatted in the IDE by Ctrl T using code tags, </>, when pasting.
A basic straight-line calibration is an offset (addition or subtraction) and a slope (a multiplication factor).
The easiest & most common way to do that is find the error at zero and that's your offset (addition). Then find the multiplication factor at the maximum. (If no calibration is needed the offset is zero and the slope is 1.)
I don't know if you can read zero... Can you rotate it to read zero? And you probably can't read the maximum either but if you multiply 7.5 x 1.307 you get 9.8. That's your slope if there is no offset.
...Where I work we have some analog-to-digital converters and digital-to-analog converters that are calibrated with an offset (at zero) and then with 10 slope corrections over the range. (We have an automated calibration setup so nobody has to make calculations.)
you have to download adafruit sensor lab library and its in but the calibration is to big ive tried other calibration code but they wont work for me for some reason
here an example of the results
For informed help, please read and follow the instructions in the "How to get the best out of the forum" post, linked at the head of every forum category.
Post the code, using code tags, describe what you expected to happen and what happened instead, and post the exact error messages.
/***************************************************************************
This is an example for the Adafruit SensorLab library
It will look for a supported gyroscope and collect
rad/s data for a few seconds to calcualte the zero rate
calibration offsets
Written by Limor Fried for Adafruit Industries.
***************************************************************************/
#include <Adafruit_SensorLab.h>
Adafruit_SensorLab lab;
#define NUMBER_SAMPLES 500
Adafruit_Sensor *gyro;
sensors_event_t event;
float min_x, max_x, mid_x;
float min_y, max_y, mid_y;
float min_z, max_z, mid_z;
void setup(void) {
Serial.begin(115200);
while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.println(F("Sensor Lab - Gyroscope Calibration!"));
lab.begin();
Serial.println("Looking for a gyro");
gyro = lab.getGyroscope();
if (! gyro) {
Serial.println(F("Could not find a gyro, check wiring!"));
while(1) delay(10);
}
gyro->printSensorDetails();
delay(100);
gyro->getEvent(&event);
min_x = max_x = event.gyro.x;
min_y = max_y = event.gyro.y;
min_z = max_z = event.gyro.z;
delay(10);
Serial.println(F("Place gyro on flat, stable surface!"));
Serial.print(F("Fetching samples in 3..."));
delay(1000);
Serial.print("2...");
delay(1000);
Serial.print("1...");
delay(1000);
Serial.println("NOW!");
float x, y, z;
for (uint16_t sample = 0; sample < NUMBER_SAMPLES; sample++) {
gyro->getEvent(&event);
x = event.gyro.x;
y = event.gyro.y;
z = event.gyro.z;
Serial.print(F("Gyro: ("));
Serial.print(x); Serial.print(", ");
Serial.print(y); Serial.print(", ");
Serial.print(z); Serial.print(")");
min_x = min(min_x, x);
min_y = min(min_y, y);
min_z = min(min_z, z);
max_x = max(max_x, x);
max_y = max(max_y, y);
max_z = max(max_z, z);
mid_x = (max_x + min_x) / 2;
mid_y = (max_y + min_y) / 2;
mid_z = (max_z + min_z) / 2;
Serial.print(F(" Zero rate offset: ("));
Serial.print(mid_x, 4); Serial.print(", ");
Serial.print(mid_y, 4); Serial.print(", ");
Serial.print(mid_z, 4); Serial.print(")");
Serial.print(F(" rad/s noise: ("));
Serial.print(max_x - min_x, 3); Serial.print(", ");
Serial.print(max_y - min_y, 3); Serial.print(", ");
Serial.print(max_z - min_z, 3); Serial.println(")");
delay(10);
}
Serial.println(F("\n\nFinal zero rate offset in radians/s: "));
Serial.print(mid_x, 4); Serial.print(", ");
Serial.print(mid_y, 4); Serial.print(", ");
Serial.println(mid_z, 4);
}
void loop() {
delay(10);
}
the error message
text section exceeds available space in boardSketch uses 34052 bytes (105%) of program storage space. Maximum is 32256 bytes.
Global variables use 1066 bytes (52%) of dynamic memory, leaving 982 bytes for local variables. Maximum is 2048 bytes.
Sketch too big; see https://support.arduino.cc/hc/en-us/articles/360013825179 for tips on reducing it.
Error compiling for board Arduino Uno.
I have posted the code and the error message that i receive. but the problem is that this only calibrates the gyroscoe but i am more concerned about the acceleration in 7 which is 7.5/s^2 when flat