Retro-Reflective Photoelectric Sensor

Retro-reflective means that the light hitting the reflector is snet back in the same direction as where the light came from. This means that the sensor detecting the light can be very close to the light source.

A retro-reflective sensor can detect an object moving through a light beam.

The sensor uses infra red light which makes the ligth invisible to the naked eye. It also means that cold objects are easier to detect and that the sensor is easier to use in a cold environment.

Brand : OMRON

Product Nr : E3Z-B81

Specifications

  • Minimum distance : 80mm
  • Maximum distance : 500mm
  • Output : PNP
  • Output current : 30mA max
  • Input voltage : 12V - 24V +10%
  • Operating temperature range : -25° → +55°C

Remark : The output is PNP which means that when the sensor sends a high signal, the ouput is pulled high to the input voltage. So when you use 24V as the input voltage and you put your hand in the light beam to couse the signal to go high, 24V is put on the signal pin. An Arduino does not like that (don't ask how I know) so you need a voltage devider on the output pin to get the signal to a usable level.

When you look closely at this picture you can see the light source and the sensor behind the red plastic cover.

Typical application for Arduino

The light sensor is connected through connector J1. It needs 24V to work. The Arduino label is conneted to an Arduino digital input pin.

The output of the sensor is floating when nothing is detexted en 24V when the light beam is interrupted. Of course the Arduino does not like 24V on its input pins so we need to use a voltage devider made with R1 and R2. The 24V is spread over both resistors. The voltage between the two is calculated by the furmula (24V / (47K + 10K)) * 10K = 4.2V. So when the light beam is interrupted, the voltage on the Arduino connection is 4.2V. As this is a digital connection, the Arduino will rigard this as a HIGH signal.

Arduino sample code

The code below uses the built in LED to indicate whether something is detected. The LED switches on when the light beam is interrupted. At the same time it provides an indication on the Serial port.

//Define the pin assignment
//The light sensor is connected to pin 7
#define LIGHTSENSORPIN 7


void setup() {
  //prepare the seerial port
  Serial.begin(9600);
  //Set input or output modes for the used ports.
  //LED_BUILTIN is a standard pin assignmet for Arduino for the LED on the board. It uses pin 13. This pin is set to output
  pinMode(LED_BUILTIN, OUTPUT);
  //Define the sensor pin as an input
  pinMode(LIGHTSENSORPIN, INPUT);
  //Let the user know through the serial port the setup is done
  Serial.println("Setup done");
} 


void loop() {
  //Input is high = active so we need to check if the port is equal to one.
  if (digitalRead(LIGHTSENSORPIN) == 1) {
    //The input is high so we detected a bottle. Let the user know through the serial port
    Serial.println("detection = 1");
    //Switch the LED on the Arduino board on by switching the pin HIGH
    digitalWrite(LED_BUILTIN, HIGH);
  } else {
    //Let the user know through the serial port nothing is detected
    Serial.println("detection = 0");
    //Switch the LED on the Arduino board off by switching the pin LOW
    digitalWrite(LED_BUILTIN, LOW);
  }
}