IR receiver & transciever Switch

Hello Arduino folks!

I got a project where I'm going to try to use an IR receiver and transceiver as a kind of optical switch. I want the Arduino to have a function which returns true if the receiver and transceiver have a connection and false if they do not.
I understand that the IR Led must send a signal with a frequency of 38kHz because that's needed for the receiver to pick up the signal right? But I don't want to send any special information, I just want to check if they have visual contact.
Is this possible and how can I do this in the simplest way?

Thank you very much!

Anyone out there? You don't have to write an entire code for me, just give me some hints :slight_smile:
Will it work if I use Ken Shirriffs ir library to send a Raw command and then wait for the signal to get received or not. If it's not received then something is blocking the signal?

Yes this is possible using IRremote, provide you are not sending continuous signals. OK if it is say every second (depends on the spec of the IR receiver)

The better way to do it would be to use what is call an Ir barrier receiver like the TSSP58038.

This is designed to handle a continuous 38kHz signal, which would work for you. Pulsing it 500uSecs on and off might work even better.

Caveat: IR will bounce off walls and other obstacles, so some thought would be required to restrict the beam. (narrow pipe)

AnalysIR:
Yes this is possible using IRremote, provide you are not sending continuous signals. OK if it is say every second (depends on the spec of the IR receiver)

The better way to do it would be to use what is call an Ir barrier receiver like the TSSP58038.

This is designed to handle a continuous 38kHz signal, which would work for you. Pulsing it 500uSecs on and off might work even better.

Caveat: IR will bounce off walls and other obstacles, so some thought would be required to restrict the beam. (narrow pipe)

Okay thanks for your help!
But isn't it possible to create a function which when I call it sends a signal(using the send raw command In the irremote library may be with as you sais 500us interval?) And then the receiver check if it can receive anything. If it can't or partially then there's something in the way (return false) or if it can then there is nothing in the way(return true)? How can I send and receive at the same time in the code? I need some help with the programming there. Because doesn't the arduino code execute one thing at the time, so how can I send and receive at the same time?

I got a usual ir receiver and transceiver from an old Lego toy(they work). thanks again!

You may need to expand your desciption of the actual application...the best solution will depend on teh specifics.

But isn't it possible to create a function which when I call it sends a signal(using the send raw command In the irremote library may be with as you sais 500us interval?) And then the receiver check if it can receive anything. If it can't or partially then there's something in the way (return false) or if it can then there is nothing in the way(return true)?

Yes

How can I send and receive at the same time in the code? I need some help with the programming there.

In general not possible without a lot of isolation. IRremote does not support this. Regarding helping with code - thats why I suggested trying out the library examples first.

Because doesn't the arduino code execute one thing at the time, so how can I send and receive at the same time?

In practice not a runner, but you can have one arduino sending and a second receiving. Or just set up a 555 or ATtiny as the transmitter @ 38kHz and use the arduino as the receiver.

AnalysIR:
You may need to expand your desciption of the actual application...the best solution will depend on teh specifics.

Okay, I'm currently working on a project to automatically control my roller blind. I have installed a motor and everything but now I need in a simple way to tell the arduino when the roller blind is pullled down/up. SO my idea was to put an IR led on one side of the roller blind at the bottom and a receiver on the other side at the bottom so that when the roller blind goes down and breaks the IR connection the motor will stop pulling it down. (I will the same thing at the top so the roller blind knows when to stop pulling it up)(I attach a picture that might explain it a litle bit better)

AnalysIR:

But isn't it possible to create a function which when I call it sends a signal(using the send raw command In the irremote library may be with as you sais 500us interval?) And then the receiver check if it can receive anything. If it can't or partially then there's something in the way (return false) or if it can then there is nothing in the way(return true)?

Yes

you say yes but at the same time you say that I should use an ATTiny?

AnalysIR:

How can I send and receive at the same time in the code? I need some help with the programming there.

In general not possible without a lot of isolation. IRremote does not support this. Regarding helping with code - thats why I suggested trying out the library examples first.

Because doesn't the arduino code execute one thing at the time, so how can I send and receive at the same time?

In practice not a runner, but you can have one arduino sending and a second receiving. Or just set up a 555 or ATtiny as the transmitter @ 38kHz and use the arduino as the receiver.

But isn't it possible to do like this,

  1. I call my custom made checkIR() function.
  2. the functions (somehow) set the IR led to continuously blink with a 500us interval(with the IRremote library may be?).
  3. while the IR led is continuously blinking the IR receiver checks if it can receive the signal.
  4. if yes, return true. if no, return false

How do I set the IR led to continuously blink while performing other tasks like checking the receiver? Or is the problem that the IR Led will have finished blinking/sending its signal when I check the receiver?
This must be possible to achieve without having to program a ATtiny.

Thank you for your help, it looks like I have found the right guy at least "AnalysIR" :wink:

Possible ATtiny85 solution
I suppose the ATiny85 solution(as AnalysIR mentioned above) to my problem would look something like this, correct me if I'm wrong.

  1. In the Arduino Nano code I call my custom made TurnOnIR() function.
  2. TurnOnIR() function sends a command via Softwareserial to ATtIny85.
  3. ATtiny85 receives the command and activates the IR led which is connected to the ATtiny85. The Attiny85 uses the Ken Shirriffs IR library to send a raw command for a couple of seconds.
  4. The arduino nano calls the custom made boolean checkIR() function.
  5. checkIR() checks if the IR receiver receivs the command, if yes then it returns true, if no then it returns false.

Now that you have explained it a bit more...

...do some research on photointerruper sensors, reflectance sensors (both IR), which should work quite nicely & better than the approach to date. Read up on the data sheets.

Another 'cool' approach would be to get an adhesive RFID tag and put it on the reverse of the blind (bottom) and put an RFID reader( x2) fixed at the bottom and top connected to one Arduino.

An even cheaper approach would be to place a small magnet (as per the RFI approach) and use a hall effect sensor at the top and bottom in a similar fachion.

Lots of possibilities for you to research...

Thanks, your answers made my day (:

AnalysIR:
Now that you have explained it a bit more...

Sry for not just doing it at once :wink:

AnalysIR:
...do some research on photointerruper sensors, reflectance sensors (both IR), which should work quite nicely & better than the approach to date. Read up on the data sheets.

I just found out about photo interrupters today. The fact that it's possible to find them in everyday electronics is also very good, I just have to find an old printer/scanner/fax :slight_smile:

AnalysIR:
Another 'cool' approach would be to get an adhesive RFID tag and put it on the reverse of the blind (bottom) and put an RFID reader( x2) fixed at the bottom and top connected to one Arduino.

That's just brilliant! That would totally be my first choice if the price of the RFID readers wasn't so expensive :confused:

AnalysIR:
An even cheaper approach would be to place a small magnet (as per the RFI approach) and use a hall effect sensor at the top and bottom in a similar fachion.
Lots of possibilities for you to research...

That sounds interesting, do you think an ordinary fridge magnet would be sufficient if it would be around 1 cm from the hall effect sensor?

Thanks once again :slight_smile:

(deleted)

That sounds interesting, do you think an ordinary fridge magnet would be sufficient if it would be around 1 cm from the hall effect sensor?

. I don't know, you will need to test it out live. Maybe do some research online? Stronger magnets will allow a larger distance to the sensor. I suspect it would be possible to bring the sensor closer, if required?

BTW: you should be able to get any such sensors via sites like eBay @ reasonable cost if you are prepared to search & wait a bit for delivery. (including RFID.)