Android accelerometer detect device lying still -


i developing application android supposed check whether device lying still. has work when lay device on flat surface. this has work when device lying still on either side of device. while holding device still in hand check should fail. because small movement hand/arm should enough detect movement.

i've tried on , on still seem fail in doing so. happens data receive sensoreventlistener fluctuating heavily. data below represents data device while lying still on flat surface.

0.07366191 0.056904275 0.034122672 0.047471035 0.080519415 0.07816742 1.2434766 0.34602648 0.25965866 0.52344894 0.14806636 

i've tried following:

  • 10 second calibrate while lying flat on table, storing calibrated value , use threshold.
  • fixed thresholding based on math.sqrt(ax * ax + ay * ay + az * az) results.
  • using either type_linear_acceleration or normal type.
  • using gravity (9.8) threshold.

at point don't know anymore. hope can me out. in advance.

i'm not sure kind of values android accelerometer outputs, if it's other accelerometers i've worked with, give regular samples of number of gs or milligs device feeling in x, y, , z directions (where x-, y-, , z- axis fixed respect device- can find guide accelerometer tell way which).

for example, accelerometer lying flat experiencing 1 g upwards. if output in milligs, continuously output (0,0,1000). if flip over, output (0,0,-1000).

there little noise, see values (-2,5,998), (1,0,1001), etc. instead of (0,0,1000). 1 way filter noise remember last few samples , average them, use average instead of raw data decision making.

for decision, try checking if z-component of g readings within, say, 20 units away 1000 or -1000.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -