Home Chipkit Chipkit Max32 and MMA7660 accelerometer example

Chipkit Max32 and MMA7660 accelerometer example

by shedboy71

In this article we look at the MMA7660 connected to a Chipkit MAx32

The MMA7660FC is a digital output I²C, very low-power, low-profile capacitive micro-machined accelerometer featuring a low pass filter, compensation for zero-g offset and gain errors and conversion to six-bit digital values at a user configurable output data rate. The device can be used for sensor data changes, product orientation and gesture detection through an interrupt pin (INT).

Communication is handled through a 2 pin I2C interface, available on a wide range of microcontrollers. The I2C address by default is 0x4c.

Features

  • Digital output I²C
  • 3 mm x 3 mm x 0.9 mm DFN package
  • Low-power current consumption
    • Off mode: 0.4 µA
    • Standby mode: 2 µA
    • Active mode: Configurable down to 47 µA
  • Low-voltage operation: 2.4 – 3.6-volts
  • 3-axis ±1.5 g MEMS sensor and CMOS interface controller built into one package
  • Configurable output data rate from one to 120 samples a second
  • Auto wake/sleep feature for low-power consumption
  • Tilt orientation detection for portrait/landscape capability
  • Gesture detection including shake and pulse detection
  • Robust design, high shock survivability (10,000g)

Connection

  • Pinout for Arduino UNO
  • GND = GND
  • VCC = 5v
  • SDA = A4
  • SCL = A5

 

Code

I used this library – https://github.com/mcauser/Grove-3Axis-Digital-Accelerometer-1.5g-MMA7660FC

[codesyntax lang=”cpp”]

#include <Wire.h>
#include "MMA7660.h"
MMA7660 acc;

void setup()
{
acc.init();
pinMode(13, OUTPUT);
Serial.begin(115200);
}

void loop()
{

static long cnt = 0;
static long cntout = 0;
float ax,ay,az;
int8_t x, y, z;

acc.getXYZ(&x,&y,&z);

Serial.print("x = ");
Serial.println(x);
Serial.print("y = ");
Serial.println(y);
Serial.print("z = ");
Serial.println(z);


if(acc.getAcceleration(&ax,&ay,&az))
{
Serial.print("get data ok: ");
}
else
{
Serial.print("tiem out: ");
}

Serial.println("accleration of X/Y/Z: ");
Serial.print(ax);
Serial.println(" g");
Serial.print(ay);
Serial.println(" g");
Serial.print(az);
Serial.println(" g");
Serial.println();
delay(50);

}

[/codesyntax]

Output

Open the serial monitor

get data ok: accleration of X/Y/Z:
-0.19 g
-1.29 g
0.24 g

x = -31
y = -32
z = 18
get data ok: accleration of X/Y/Z:
-1.48 g
-1.52 g
0.86 g

x = -8
y = -25
z = 12
get data ok: accleration of X/Y/Z:
-0.38 g
-1.19 g
0.57 g

x = -2
y = -28
z = 18

Link

https://www.nxp.com/docs/en/data-sheet/MMA7660FC.pdf

1PCS NEW MMA7660 Replace MMA7260 3 Axis Triaxial accelerometer sensor module

Share

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More