Introduction: Using IR Sensor (TCRT 5000) With Arduino and Program to Remove Noise

Picture of Using IR Sensor (TCRT 5000) With Arduino and Program to Remove Noise

In this instructable, basic circuitry for TCRT 5000 IR sensor and its working is discussed. a major focus of this instructable is on making a program which enables it to remove all kind of ambiance noise. So after using this method IR sensor need not be calibrated for different ambiance condition.

If you don't want to read complete instructable then go through this video:

Step 1: Working of IR Sensor:

Picture of Working of IR Sensor:

Distance measuring is very easy using IR sensor.
A beam of IR is transmitted to target and reflected beam is captured by the photodiode.

Photodiode measures the intensity of light (here mostly IR light). IR diode does not measure intensity of just IR light but it is also sensitive to visible light.

here, Intensity of IR light recorded by photodiode represents the distance between target and sensor.

Closer the target is the higher intensity of light is recorded and reduces with increase in distance.

Step 2: Making Circuit for Sensor:

Picture of Making Circuit for Sensor:

we are driving out photodiode using a basic circuit. we can also use op amp based more accurate and better method for precise measurement.

IR LED is connected with 100 Ohm of the resistor in series to digital pin of Arduino. and the photodiode is connected to 5k Ohm of the resistor in series to 5v of supply and signal is taken out from it which goes to the analog input pin of Arduino.

Step 3: Checking Circuit:

Upload this code to arduino.

void setup()





void loop()

{ digitalWrite(6,HIGH);



Serial.println(a); }

Now turn ON serial plotter and move some target in front of the sensor. The plot also should move as per movement of the target displacement.

The problem with this method:

  • Measurement is ambiance sensitive. any change in light can ruin measurement.

For example, if we calibrate sensor at morning can not be used for evening. And even in indoor if we turn ON - Off room light, calibration get changed.

Step 4: Sources of Noise and Solution:

Picture of Sources of Noise and Solution:

there are various sources of noise like:

  • IR radiation from the sun: the sun transmits a huge portion of IR radiation to earth. which captured by IR photodiode and reading is no more correct.
  • Indoor lighting: IR photodiode does not capture just IR light but also senses visible light transmitted by room lights.
  • Heat source: All heat source emits some sort of radiation which is captured by IR photodiode. the amount of this radiation so error depends upon temperature and size of a body.

These sources emit IR radiation, which is captured by IR Photodiodes. so the error is added to our measurement.


Ascan be shown in the third image,

If we turn ON led than photodiode measures noise+signal and if led turn Off photodiode receives just noise.

The difference in between this two values will give denoised data.

If we take two reading very fast enough denoising would get better.

attached code can be used to get pure/denoised data from the sensor.

Step 5: Testing Code for Denoising and Application

Picture of Testing Code for Denoising and Application

These pictures show RAW data, noise value and pure signal. you can also refer the video in which output from the sensor in presence of flashing light as well as static noise.

this approach can be used in line follower so that we do not need to calibrate sensor every time we use. it also can be used in some bots where IR sensor is used for the same advantage.


aravs1 (author)2017-08-22


I have TCND5000 Reflective Optical Sensor with PIN Photodiode Output.

I think function of this same as tcrt5000.

here I am connecting Anode of IR Led to 5v with 100ohm of resister and collecter is also connect to 5v with 5k ohm resister.and cathode of both connects to ground.

the output is taken from the collector of photo transistor which I connect to Arduino Pin of A1.

when I open a serial terminal I get constantly 98 98 98.........

this value is not changing if I take any object near to TCND5000.

help me. is there I need to connect any Op-amp IC.

marcusnorris75 (author)2017-06-06

What is the program you use to graph the data in real time?

It is serial plotter from Arduino IDE. Just update your Arduino IDE it is not available in older version.

chmico_9 (author)2017-03-21

Can this be done with an analog circuit ?

What terms can I use to search about this argument ?
Sorry for my noobness and thank you.

abhilash_patel (author)chmico_92017-03-22

yes . This code is inspired from that circuit only called "Lock-In amplifier". this is very useful system to extract data (of known frequency) from extremely noisy signal.

chmico_9 (author)abhilash_patel2017-03-28

thank you, now I have a lot to study :-)

АртёмХ (author)2017-02-07

Cool! Good idea!

Thanks lot...

About This Instructable



More by abhilash_patel:DIY: Arduino Based RC Transmitter and ReceiverSolar RC Plane Under 60$Simple Arduino Trigger for DSLR
Add instructable to: