Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Break Beam Sensor Funky Output & Questions
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Break Beam Sensor Funky Output & Questions

by afno on Thu Aug 13, 2020 10:44 am

Hello. I am doing a project with a RasPi 3B+ and I am having trouble interfacing with the 3mm IR Break-Beam sensor that is sold here on Adafruit (but for some reason I bought it on Amazon even though it's more $$ there). I am new to using the GPIO pins with the raspberry pi, and so I decided to run a slightly edited version of the basic CircuitPython code that is shown here: https://learn.adafruit.com/ir-breakbeam-sensors/circuitpython
Code: Select all | TOGGLE FULL SIZE
import os
 
import board
import digitalio
 
 
# Create digital input with pull-up resistor on pin D18
# for break beam sensor.
break_beam = digitalio.DigitalInOut(board.D18)
break_beam.direction = digitalio.Direction.INPUT
break_beam.pull = digitalio.Pull.UP
 
while True:
    print(break_beam.value)
    # wait for the beam to be broken
    if not break_beam.value:
        #wait for the beam not to be broken
        print(break_beam.value)
        while not break_beam.value:
            print(break_beam.value)
        #play an mp3
        os.system("mpg 321 /home/pi/Music/soundFile.mp3")



For some reason, the only output I get is True. Never false, even when the sensor is not connected. For experimentation, I tried to change the pull to DOWN, to see if that would change it to constant false, which it did. I also tried to connect the sensor pin to 24 instead of 18. No dice. One thing that I did rather unusually which, I, being a total (non)expert, think couldn't be the problem was that I used aluminum foil to connect the sensor wires to some GPIO cables stripped on one end.

Is it possible I got a dud?

Now, having tried everything I could think of, I can't seem to get this working.

Now, apart from my problem, I do have some other questions. The environment this sensor will be implemented in is very fast paced. The sensor, in order for it to be useful to me, has to detect an object 4/4/4 to 6/6/6 mm object traveling at 218-260 miles per hour. I want to make sure that when (if) I get this sensor working that it will be able to handle it's (very hard) job

afno
 
Posts: 3
Joined: Sat Nov 10, 2018 10:56 am

Re: Break Beam Sensor Funky Output & Questions

by dastels on Thu Aug 13, 2020 2:55 pm

So what happens if you use a wire (and solder!) to connect the sensor?

Dave

dastels
 
Posts: 3478
Joined: Tue Oct 20, 2015 3:22 pm

Re: Break Beam Sensor Funky Output & Questions

by afno on Thu Aug 13, 2020 10:21 pm

The wires ARE STRIPPED AND CONNECTED. The aluminum foil is just around the connection to keep it in place and seal the deal. Maybe the aluminum foil is adding just enough resistance to trigger the pull down resistor. (but then again, it is sort of acting like a bunch of parallel resistors, and should be lowering the resistance.). Maybe electrical tape? It is also a possibility that the aluminum foil connections touched and ruined the sensor.

I am, now that I think about it, starting to be convinced that there is a connection that is lacking contact area and there is too much resistance in that connection. But then again, I can't be sure until I solder. I plan to do that

afno
 
Posts: 3
Joined: Sat Nov 10, 2018 10:56 am

Please be positive and constructive with your questions and comments.