1

I have a simple IR detection device that looks like this...

enter image description here

I hook the GRD into ground, I hook the VCC into the Raspberry Pi 5v, I hook the EN into GPIO 21 and the OUTPUT to GPIO 20. Then I created this code...

from gpiozero import Button, LED
from signal import pause
from time import sleep

print("Starting the sensor")
engageSensor = LED(21)
pir = Button(20)
engageSensor.on()
# Also tried...
# pir = MotionSensor(20)
# pir.wait_for_motion()
# print("Motion detected!")
while True:
  print(f'running ${pir.is_pressed}')
  sleep(1) 

But I can't seem to get anything to work. It seems to turn on and based on the LEDs on the board detect my hand in front of it, but I never see it recognize it in python.

What am I missing?

Update

I also tried

from gpiozero import LineSensor
from signal import pause

sensor = LineSensor(20)
sensor.when_line = lambda: print('Line detected')
sensor.when_no_line = lambda: print('No line detected')
pause()

And

from gpiozero import LightSensor

sensor = LightSensor(20)

while True:
    sensor.wait_for_light()
    print("It's light! :)")
    sensor.wait_for_dark()
    print("It's dark :(")

But again I see the (s1?) LED on the board flash but nothing to stdout. (Neither print message)

I can use this with just straight GPIO...

from gpiozero import LED, LineSensor
from signal import pause
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(20, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
engageSensor = LED(21)
engageSensor.on()
while True:
  output = GPIO.input(20)
  if(output != 1):
    print(GPIO.input(20))

And it seems to work, 1 normal 0 when something is seen. How should this be translated to GPIOZero?

**Adding Arduino wire diagram **

enter image description here

enter image description here

10
  • 2
    I think you want LineSensor not MotionSensor gpiozero.readthedocs.io/en/stable/… Apr 18, 2020 at 22:23
  • 1
    Tried LineSensor too and still not seeing it in the std out
    – Jackie
    Apr 18, 2020 at 22:31
  • 1
    VCC should be the regular power rt not another GPIO?
    – Jackie
    Apr 18, 2020 at 22:33
  • 1
    It’s possible that the 5V power is used as a reference and the 3.3V is not enough to trigger the enable - have you tried powering it from the 3.3v supply? Do you have a link to the actual device rather than a pic?
    – user115418
    Apr 19, 2020 at 0:35
  • 1
    The datasheet is on a pdf. I am noticing the EN is not connected in their mockups I am not sure if that part is optional. On the diagrams everything says 5v but I will try to add more info later. If I use the straight GPIO lib I can see it work so I know it is working just not sure how to get it to work with GPIOZero now
    – Jackie
    Apr 19, 2020 at 1:47

1 Answer 1

1

Hip shot. You didn't share the device name.

1 - EN : Usually a high or low to enable the device. May be loose to default on. Basically an ENABLED or DISABLED feature. (locked or unlocked). You could try the three different states it can do,which is Ground, VCC or floating.

I'm sure you've figured it out by now.

1
  • It has been a while let me pull up the project and try it out
    – Jackie
    Feb 17, 2021 at 22:31

Your Answer

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

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