MMA7341LC Trouble

I have been trying to use this accelerometer with an arduino board but there has been a lot of trouble. I have been using the code that was given by arduino to read accelerometers. I soldered the wires and i have triple checked that each one is going to the correct place. I keep getting 400 for all the values most of the time. the three output values should be 0,0, 440. because there should be no force on two angles and the force of gravity on the last one.

Here is the code.


 Reads an Analog Devices ADXL3xx accelerometer and communicates the
 acceleration to the computer.  The pins used are designed to be easily
 compatible with the breakout boards from Sparkfun, available from:

 The circuit:
 analog 0: accelerometer self test
 analog 1: z-axis
 analog 2: y-axis
 analog 3: x-axis
 analog 4: ground
 analog 5: vcc

 created 2 Jul 2008
 by David A. Mellis
 modified 30 Aug 2011
 by Tom Igoe

 This example code is in the public domain.


// these constants describe the pins. They won't change:
const int groundpin = 18;             // analog input pin 4 -- ground
const int powerpin = 19;              // analog input pin 5 -- voltage
const int xpin = A3;                  // x-axis of the accelerometer
const int ypin = A2;                  // y-axis
const int zpin = A1;                  // z-axis (only on 3-axis models)

void setup()
  // initialize the serial communications:

  // Provide ground and power by using the analog inputs as normal
  // digital pins.  This makes it possible to directly connect the
  // breakout board to the Arduino.  If you use the normal 5V and
  // GND pins on the Arduino, you can remove these lines.
  pinMode(groundpin, OUTPUT);
  pinMode(powerpin, OUTPUT);
  digitalWrite(groundpin, LOW);
  digitalWrite(powerpin, HIGH);

void loop()
  // print the sensor values:
  // print a tab between values:
  // print a tab between values:
  // delay before next reading:


I am sorry you are having trouble reading your sensor. We have two boards that use the MMA7341LC chip: one that has a regulator and one that does not have a regulator. Which of those two are you using? Which Arduino board are you using? Can you also post pictures that clearly show your connections?


I have a chip with the regulator. I am using an arduino uno.
here is some sample data I get when I drop the chip.
372 388 256
372 389 258
371 388 257
373 390 257
371 389 255
371 389 254
372 387 257
372 388 258
372 387 259
287 403 434
351 301 373
387 441 677
383 224 680
343 419 140
500 381 2
371 370 153
282 338 474
386 362 210
344 357 305
365 361 231
357 360 268
363 363 241
362 361 254
363 364 240

Your raw data looks mostly okay to me. Please note that the accelerometer readings are going to be centered around half the voltage of the 3V3 pin (which should be about 3.3V), or 1.65 V, making the center value about 337 (where 0 is 0V and 1024 is 5V). When converted properly to units of g, most of your readings are close to 1 g in magnitude.

By the way, I appreciate your attempt at making your diagram depict reality, but in the future it would be much more helpful if you just showed what was connected to what in a clear way. You can see an example of a cleanly labeled schematic diagram here:


Thank you for the help so far. It has made a huge difference. Do you know how the code would look in order to control the g select pin?

You can control the g-select (sensitivity selection) pin with any of your Arduino’s 5V digital outputs. The pin is internally pulled low, so you should only need to write code if you want to change it from its default setting. Something like this should work:

int gSelectPin = 3; digitalWrite(gSelectPin, HIGH);


When i do that the numbers do change but the conversion doesn’t work.
here is the data for the chip being flat on the table which should read 0,0,-1
348 354 326
349 354 326
here is the data for the chip being upside down on the table which should read 0,0,1
346 350 373
344 351 376
for some reason the center is around 354 and 20 units = 1g
I cant figure out why this is?

Like we mention on the product page for that accelerometer, the value of the center of the analog voltages is dependent upon the voltage of the 3V3 pin. So, it might be that the voltage is not quite at 3.3V when you are getting your raw data. There are various reasons this might be, but a good way to get around that is to use an analog input and measure the voltage on the 3V3 pin, and then use that value as the center for your calculations.


