I am planning to mount a MMA8452Q accelerometer on my window pane, which slides to open or close.
And, I want to detect when the window is slid open or shut, by detecting motion and direction of acceleration (and in the future, duration of motion).
I am currently able to detect motion using ‘Transient (HPF) acceleration detection’ on one axis. It is also supposed to give me ‘polarity’ of the acceleration, which, I suppose, should indicate the direction of initial acceleration. But the polarity is extremely inaccurate.
If I try moving it 10 times in the same direction, 50% of the time, I get a wrong polarity.
Since I want the instantaneous direction of acceleration, I haven’t averaged the reading.
I tried taking 50 samples immediately after the motion was detected, but failed to see a “trend” that I could detect. May be a seasoned eye can spot it (both attached images are for motion in the same direction, but one is for a short duration and another for much longer)
Can anyone please tell me what I am doing wrong here, or if I am missing something?