## Accelerometer Continued Troubles

Our range of tiny modules are designed to make it easy for you to quickly add functionality to your projects. [Module List]
avrdude
Posts:32
Joined:Mon Sep 30, 2013 3:42 pm
Accelerometer Continued Troubles
Hi
I know I had a post recently about the accelerometer, and you're probably thinking "oh no not this guy again", but after confirming my module works, I am confused as to how one actually determines the g-force from the output voltage.
Which equation should I use:

g = (v - 1.65) / 0.8

or

g = (v / 0.8) - 1.65

Or are neither of those correct and I am on the wrong path?
I have tried equation 1, and it seems to work for the x and y axis, but the z axis displays -0.4 when at 0g.
I then tried equation 2, which I'm pretty sure is incorrect, but resulted in the z axis correctly displaying all g-forces experienced. However, the x and y axis were way out.
What am I doing wrong?
Thanks

andrew
Freetronics Staff
Posts:978
Joined:Sun Jul 14, 2013 7:06 am
Location:Melbourne, Australia
Contact:

### Re: Accelerometer Continued Troubles

Give this library a try, it works well:

avrdude
Posts:32
Joined:Mon Sep 30, 2013 3:42 pm

### Re: Accelerometer Continued Troubles

Hi,
Thanks for the link, that library works good, but I'd rather write my own code (and i thought people encouraged writing one's own code), so could you please tell me the correct equation to use?
Thanks

andrew
Freetronics Staff
Posts:978
Joined:Sun Jul 14, 2013 7:06 am
Location:Melbourne, Australia
Contact:

### Re: Accelerometer Continued Troubles

G value = (ADC x AREF/1023) - Q;

where ADC is the raw value from analogRead(), AREF is the analogue reference voltage you're using (3.3 or 5) and Q is the value for zero-g (Voff in table 2 of data sheet) which is 1.65 at 25 degrees Celsius.

avrdude
Posts:32
Joined:Mon Sep 30, 2013 3:42 pm

### Re: Accelerometer Continued Troubles

Thanks, now I know definitely what to do.