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

Jackie
  • 181
  • 1
  • 9

1 Answers1

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.

peck
  • 109
  • 4