Best Rangefinder Inside a 1-2" Pipe

Hi!

I want to measure the position of an object moving inside a 1" diameter pipe ( I could probably make it up to 2" in diameter). The Ping rangefinder doesn’t fit inside and the Sharp IR GP2Y0A21 fits inside just perfectly but even when flush, sometimes the sensor readings are an inch or two off from previous calibrations (pic attached). I’m guessing the beam might be bouncing off the walls?

What’s the highest accuracy&precision, arduino-compatible sensor for this purpose for less than $80? I only need to measure distances 6" - 40". I heard lasers are great but they look quite expensive.

I found the Maxbotix LV-EZ4 which will fit perfectly inside a 1" pipe but I’m worried it will bounce around inside the pipe and give crappy readings.

Thanks!

can’t you place a stick in the pipe and see how far it sticks out?

tell more about the object and the pipe and the conditions for the measurement, otherwise more “crazy ideas” might pop up :wink:

haha! yes I could do that with a dowel, but then I guess I would run the rangefinder on the dowel? That's going to add mass and make the object 2x as long. I basically want to levitate a magnet in a pipe inside an electromagnet and change the current through the electromagnet depending on the position of the magnet. So i need to monitor the position of the magnet quickly and easily. :)

Just recalibrate the sensor for use inside the pipe. Sonar works much better in pipes than in open spaces, because the sound wave amplitude doesn't fall off so quickly with distance. For example, sonar is used to measure water level in deep wells.