4

Is there a way to calculate the height between ground and your phone ? I thought i could use accelerometer to measure height but this post suggest that you should not use it considering the inaccuracy rate. If so what approach should i take to measure the height where my phone is held ?

Community
  • 1
  • 1
Illep
  • 16,375
  • 46
  • 171
  • 302

2 Answers2

3

An accelerometer (and timer) could measure relative height. If you start from the ground you could get an approximation.

If you don't mind it only working once:

Drop it, use the same technique, stop timing after the first impact.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
  • I want to calculate the change in distance(height) from its original position or ground. and every time there is a change in height i need to detect it. Is there a way to do this? – Illep Nov 22 '11 at 02:49
  • How to calculate the distance in feet from accelerometer values? Could you post any code snippet? – Anas Ahamed Mar 29 '18 at 12:47
  • @AnasAhamed Using math? Pretty standard stuff; you could just search--I found this after about 10s: http://www.dummies.com/education/science/physics/finding-distance-using-initial-velocity-time-and-acceleration/ – Dave Newton Mar 29 '18 at 12:55
2

GPS is accurate enough for you to get the elevation to within a few meters, but that's probably not what you're going for.

I suppose you could try some sort of sonar, after you determine that the phone's mic/speaker is pointing straight towards the ground with the accelerometer. You could assume STP, which would probably introduce about 20% error.

You could also tell the user to drop the thing, and use the accelerometer to see how long it falls before hitting the ground. Probably the most precise and accurate. This might use up a lot of phones though.

  • I could get the elevation height if i used GPS, but what do you mean by `few meters` ? Is there a given height for the elevation api to work? – Illep Nov 22 '11 at 02:46
  • He means that GPS gives you the height accurate to within a few meters. If it says you're 100 meters above sea level, you could be somewhere between, say, 90 and 110 meters. It's certainly not accurate to centimeters or anything. – ceejayoz Nov 22 '11 at 02:49
  • What about 5 meters ? Will it be able to detect this? – Illep Nov 22 '11 at 02:51
  • @Illep: It will depend on your phone. Different phones have different quality GPS implementations. I've evaluated GPS altitude data from the Samsung Google Nexus S and on Google's ADP2 (HTC Magic). At best they were +/- 5m (10m swing). The ADP2 was better though. Test it out on your phone to see. You'll probably notice that it jumps around even if you don't move the phone. – Richard Povinelli Nov 22 '11 at 03:44
  • So i guess there are no ways for me to get the height yet. – Illep Nov 22 '11 at 04:37