0

I am trying to build a small G force logger with the use of a esp8266 and a mpu6050, I've managed to read values from the sensor and its prints out the following data:Data from sensor

Now I am wondering how to get human readable G forces from this data?

Code that I am using:

void loop() {
// read raw accel/gyro measurements from device
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

// these methods (and a few others) are also available
//accelgyro.getAcceleration(&ax, &ay, &az);
//accelgyro.getRotation(&gx, &gy, &gz);

#ifdef OUTPUT_READABLE_ACCELGYRO
    // display tab-separated accel/gyro x/y/z values
    Serial.print("a/g:\t");
    Serial.print(ax); Serial.print("\t");
    Serial.print(ay); Serial.print("\t");
    Serial.print(az); Serial.print("\t");
    Serial.print(gx); Serial.print("\t");
    Serial.print(gy); Serial.print("\t");
    Serial.println(gz);
#endif

#ifdef OUTPUT_BINARY_ACCELGYRO
    Serial.write((uint8_t)(ax >> 8)); Serial.write((uint8_t)(ax & 0xFF));
    Serial.write((uint8_t)(ay >> 8)); Serial.write((uint8_t)(ay & 0xFF));
    Serial.write((uint8_t)(az >> 8)); Serial.write((uint8_t)(az & 0xFF));
    Serial.write((uint8_t)(gx >> 8)); Serial.write((uint8_t)(gx & 0xFF));
    Serial.write((uint8_t)(gy >> 8)); Serial.write((uint8_t)(gy & 0xFF));
    Serial.write((uint8_t)(gz >> 8)); Serial.write((uint8_t)(gz & 0xFF));
#endif

// blink LED to indicate activity
blinkState = !blinkState;
digitalWrite(LED_PIN, blinkState);}
Marcel Stör
  • 22,695
  • 19
  • 92
  • 198
Erwin Vorenhout
  • 181
  • 1
  • 5
  • 20

1 Answers1

1

Did you change the scaling for the accelerometer? If you are using +-8g then you will divide by 4096 to get the G values.

Full Scale Range = LSB Sensitivity

-/+2g = 16384 LSB/g

-/+4g = 8192 LSB/g

-/+8g = 4096 LSB/g

-/+16g = 2048 LSB/g

L. Putvin
  • 56
  • 5
  • That will output 0.834228516G isn't that a bit low when its laying flat on the table or is the sensor not that accurate and should I round it? – Erwin Vorenhout Jun 12 '18 at 15:34
  • You have to calibrate the sensor by changing the offset. All the MPU6050s I used needed the offset values adjusted but were fine after that. – L. Putvin Jun 13 '18 at 22:07
  • What seems to be strange is that the 3th param doesn't seem to be accelaration but something like gyro, because when I hold the sensor upside down it changes values? Also my readings are way lower now something like 300? – Erwin Vorenhout Jun 14 '18 at 08:05
  • The first three are acceleration. I'm not familiar with the board you are using, but here's some calibration instructions written for using an arduino that should be easy to follow. [link](https://learn.adafruit.com/adafruit-analog-accelerometer-breakouts/calibration-and-programming) – L. Putvin Jun 14 '18 at 20:26