Uncategorized

Laser sharp focus on a subject

Asked 
Active today
Viewed 23 times
1

first time posting here so i will try to explain my best . I have 1 infra red transmitter on one side and second on other side , and when someone passes through i want to detect and call some function. Everything is working fine , but sometimes it detects passing through when nobody is passed , something like false edge detection, plus when i cross and stand in between the calling function is called 3 times or 2 times , depends. I dont know what the problem may be , i tried connecting it like this LINK

without the capacitor but its still the same , My code is :

import RPi.GPIO as gpio
import time

pin = 11

def on_pushdown(channel):

    latest_state = None
    inputValue = gpio.input(pin)
    if inputValue != latest_state:
        latest_state = inputValue
        if latest_state:
            print("Button2 pressed")



try:
    # Setting GPIO layout
    gpio.setmode(gpio.BOARD)
    # Set pin as input pin pulled down to GND
    gpio.setup(pin, gpio.IN, pull_up_down=gpio.PUD_DOWN)
    gpio.setup(pin1, gpio.IN, pull_up_down=gpio.PUD_UP)




    while True:
        #print(gpio.input(11))
        if not 'event' in locals():
            event = gpio.add_event_detect(pin, gpio.FALLING, callback=on_pushdown, bouncetime=1)
        else:
            time.sleep(1)

finally:
    gpio.cleanup()  
 New contributor
  • 1
    now its working – Raspu 14 hours ago
  • 1
    I will try to answer all of your question starting from the top : Yeah i know that is an old post but the idea is the same , i think my problem is the uncotinious (not constant XD) power , so even the smallest changes in the power are detected , and as far as i know , the capacitor has something to do with the stabillizing the power. – Raspu 8 hours ago
  • 1
    I did not try the other libraries because they are simillar and in my situation i think i will stay with the Rpi.gpio for now – Raspu 8 hours ago
  • 1
    I did not connected the capacitor because i am not sure how to implement it in my circuit , because i have , ground from IR to gnd to raspberry and pusle from IR to pin11 on raspberry – Raspu 8 hours ago
  • 1
    The wires are around 10 m long – Raspu 8 hours ago
1

I found a solution , so if somebody come across this post , and its in simillar situation like me , because there are a lot of people with the same problem here is link to the solution:

LINK

 New contributor
  • 2
    Please don’t just post a link-only answer. Explain in short the solution and take the link only as reference. And please accept your own answer after two days with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year. – Ingo 6 hours ago
  • Hi @Raspu, Ah, the link you recommend about edge interrupt is very good for me ninja grade edge interrupt lovers/haters. I have perhaps read 500+ posts in that forum’s troubleshooting and also sensors and automation projects section and I would rank it top 0.1%. For those who have not yet followed the link, I would repeat the addr here, and then give my comments, perhaps after others. “Avoiding False Hits with RPi.GPIO Edge Detection (19 posts, 30+ min read) – apulv rpi.org.forums.troubleshooting 2016jan29”: raspberrypi.org/forums/viewtopic.php?f=28&t=134394. Cheers. – tlfong01 29 mins ago
.END

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: