High-pass filtering phototransistor output

I'm attempting to use an IR LED and an IR Phototransistor to read the "density" of vapors moving through a glass tube. The simple arrangement worked alright, but suffered from noise issues due to IR light in the environment.

I learned about the TSOP38238 IR Receiver from Adafruit, and other 38kHz IR receivers, but they seem to do additional demodulation beyond just filtering out non-38kHz input. What I'd like to is filter for high frequency input, but still read a continuous analog signal indicating how little to how much light the sensor has received.

To accomplish this, I've tried the following circuit:

I hoped this would make a high pass filter with a cutoff of about 32kHz, well beyond generous enough to avoid filtering 38kHz signals.

Unfortunately, this doesn't seem to work at all - exposing it to remote control light and repeatedly sampling the analog pin on the Arduino doesn't give me any non-zero readings.

I'm not sure what I'm doing wrong, and would appreciate any suggestions.

P.S.
I'm also open to suggestions for better ways to solve the underlying measurement problem (ie, use a photoresistor or something instead). Importantly, though, the solution shouldn't cost more than $2 for each sensor-emitter pair, and it should ideally not be visible to the naked eye.

No, you've blocked the photocurrent with the capacitor.
Add a 1.5k resistor from emitter to ground, change the previous resistor to say 10k (so
its not attenuating the signal too much), and reduce the capacitor to match, to 560pF or so)

Thanks for the reply!

By "add a 1.5k resistor from emitter to ground", do you mean from between the phototransistor output and the capacitor to ground?

The TSOP38238 family is a digital receiver - designed to receive remote control type signals. So it's output is of the "signal"/"no signal" type. It's often suggested here for break-beam type of applications, but it's not suitable or adaptable for your requirement.

I'm thinking of two different solutions to your design.

  1. eliminate the disturbances: make sure no (or very little) ambient IR light can reach your phototransistor, and use an appropriate IR filter to prevent visible light and other frequencies from reaching your phototransistor.

  2. correct for disturbances: measure the intensity of both the high and low signals. The amount of IR you measure when your LED is off is the background, deduct that from the signal you measure when the LED is on. You can probably reduce the flashing frequency to 100 Hz or so, assuming that your ambient IR doesn't vary that fast.

MarkT:
No, you've blocked the photocurrent with the capacitor.
Add a 1.5k resistor from emitter to ground, change the previous resistor to say 10k (so
its not attenuating the signal too much), and reduce the capacitor to match, to 560pF or so)

Thanks! That worked. I also didn't realize that both my emitters and phototransistors are highly directional. Even in the original layout, it is possible for me to pick up very small signal if I orient things correctly.

I'd really like to learn the proper math for this. It makes sense intuitively, now that I've thought about it a bit, that I was attenuating the signal too much, since the resistor to ground was so small. But I don't know how to take the output range of the phototransistor and correctly scale the output range of my filter to match that of the Arduino Due's Analog input.

The problem was really that you had barely any signal to filter in the first place without the emitter resistor, not the size of the filtering resistor.

As for the scaling, use a noninverting opamp circuit.