How do I connect a 5V sensor to a 3.3V input

Hi

I am using a IR sensor (photo transistor) that was ripped out of a ball mouse and I am running it at 5V, but I need to connect it to a Raspberry Pi which runs at 3.3V (at least the IO-pins are). 

I can place a 3.3V regulator before the sensor and adjust the pull down resistors, or use a zener diode to limit the output, but I was wondering wheter my currecnt setup will be safe to use.

Sorry for the poor quality drawing by the way.

I used a potmeter for pulling down the transistor output and adjusted it until a voltage between 0.6 and 2.5 volts are going to the input. It came out at 1K Ohms.

Because the sensor is used as 1 half watcher for an encoder wheel, It takes very small turns of the wheel to measure the output. 

To make sure the two sensors don’t turn on and of simlutateously and to visualize the timing, I added an LED and connected it with a small (56Ohm) resistor to ground. 

The LEDs blink happily as the encoder wheel spins. You can see them switching on, turning brighter, dimming and switching off. I guess the switching occurs because when the output voltage is below the forward voltage of the LED, no current flows and the LED is off. Above the forward voltage, the LED switches on.

I asume that, because I don’t measure any voltages above 2.5V, this setup will be safe to connect to the Raspberry Pi 3.3V inputs.

Am I correct in this or is it there a risk that unforseen circumstances will still damage the Pi???

Use a Schmitt trigger to get
Use a Schmitt trigger to get a clean high/low level output. If you use a CMOS Schmitt trigger like 4093 you can run the circuit directly on 3.3V.
Don’t connect the circuit you posted to a 3.3V input. If the photo transistor is exposed to strong sunlight for instance, the output voltage can rise to 5V-dropdown voltage of the photo transistor and might fry the Pi input.

OK : thanks guys

I’ll check out that non inverting buffer.

The reason I prefer to run the encoder sensors at 5V, is that I am hoping to avoid having to deal with different logic voltages everywhere. The only exception will be 4 encoder signals to the RaspberryPi and 4 motor signals from the Pi to the L9110. The rest of the stuff is running at 5V and is controlled with I2C through a two-way I2C logic level converter; either direclty or maybe using a picaxe.