Problem with Ultrasonic ranger

Hi,
i’m trying to use the ultrasonic ranger SEN10737P on my Raspberry. It’s connected to a GrovePi. I’m using the following code :
`

GrovePi + Grove Ultrasonic Ranger

import time
from grovepi import *

Connect the Grove Ultrasonic Ranger to digital port D4

SIG,NC,VCC,GND

ultrasonic_ranger = 4

while True:
try:
# Read distance value from Ultrasonic
print ultrasonicRead(ultrasonic_ranger)
time.sleep(1)
except TypeError:
print "Error"
except IOError:
print “Error”

But, instead of giving me the distance, i’ve got something like 1, 2, 5 , 0 , 1054, 784.
In short, it sometimes gives me the right distance, but every 2 or 3 distances, he sends me a random number.

Hey,
Can you try reading the values in a while loop and see if the values become consistent after a second or two. There is a possibility that the GrovePi might be reading an old value from the buffer and that might be a reson for the inconsistency.

Do let us know if this helps.

-Karan