## Accelerometer

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
AlexBir
Posts: 7
Joined: Tue Apr 23, 2019 1:00 pm

### Accelerometer

Hi,

I am trying to work with the accelerometer of pyBoard.
From the values I get, I am not sure whether I do not understand something, or it does not work well.

I would expect that if the board does not move, the reading of all axes will be zero ( or close to zero).
When I will move the board I will get reading in the direction of the movement.

What I get now, that the value is depending on the location and not on the acceleration. I can get values of x,y,z: 14,12,14 and it remains the same until I change the location if the board.

Can anyone explain what I am missing?

Thanks
Alex

rhubarbdog
Posts: 166
Joined: Tue Nov 07, 2017 11:45 pm

### Re: Accelerometer

Axis z will be 9.81G
If the pyboard is not level this will be shared into other axis

OutoftheBOTS_
Posts: 791
Joined: Mon Nov 20, 2017 10:18 am

### Re: Accelerometer

Understand what an Accelerometer reads, it doesn't read acceleration but rather reads linear force so at rest it will read the force gravity exerts on it. When it accelerates it will read the resultant force of gravity plus the force created by acceleration.

Like wise the gyro isn't a gyro (gyro reads direction faced) but rather reads the angular force (reads how fast it is spinning) then it is possible to do a calculation based upon how fast it is spinning for how long to calculate what direction u are facing. Of course if the speed of the spinning isn't perfectly constant (in real world it is nver perfect constant) then there will be an slight error in they gyrop calculation of direction and this is called gyro driff

pythoncoder
Posts: 4792
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

### Re: Accelerometer

The accelerometer on the Pyboard is primarily for detecting the orientation of the board with respect to gravity. The general idea is that you can make applications which can detect tilting or inversion of the board, or decode gestures such as shaking it. It is fine for this purpose.

For motion measurement a precision IMU (inertial measurement unit) device with a gyro and magnetometer is required. Even then achieving any level of precision for distance and direction is not easy*. Gyros drift, magnetometers are influenced by local fields and the double integration of acceleration to determine distance greatly magnifies errors. In practice the best you can get from an IMU is a good measurement of heading, pitch and roll e.g. for aircraft applications.