MSA300 - Digital Triaxial Accelerometer

MSA300 is a triaxial, low-g accelerometer with I2C/SPI digital output for sensitivity consumer applications


1. Datasheet

MSA300-V1.0-ENG


2. getAcceleration()

2.1. Description

getAcceleration() returns the acceleration.

2.2. Syntax

getAcceleration()

2.3. Returns

acc_t Acceleration struct containing accelarations of each axis in m/s^2

2.4. Example Code

see example msa basic

#include <MSA300.h>
#include <Wire.h>

// This is the length of the string that will be created
// included minus and decimal point
const signed char formattedStringLength = 11;

//  The number of digits after the deimal point to print
const unsigned char numVarsAfterDecimal = 6;

acc_t data;
MSA300 msa;

static char outstr[11];

char * formatValue(float value)
{
  dtostrf(value, formattedStringLength, numVarsAfterDecimal, outstr);
  return outstr;
}

void setup()
{
  Serial.begin(115200);
  Wire.begin();
  msa.begin();
}

void loop()
{
  data = msa.getAcceleration();

  Serial.printf("Xa:%s ", formatValue(data.x));
  Serial.printf("Ya:%s ", formatValue(data.y));
  Serial.printf("Za:%s", formatValue(data.z));
  Serial.println();

  delay(100);
}

results matching ""

    No results matching ""