1 Like

Hi, I am using the accelerometer MMA7341L ±3/±11g, I would like to know where the 3V3 pins are connected since it has two and one is next to “g-select”, I will use it with a PIC16f76A. greetings and thanks Pololu team!

Hello, LANDON.

The 3V3 pins are both 3.3V outputs supplied by the onboard 3.3V voltage regulator. They are connected to each other, and one is located next to the g-Select pin to provide a convenient way to pull g-Select high with something like a 0.1" - spaced jumper.


1 Like

Thank you for your prompt response, I understand it, now then the reading at the exit of any coordinate will be the reference to ground or just read through the pic the output of that coordinate? I planned to monitor the voltage at the output of a coordinate with an oscilloscope to have the reference values ​​before starting to program. Thanks J.

I am not entirely sure I understand what it is you are asking. In general, electronics like these should share a common ground, and by convention, voltages in a circuit are measured with respect to ground. For example, if you are using a multimeter to measure the voltage, you would connect the positive probe to either X OUT, Y OUT, or Z OUT, and the negative probe to GND. If you are using a microcontroller like your PIC, you should ensure that there is a connection between GND on your PIC and GND on the MMA7341L before reading the voltages produced at X OUT, Y OUT, or Z OUT.


1 Like

Thank you very much Jon for your attention, and I managed to get a reading of the midpoint of the voltage in XOUT which is 2.587V approx. (The exchange range is 2,790V - 2,495 approx.). Now I have several doubts:

  1. This variation is minimal even if it is already at 90 °, I would like to know if this is correct and if this variation can be increased since I understand that it can vary from 0-5V (while the G-select pin is 1).
  2. How can I make these values in Volts that XOUT gives me are read and interpreted by the PIC?
  3. The following pins are not connected:
    *TEST and 0G

Should I connect them to some port of the pic? or what are these pins of the MMA7341L for?

-Thanks a lot JON

This is a 3.3V sensor, not a 5V sensor, so its analog voltage outputs will vary from 0V to 3.3V (with the midpoint, 1.65V, representing 0g). This is regardless of whether the g-Select pin is connected high or low. The g-Select pin is used to set the sensitivity of the accelerometer, and pulling it high like you did sets a range of +/-11g. We broadly go over how to convert the analog voltage output of this sensor using the sensitivity (which would be 118 mV/g for your setup, since you are pulling g-Select high) under the “Using the sensor” section of that board’s product page. If you want the output to cover a wider voltage range, you probably want to use the +/-3 g range instead, which you can select by pulling g-Select low or leaving it disconnected.

That section also describes the Self Test and 0-g Detect pins; you should not need to connect them if you just want to read the acceleration values directly like what you are doing. If there is something in that section that is not especially clear, can you tell me specifically what it is you do not understand?

Note that the values you are reporting generally seem too high (with the +/-11g range, 2.587V would indicate a measured acceleration of nearly 8g), so unless you are actually expecting the sensor to be experiencing that kind of acceleration, I suspect you are either using it incorrectly or interpreting its output incorrectly. Can you tell me more about your setup? How are you supplying power to the MMA7341L, and how are you measuring its output? Can you post pictures that clearly show the connections between your accelerometer, PIC, and oscilloscope?


1 Like

Hi, I made a small sketch of the connections between the accelerometer and the pic (excluding the other connections of the pic), Vin of the accelerometer is 3.3V, but it still gives me the following values: (left-center-right)
With gsel not connected: 1.748V - 1.630V - 1.503V
With gsel connected: 1.780V - 1.657V - 1.536V

thanks Jon.

Those values seem fine for when g-Select is connected high, but not when g-Select is disconnected. Can you post pictures that clearly show your board and setup? Specifically how are you measuring the voltage at X OUT (multimeter, oscilloscope, reading with your PIC and printing the values, etc.)? It might also help if you post a video that shows your setup.


1 Like