I am trying to make a photoelectric sensor using an IR emitter and an IR sensor.
Both are from the same brand and are compatible with each other, however, I constantly get a value of ca. 0.9 (should get 0 if it detects light) when holding the emitter right in front of the sensor. When I move the sensor away, it gives a value of 0.7, which I can work with.
Does anyone know how this happens and/or how I can fix it?
Thank you in advance.
Please post a schematic and your code, in code tags.
Using Python 3.9 with pyfirmata:
import pyfirmata
import time
try:
board = pyfirmata.Arduino('/dev/cu.usbmodem1101')
except pyfirmata.serial.serialutil.SerialException:
board = pyfirmata.Arduino('/dev/cu.usbmodem101')
it = pyfirmata.util.Iterator(board)
it.start()
board.digital[12].write(1) # signal for emitter
board.digital[13].write(1) # power for emitter and sensor
board.analog[0].enable_reporting() # input of sensor
a_0 = board.get_pin('a:0:i')
try:
while True:
board.digital[12].write(1)
board.digital[13].write(1)
print(a_0.read())
time.sleep(0.1)
except (KeyboardInterrupt, OSError, SystemError):
pass
finally:
board.digital[12].write(0)
board.digital[13].write(0)
Is that an IR detector/decoder that is used with an IR remote control. If so, then it may not be made to sense a steady signal, only a changing signal like the modulated signal from an remote control. You may need to modulate the signal from the emitter. 38KHz is a popular modulation frequency. And, even then, it may not work as the 38KHz frequency is further modulated to carry the information from a remote.
No, it's just a sensor, which is compatible with the emitter. Both the frequencies are at 37,8 kHz.
Your schematic shows the emitter driven by the battery. Is the schematic not accurate?
It's a simplified version. The power comes from the arduino
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.