Electronic – Sharp IR Distance Sensor gives the wrong readings

infraredproximity-sensor

I am using the SHARP GP2Y0A21YK0F IR distance sensor. According to the datasheet, the output voltage to distance graph should look as follows:

enter image description here

I attached the sensor to a power source straight from Arduino 5V output, so the power source is relatively steady. The sensor's analog output is attached to a multimeter to check the output voltage for the varying distances of a white sheet in front of the sensor.

Until approximately 45cm distance of the white sheet from the sensor, the sensor works fine. The multimeter reads are consistent with the graph's curve (except the 0cm reading). But after 45cm, the voltage goes up instead of decreasing further, until it reaches 1.57V, when there is no object in front of the sensor.

My readings of the multimeter are as follows:

    Distance[cm]      Voltage[V]   


    0                 1.7   
    5                 3.10  
    10                2.45   
    15                1.9   
    20                1.36   
    25                1.17  
    30                1.05   
    35                1.02   
    40                1.00  
    45                1.01   
    50                1.03   
    55                1.06   
    60                1.10 
    65                1.12 
    70                1.16   
    75                1.21  
    80                1.25  
    infinity          1.57   

I understand that for distances greater than 45cm the readings can be off because of effects caused by the surroundings (even though my testing environment is a closed clean room, but still maybe something causes faulty readings). What bothers me most is the voltage readings when no objects are in range. The sensor outputs 1.57V which is the same as 15-20cm range voltage, which can be problematic for my project as I intend to measure distances in the 10-40cm range.

What could be wrong?

Best Answer

Seems the issue was power spikes after all. I added a 100uF capacitor across the Vcc and GND connections on the sensor and it solved the issue.

Datasheet recommends 10uF which I tried first but 100uF did the trick.

Thank you very much for your answers