# Calibrating MPU6050 sensor

So I'm using an MPU6050 module for detecting the impacts on a board to which it is attached, in-order to detect hits on the board, using the accelerometer sensors. The module is placed vertically(z-axis pointing towards you). Each axis of the accelerometer reads up to +/-2g. But the reading at resting state for the X-axis reads around 1 always, but as far as I understand the values of all three axes should be close to zero? Also what is the most optimal way to calibrate the accelerometer sensor in code since every sensor would require minor tweaking.

• which part of your post is about IoT? Nov 16, 2023 at 17:01

As Wikipedia tells us:

An accelerometer is a tool that measures proper acceleration. Proper acceleration is the acceleration (the rate of change of velocity) of a body in its own instantaneous rest frame; this is different from coordinate acceleration, which is acceleration in a fixed coordinate system. For example, an accelerometer at rest on the surface of the Earth will measure an acceleration due to Earth's gravity, straight upwards (by definition) of g ≈ 9.81 m/s2.

(...)

An accelerometer at rest relative to the Earth's surface will indicate approximately 1 g upwards because the Earth's surface exerts a normal force upwards relative to the local inertial frame (the frame of a freely falling object near the surface). To obtain the acceleration due to motion with respect to the Earth, this "gravity offset" must be subtracted and corrections made for effects caused by the Earth's rotation relative to the inertial frame.

So, no, it should not be 0, you should have 1g in one direction, which enables you to detect which side is up (or down).

Not familiar with this specific accelerometer, but many can be configured to return, or better yet, detect variations rather than the absolute value. Can't find anything on this topic in the docs of that chip, though, but I have only gone through the docs I found very quickly, I may have missed it.

Depending on your application (detect any movement, or only specific movements), it could be as simple as just computing the difference between successive measurements or it may need something more.

• Okay that makes sense, thanks @jcaron! Nov 17, 2023 at 5:35