I am trying to connect slotted opto ( TCST2300 ) to raspberry pi. I would like to receive 1/0 on GPIO input pin. Programming is not a problem but the circuit is.

I referred following circuit

But it is unclear which pin goes where. ("GPIO Pin" and "Input" particularly )

I tried with:

1: connecting "GPIO Pin" to Pi's 3.3V through 10K resistor


2: connecting "input" to P17.

Then I always received 1 on P17, regardless of infrared being interrupted.

Could you please guide me here?


The "Input" terminal should be grounded to turn on the LED in the optocoupler. The collector of the opto's transistor should be connected to +3.3V through a resistor, as you have shown, and also to the Pi's pin 17. With this connection, pin 17 should be low (0) if there is nothing in the opto's slot, and should go high (1) when something is in the slot obstructing the light path.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.