Acclerometer readings to G readings

i have a question about the accelerometer sensor.
I am using the ADLX335 3 axis accelerometer.

When i connect it to the Arduino UNO using the following code

const int xpin = 0;
const int ypin = 1;
const int zpin = 2;

void setup()

void loop()
  Serial.print("X"); Serial.print(analogRead(xpin));
  Serial.print("Y"); Serial.print(analogRead(ypin));
  Serial.print("Z"); Serial.print(analogRead(zpin));

I get the following results to the serial output

my question is how to convert the analog reading of for example X: 340 Y: 369 Z: 413 to G force readings
I don't want to do the calculation on the arduino but on the computer.

I am new to this and i was searching all day but i couldn't find any clue.


I have that sensor but, I am still working on getting correct "G" readings. The way I have it figured is that the max analog value at 3.3v would equal 676.5 and the min. would equal 0.

So the scaling should be:
3G = 676.5
0G = 338.25
-3G = 0

I was able to get analog readings that looked to be correct. However, when I was trying to use the Map function and I must have been doing something wrong because my readings were all zero.

I hope this is at least some help,

This article might help

I tried but at some point i have readings up to 707 for all the axis

Have you verified that gravity is working correctly where you are?

0g should correspond to half the supply voltage.
So, assuming a 3.3V supply, 3.3 / 2 = 1.65V
If 5V is full scale, 1.65 / 5 * 1023 = 337.
So, 340 and 369 are not too far away for x and y, assuming the device is roughly horizontal.
Now, somewhere on the device's datasheet there is a figure for sensitivity, expressed in "mV / g" probably.
Apply that to your z (gravity, acting downwards) value, and you have your conversion.

Per the adxl335 datasheet, typical sensitivity is 300mV/G.

The Arduino uses a 10bit A/D, which is 1024 values. If you're using a 3.3V reference, that's 3.3/1024 = 3.22mV per LSB (as in,3.22mV change in voltage per increment of the A/D output).

So, to convert Arduino output value into G values...

Val * 3.22 = input voltage.
(Input voltage - offset)/.3 = G force.
(Val * 3.22 - offset)/.3 = G force.

Now, there's a couple things you need to understand about these low cost accelerometers. They are neither accurate or precise. You'll need to perform some sort of calibration to increase accuracy, and some form of averaging/filtering to increase precision. What sort of calibration/averaging/filtering you need to do depends on how accurate and precise you need your measurement to be.

Per the adxl335 datasheet, typical sensitivity is 300mV/G

… but is ratiometric to the supply voltage.

If you’re using a 3.3V reference

There’s nothing in the code posted above to suggest that this is the case.

You can have a look at my thesis, section 5.4.3 Reading data from the ADXL330 (which is just as the 335). You can also find there many good info on orientation sensing and sensor fusion with tones of references.. so you may find it useful.