Hi,
I'm currently working on a project to measure arm movements. I'm using an Arduino UNI with a MPU 6050 GY521. I have a working code that measures its raw values and I understand that I need to count in the sensitivity range 2g, 4g etc to get actual workable values.
I'm using GitHub - jrowberg/i2cdevlib: I2C device library collection for AVR/Arduino or other C++-based MCUs to find my acceleration offsets to calibrate the device but I don't know how to incorporate this into my code. I aso dont understand where i can add it the sensitivity range to get actual measurements.
Help will be much appreciated!
I'm new to the arduino world and am struggling to find anything useful as it seems this is basic knowledge to most people.
Thank you for your time. the following is the code I also got online to get the raw values:
//Arduino Project Hub
#include<Wire.h>
const int buttonPin = A5;
const int button = A4;
const int MPU=0x68; // I2C address of the MPU-6050
int16_t X, Y, Z;
void setup(){
pinMode(buttonPin, INPUT);
pinMode(button, INPUT);
Wire.begin();
Wire.beginTransmission(MPU);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);
Serial.begin(9600);
}
void loop(){
Wire.beginTransmission(MPU);
Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)
Wire.endTransmission(false);
Wire.requestFrom(MPU,6,true); // request a total of 14 registers
X=Wire.read()<<8|Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
Y=Wire.read()<<8|Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
Z=Wire.read()<<8|Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
Serial.print(""); Serial.print(X);
Serial.print(" "); Serial.print(Y);
Serial.print(" "); Serial.print(Z);
Serial.println();
// delay(100); //100ms
}