Arduino-GP2Y0A21YK-library icon indicating copy to clipboard operation
Arduino-GP2Y0A21YK-library copied to clipboard

Wrong distance values

Open ghost opened this issue 9 years ago • 3 comments

I used this Library with an GP2Y0A21YK Sensor and run the Example code for reading Centimeter on an Arduino Nano und am receiving incorrect values. I meassured the distance with a tape meter and at 15cm I get the Serial reading "8", at 20cm I get "11", at 25cm I get "13", at 30cm I get "15". What could cause those misreadings?

ghost avatar Apr 17 '15 18:04 ghost

Could you check the analog value on the ADC input at these distances? Check the datasheet to see what distance corresponds to your measured value to see where the problem is located. (Arduino/code or the sensor)

jeroendoggen avatar Apr 17 '15 20:04 jeroendoggen

The distance is indeed not correct. I have two of these sensors at the moment. And I have compared them both with the data sheet of this sensor. At around 1.3V it should be 20cm, but your code gives 10cm. And it is still significant of at other ranges also.

tijmenvn avatar May 08 '15 08:05 tijmenvn

After using your combined library of distance sensors, the distance is correct.

tijmenvn avatar May 08 '15 08:05 tijmenvn