STM32 Nucleo and MMA7361 accelerometer arduino example

In this example we connect a MMA7361 to a STM32 Nucleo – the code is written in the Arduino IDE

The MMA7361L is a low power, low profile capacitive micromachined accelerometer featuring signal conditioning, a 1-pole low pass filter, temperature compensation, self test, 0g-Detect which detects linear freefall, and g-Select which allows for the selection between 2 sensitivities. Zero-g offset and sensitivity are factory set and require no external devices. The MMA7361L includes a Sleep Mode that makes it ideal for handheld battery powered electronics.

Features
• 3mm x 5mm x 1.0mm LGA-14 Package
• Low Current Consumption: 400 μA
• Sleep Mode: 3 μA
• Low Voltage Operation: 2.2 V – 3.6 V
• High Sensitivity (800 mV/g @ 1.5g)
• Selectable Sensitivity (±1.5g, ±6g)
• Fast Turn On Time (0.5 ms Enable Response Time)
• Self Test for Freefall Detect Diagnosis
• 0g-Detect for Freefall Protection
• Signal Conditioning with Low Pass Filter
• Robust Design, High Shocks Survivability
• RoHS Compliant
• Environmentally Preferred Product
• Low Cost

Typical Applications
• 3D Gaming: Tilt and Motion Sensing, Event Recorder
• HDD MP3 Player: Freefall Detection
• Laptop PC: Freefall Detection, Anti-Theft
• Cell Phone: Image Stability, Text Scroll, Motion Dialing, E-Compass
• Pedometer: Motion Sensing
• PDA: Text Scroll
• Navigation and Dead Reckoning: E-Compass Tilt Compensation
• Robotics: Motion Sensing

Parts List

Name Link
STM32 Nucleo STM32 Development Board NUCLEO-F446RE, STM32 STM32F446RET6 MCU, supports Arduino
MMA7361 sensor MMA7361 Angle Sensor Inclination Accelerometer Acceleration Module For Arduino
connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

Schematic

nucleo and mma7361
nucleo and mma7361

Code

Simple code that simply displays the X,Y and Z values via the serial port

[codesyntax lang=”cpp”]

int x;
int y;
int z;

void setup()
{ 
Serial.begin(9600);
}

void loop()
{
x = analogRead(0); // read A5 input pin
y = analogRead(1); // read A4 input pin
z = analogRead(2); // read A3 input pin
Serial.print("X = "); // print x value
Serial.println(x);
Serial.print("Y = "); // print y value
Serial.println(y);
Serial.print("Z = "); // print z value
Serial.println(z);
delay(1000);
}

[/codesyntax]

Output

Open the serial monitor and move the sensor around, you should see something like this

X = 223
Y = 127
Z = 10
X = 220
Y = 127
Z = 11
X = 218
Y = 125
Z = 9
X = 219
Y = 130
Z = 11
X = 118
Y = 12
Z = 37

Links

http://www.nxp.com/files/sensors/doc/data_sheet/MMA7361L.pdf

 

This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views :