IR receiver readings giving odd values

I am using a TSOP 38238 which has a carrier frequency of 38khz. Using tone, I blink my IR diodes at that frequency.

int irBounce(int pinNo) 
{
  tone(pinNo, 38000, 1);
  //interpret the signal
  delay(1);
  return (analogRead(A2)); //the higher this number is, the closer the object.
}

When call this function using the Serial.println(irBounce(pinNo)); I get odd results such as 1023 when there is nothing around, or 500 when my hand is right next to the diode.

I've wired everything like the attached picture

You have to connect the Ground of your sensor to the Ground of your Arduino.

Whoops I forgot to draw the ground on my schematic, the reciever is actually connected to another power source where it has a separate ground.

If you look at the datasheet (http://www.vishay.com/docs/82491/tsop382.pdf) you will see that the TSOP38238 output is digital (LOW-HIGH), not analog. It will either detect the signal (1023) or not (0). Any value you get between those two probably come by reading the input pin as it is switching ON or OFF.

You should get an IR photodiode to detect analog IR levels. Then you can measure the levels with your IR LED off and on and use the difference as an indication of proximity. Here is an article about such things: Arduino, Electronics and Programming: IR detection and Photo Transistor Testing