I'm making a piston that is attached to a motor by a string, the piston is "cocked" back using the motor. The piston is sliding through a linear bearing I made. The end of the piston is attached to elastic bands which provide the moving force when extending the piston. When the piston needs to be extended, the motor needs to unwind to provide little resistance so that the piston can move freely. To know when I need to stop the motor (for both extending and cocking), I need to know the position of the rod. (I can't use an encoder for the motor because feedback in the motor doesn't necessarily correspond to feedback in the position of the piston, what if when extending, the piston hits something and doesn't move forward. Then the motor will continue to unwind even though there is no tension in the string and the string will bundle up and get caught somewhere).
Currently, I'm using a VL53L0X module to measure the position of the piston, but the output is unstable even when the piston is stationary.
I'm currently using that setup with a VL53L0X, but when the rod is stationary, the output isn't stable. Changes by about ±30mm, so I need a better solution
I've changed the post. I was using a black surface with the VL53L0X, now that I use a white surface, the reading only changes by ~10mm, so there was no real problem. I'm guessing if I use a more reflective surface like you suggested, I'd get better results