Project tutorial
Long Range Beam Break Sensor with Reflector Panel

Long Range Beam Break Sensor with Reflector Panel

A cheap beam break sensor utilising a reflector panel instead of a transmitter / receiver setup. Capable of handling long distances.

  • 4,502 views
  • 15 comments
  • 28 respects

Components and supplies

11114 01a
SparkFun Arduino Pro Mini 328 - 3.3V/8MHz
×1
Vishay TSSP4038 IR sensor
×1
Osram SFH 4545 IR LEDs
×2
Relay Module (Generic)
×1
d-sun voltage regulator
×1

About this project

Specific parts list:

  • I found These LEDs with a half-angle of 5 degrees able to emit 100mA of power. They also emit light at 940nm which is perfect for the receiver.
  • Vishay TSSP4038 IR receiver. The receiver is made to detect continuous 38kHz light also. Some other sensors need bursts which I weren't ready to figure out how to code.
  • Arduino Pro Mini 3.3v
  • D-SUN adjustable voltage regulator. I just had it lying around
  • 5V Relay module able to be triggered by the 3.3V Arduino
  • 0.1uF Capacitor
  • 300uF capacitor
  • 2N7000 transistor (This one can only handle 200mA so that limits the power for the LEDs but it's still more than the 20mA the Arduino pin can output) Might want to upgrade to a 2N2222 instead if more power is needed.

I've gathered bits and pieces from other projects to make this. The coding could probably be nicer looking and so could the soldering. But hey, it works.

I wanted to make a sensor with no dedicated transmitter but a reflector panel instead. Also, it needed to be long-range. It's fairly easy to find these on ebay but pretty damn difficult to find any with a range of about 15m which I need. So I built one...

I had a lot of trouble getting this thing working but two things I learned were that the capacitor near the sensor is a MUST and that light pollution is a bitch. I ended up covering the whole sensor in Sugru (except the front, obviously) to keep stray light out. It's pretty difficult to see that annoying IR light but I realised that it travelled through the plastic PCB-ish material. The Sugru did it.

Final results first:

Actually, after testing my first setup I discovered that the effective range was only around 10m.

In order to increase the range I tried ramping up the effect on the LEDs. So I turned the voltage regulator up from the previous 3.3v to around 4.5v AND supplied the Arduino via the RAW pin instead of the VCC pin in order to utilise the onboard regulator here. I put in a 10 Ohm resistor in series with the LEDs. (depicted on the schematics) I then discovered that my Arduino had a handicap and it's voltage regulator was dead. So I switched it to a Trinket Pro 3v I had lying around. Basically the same functionality between the two.

Functioning:

The built-in timer function on the Arduino works on pin 11 and connects to the gate on the transistor in order for the LEDs to pull more than the 20mA the Arduino can directly supply. My LEDs can safely pull 100mA at 1.5V CONTINUOUS. When pulsing this can be safely increased to roughly 160mA according the spec sheet (page 4, lower left corner).

The IR receiver is connected to power (via a resistor) and has as 0.1uF capacitor (very important, apparently). The output from the receiver connected to pin 8 goes low when it detects 38kHz modulated IR light and high when the beam is broken. Very easy to program the Arduino around.

Pin 12 is connected to a relay module also powered from the external voltage regulator by 4.5V

The coding makes sure that whenever the beam is broken the onboard LED lights up. This is mainly for aiming the sensor at the reflector. Only when the beam has been broken for 2 secs pin 12 will go high and trigger the relay. This is because I want people (and cars) to be able to move through the beam without triggering it. Only if a car is PARKED the relay goes off. This coding could most likely be prettier but I copy/pasted/edited from other projects, one using a push button to trigger different things for long/short presses.

Code

CodingC/C++
int LED1 = 12;
int LED2 = 13;
int button = 8;
const byte IR_LED = 11;

boolean LED1State = false;
boolean LED2State = false;

long buttonTimer = 0;
long longPressTime = 2000;

boolean buttonActive = false;
boolean longPressActive = false;

void setup() {

  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(button, INPUT);
  pinMode (IR_LED, OUTPUT);

TCCR2A = _BV (COM2A0) | _BV(WGM21);
TCCR2B = _BV (CS20);
OCR2A =  209; // ~209 = ~38kHz | ~219 = ~36kHz

}

void loop() {

  if (digitalRead(button) == HIGH) {
    
digitalWrite(LED2, HIGH);

    if (buttonActive == false) {

      buttonActive = true;
      buttonTimer = millis();

    }

    if ((millis() - buttonTimer > longPressTime) && (longPressActive == false)) {

      longPressActive = true;
      
      digitalWrite(LED1, HIGH);

    }

  } else {
    digitalWrite(LED2, LOW);
    digitalWrite(LED1, LOW);

    if (buttonActive == true) {

      if (longPressActive == true) {

        longPressActive = false;

      } else {

        LED2State = !LED2State;
        digitalWrite(LED2, LED2State);

      }

      buttonActive = false;

    }

  }

}

Schematics

ir_sensor_schem_4yP7GDenDe.png
Ir sensor schem 4yp7gdende

Comments

Similar projects you might like

Multiple mode Environmental Sensor Deck with MKR1000

Project tutorial by ConsoleTeam

  • 12,058 views
  • 14 comments
  • 50 respects

Eye Motion Tracking Using Infrared Sensor

Project tutorial by HomeMadeGarbage

  • 7,985 views
  • 11 comments
  • 70 respects

Color Sensor Prototype: Detect Color Name from Objects

Project tutorial by moretticb

  • 3,032 views
  • 4 comments
  • 23 respects

IR Distance Sensor

by vicente zavala

  • 4,849 views
  • 0 comments
  • 8 respects

Touch Sensor and Sound Sensor Controlling AC/DC Lights

Project showcase by Anbumachi

  • 1,160 views
  • 2 comments
  • 5 respects

Easy Motion and Gesture Detection by PIR Sensor & Arduino

Project tutorial by ElectroPeak

  • 26,539 views
  • 9 comments
  • 214 respects
Add projectSign up / Login