I've been looking at the IR break beam here. and using this Python program:

import RPi.GPIO as GPIO
GPIO.setup(17, GPIO.IN)
    #I've tried with and without pull up, i.e., pull_up_down = GPIO.PUD_UP 
    while True:
       if(GPIO.input(17) ==1):
           print(“Beam Broken”)
       if(GPIO.input(17) == 0):
    #I've also looked at print(GPIO.input(17)

The results are a bit inconsistent. Namely, though '1' has showed up once. When restarting it only showed 0. When measuring the output of the 'switch' cable - it seems to be about .07 V

The Sensors are wired in the provided link (for Arduino) with direct connections for both sensor and connector to ground and 3v3. The signal cable is connected to pin 17.

Not sure how to trouble shoot at this point. Perhaps a more sensitive reading of the pin?

RPi with sensor-wiring visible

  • If you want help you will have to provide the code you are using and details of your wiring. Something similar is just wasting our time.
    – joan
    Commented Mar 3, 2016 at 15:23
  • revised - with wiring details elaborated
    – d-cubed
    Commented Mar 3, 2016 at 15:36
  • One thing that I found when working with the GPIO was that some pins were "cleaner" than others. I don't know where my notes on which pins were better are right now, but you may want to try other pins to see if you get different results.
    – Ficertyn
    Commented Mar 8, 2016 at 18:41
  • We used a remote - holding the beam up to the sensor resulted in .07V. I've ordered some webcams to check IR. I also have an IR reader I can set up. Unfortunately, my phone doesn't show IR anymore. [Not available with iPhone 4 after a certain date]
    – d-cubed
    Commented Mar 10, 2016 at 20:10
  • Can I ask how are you getting on with this? I have the same kit and can't get it to work. I will have a proper look tomorrow but what I have noticed is that to test if the ir LED is on, use the front facing camera of your iPhone. You can see if the LED is lit or not.
    – user42980
    Commented Mar 11, 2016 at 19:05

3 Answers 3


I can't comment so here's an answer that's not really an answer but rather some debugging suggestions:

Remove all logic from the circuit for now (raspi, arduino, whatever). No need for programming if the hardware isn't working.

Connect the receiver and transmitter to a 3v3-5v supply. Connect your multimeter or voltmeter to the output line of the receiver.

Make sure that the receiver is giving off a low reading when not illuminated (your reading of .07 volt == low). Proceed to place the receiver and transmitter as close as possible and check the voltage reading on your volt-/multimeter. It should rise significantly (typically to a voltage slightly lower than the supply).

If you don't get a rising voltage here, you got a hardware problem in the transmitter, receiver, connecting wires, your power supply or your multimeter. You can now start ruling out each component individually.

You might be able to test the receiver and transmitter using a digital video camera and an infrared remote control. If you own a TV and a smartphone/digicam, you should be good. It's not a sure-fire method but video cameras often don't filter out IR light properly so turn on the IR transmitter and look at it close-up through the view finder of your camera. You should see the light if it's working. Likewise, you'd expect the voltage in the receiver's output line to change if it's directly facing a TV remote control while the buttons are being pressed. If none of this works, look at the remote control through the camera to verify that your camera doesn't filter out IR light and that your remote is working.

Still nothing? Hit up ebay and buy 10-20 new diodes/receivers for a couple of bucks :P

  • Thank you for the great information. When they are directly lined up - it showed .07V and then decreased to .01/0.0V when moved apart. ?
    – d-cubed
    Commented Mar 10, 2016 at 15:52
  • Without adding a 3rd piece of equipment that you know is working, it's nearly impossible to determine which part is faulty. That's why I suggested that you tested with a camera, a remote control or something else (after making sure that the camera can actually see IR light or that the remote is actually able to turn on a TV/appliance)
    – jDo
    Commented Mar 10, 2016 at 16:38

If you are you using the Adafruit sensor.

The receiver is open collector. You need to enable the Pi's internal pull-up resistor for the GPIO you use or use a 10 k resistor between the receiver output line and 3V3.

The receiver output line should normally read high (beam solid) and will read low when the beam is broken.

  • No luck. The output only changed when the output line was unplugged - regardless of whether the beam was broken or not.
    – d-cubed
    Commented Mar 5, 2016 at 1:20
  • @Donnied Add some close-up photos of your set-up to your question.
    – joan
    Commented Mar 5, 2016 at 4:28
  • @Donnied Do you have a meter? If so could you measure the 3V3 and 5V voltages at the breadboard? It is very common to have the ribbon cable inserted improperly so that the left hand pins are actually on the right hand size and vice versa.
    – joan
    Commented Mar 7, 2016 at 15:47
  • Yes, I checked the feeds going to the sensor. 3v3 - both. The signal cable outputs .07V
    – d-cubed
    Commented Mar 7, 2016 at 16:16
  • 1
    I'd confirm you have the correct GPIO by reading it on the Pi while you alternately connect it with a jumper lead to 0V and 3V3 on the breadboard (making sure it is 3V3 and not 5V before doing so!).
    – joan
    Commented Mar 7, 2016 at 19:09

That sensor won't do well near any stray infrared source (sun, proximity sensor, etc.). Check my answer here.

Also, add a delay in your loop. 5ms or 10ms is a good number.

Source: experience

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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