Author Topic: Problem with EE-SY410 sensor in motor counter project using Raspberry pi  (Read 923 times)

guitar0404

  • Newbie
  • *
  • Posts: 1
Dear all,

I'm currently working a project using EE-SY410 sensor and a Raspberry pi B+ model for motor revolution counter purpose. However, I have a problem in reading the signal from the sensor. Hope you guys can help me out.
My circuit for EE-SY410 is:
     LED (Cathode) --> 150 ohm --> 3.3V Pin
     LED (anode)--> Ground pin
     Receiver (Cathode) --> 3.3 V pin
     Receiver (Data) --> GPIO 7
     Receiver (Anode) --> 10kohm --> Ground pin

And my python code is:

import RPi.GPIO as GPIO
import time

sensor = 7
GPIO.setmode(GPIO.BOARD)
GPIO.setup(sensor, GPIO.IN, pull_up_down=GPIO.PUD_UP)
current = GPIO.input(sensor)
previous = current
def printState(current):
    print 'GPIO pin %s is %s' % (sensor, 'HIGH' if current else 'LOW')
printState(current)
while True:
    current = GPIO.input(sensor)
    if current != previous:
        printState(current)
    previous = current
    time.sleep(0.1)
GPIO.cleanup()


However when running the program, the GPIO-7 output stayed at HIGH value even though I use piece of paper to reflect the IR LED. The output voltage is around 3.2 V and reduce very little (0.05V) if there is reflective paper on it. 
If I don't use pull_up_down = GPIO.PUB_UP but let it as default (OFF), the value of GPIO-7 can be changed from HIGH to LOW and vice versa but it very unstable. Even there is no reflection, the value still change. When I measure the output voltage between GPIO-7 and ground, it showed around 1.2-1.4 V.

Can you help me out at which point was I wrong ? and what is the best python code for this kind of sensor ?

Thank you very much.

edesio

  • Newbie
  • *
  • Posts: 5
Re: Problem with EE-SY410 sensor in motor counter project using Raspberry pi
« Reply #1 on: September 29, 2015, 07:25:07 AM »
I had a similar problem. In my case IR just pass thru the paper. Try using a metal foil.