An infrared sensor is an electronic module that is used to detect the certain physical appearance of its surroundings by either emitting and/or detecting infrared radiation. IR sensors can also sense motion and determine the amount of heat released by an object. These sensors are commonly used in intruder alarms, light switches, and other home automation and industrial automation applications. We have previously used IR sensors in many projects. But these IR sensors can’t be put in sunlight as the sun also releases IR waves. There is only one common solution for this problem: Modulate your IR signal so that your sensor can detect an IR variation rather than a fixed IR level.
In this tutorial, we are going to interface E18-D80NK IR Proximity Sensorwith Arduino. The E18-D80NK is an advanced low-cost IR Proximity Sensor with an obstacle detection range of 3 cm to 80 cm. The use of modulated IR signal protects the sensor from the interferences caused by the normal light of a light bulb or the sunlight.
Components Required for interfacing E18-D80NK- Arduino Nano
- E18-D80NK IR Sensor
- Jumper Wired
- Breadboard
E18-D80NK Infrared Obstacle Avoidance Sensor is a low-cost IR Proximity Sensor with an adjustable range of 3 cm to 80 cm. The E18-D80 sensor comes with IR Transmitter and IR receiver in one module. The IR transmitter transmits modulated IR signal, which is then reflected by the object in its path and then detected by the receiver. This sensor has less interference by sunlight because of the modulated IR light.
E18-D80 IR Sensor is widely used in robots to avoid obstacles, industrial assembly lines, Reverse Car Parking, and many other automation applications. The detection range can be adjusted according to the application using the multi-turn screw that is located at the back of the sensor. The switching signal output changes according to the obstacle detection. It remains high when no obstacles and changes to low when there are obstacles. A red LED is placed behind the probe that turns high whenever an obstacle is detected. The E18 sensor operates on 5V and consumes around 5mA to 30mA current without any load.
E18-D80NK IR Proximity Sensor Specifications & Features:
- Input voltage: 5V DC
- Current consumption: > 25mA (min) ~ 100mA (max)
- Dimension: 1.7cm (diameter) x 4.5cm (length)
- Cable length: 45cm
- Detection of objects: Transparent or Opaque
- Diffuse reflective type
- Sensing range: 3cm to 80cm (depends on obstacle surface)
- NPN output (normally high)
- Environment temperature: -25 °C ~ 55 °C
Complete schematic for Interfacing E18-D80NK Proximity Sensor with Arduino is given below:
The connection for Interfacing of E18-D80NK IR Sensor with Arduino is very easy, connect the Brown wire of sensor with Arduino 5V pin, connect the Blue wire of sensor with Arduino’s Ground and connect Black pin of a sensor with a digital pin 7 of Arduino Nano.
IR sensors are also used in Line follower Robots and alarm system.
Programming Arduino for E18-D80NK IR SensorThe code for interfacing E18-D80NK IR Sensor with Arduino is as simple as it gets. The complete IR sensor Arduinocode is given at the end of the document. The explanation of the code is as follows:
Start the code by defining all the necessary pins that are required to read the sensor data and control the LED.
const int e18_sensor = 7;
const int led = 6;
Then inside the setup() function initialize the serial monitor at 9600 for debugging purposes. Also, set the sensor pin as input and the LED pin as output.
void setup() {
Serial.begin(9600);
pinMode (e18_sensor, INPUT);
pinMode (led, INPUT);
}
Then inside the loop() function read the sensor pin using digitalRead() and if pin state is LOW turn on the LED else turn off the LED.
void loop() {
int state = digitalRead(e18_sensor);
Serial.println(state);
if(state==LOW){
Serial.println("Object Detected");
digitalWrite(led, HIGH);
}
else {
Serial.println("All Clear");
digitalWrite(led, LOW);
}
Testing the E18-D80NK IR SensorOnce your code and hardware are ready, connect Arduino to the laptop and upload the code. After that open the serial monitor at a baud rate of 9600, and make some motion in front of the sensor. Observe LED and Serial monitor.
The complete working video and code for interfacing proximity sensor with Arduino are given below. Hope you enjoyed the tutorial and learned something useful. If you have any questions, leave them in the comment section or use our forums for other technical queries.
Code
const int e18_sensor = 7;const int led = 2;void setup() { Serial.begin(9600); pinMode (e18_sensor, INPUT); pinMode (led, INPUT);}void loop() { int state = digitalRead(e18_sensor); Serial.println(state); if(state==LOW){ Serial.println("Object Detected"); digitalWrite(led, HIGH); } else { Serial.println("All Clear"); digitalWrite(led, LOW);}delay(1000);}
Video
Comments