# how to increase IR sensor sensitivity to blockage

Here is the set up:

Right now I have an IR emitter and an IR receiver in slots on polar opposite walls of a tube. I need them to be able to detect a stoppage of flow within the tube. The tube is vertical and the flow will be a metal powder. I am using a 10 value averaging array and subtracting ambient IR from emitted IR (see code). IR emitter is turned on and off by a digitalWrite from an Arduino mega. IR emitter is connected to the 5V rail through a 100k ohm resistor and the analog read wire is connected to the node between the IR sensor and the resistor.

Here is my plan:

I plan to start the metal powder flow (due to gravity, from a hopper full of powder) and take an initial reading of the IR. Then when the metal powder hopper empties, the IR will be blocked less and the sensor should increase its output. this will allow me to detect when the hopper is empty and done flowing.

Here is my function: (it works well and is very consistent)

``````int readIR(int times) {
for (int x = 0; x < times; x++) {
digitalWrite(IRemitter, LOW);    //turning the IR LEDs off to read the IR coming from the ambient
delay(10);                        // minimum delay necessary to read values
ambientIR = analogRead(IRpin);   // storing IR coming from the ambient
digitalWrite(IRemitter, HIGH);   //turning the IR LEDs on to read the IR coming from the obstacle
delay(10);                        // minimum delay necessary to read values
obstacleIR = analogRead(IRpin);  // storing IR coming from the obstacle
value[x] = ambientIR - obstacleIR; // calculating changes in IR values and storing it for future average
}

for (int x = 0; x < times; x++) {  // calculating the average based on the "accuracy"
powder += value[x];
}
return (powder / times);         // return the final value
}
``````

The Problem:
I don’t think the metal powder will be able to block enough light. My code displays an average value of 1127 when the tube is empty and down to 1098 when I stick a drill bit between the sensor and emitter. This drill bit is blocking more of the light than the metal powder will. I need to somehow adjust my set up to have the obstacle bring down the reading much more. I am loosing a lot of fidelity with the reading currently.

Any suggestions?

I'm guessing you have the IR receiver connected between pin and 5volt.
I'm guessing your pull down resistor has a too high value.
You should have posted according the forum guidelines, so we don't have to guess.

I think you should lower the value of that pull down resistor until you have A/D values that are more in the middle of the range of the A/D (~512).
Then you should see a larger difference between full/empty.

You could have used modulated IR (38kHz).
Then you don't have issues with ambient light.
Leo..

There is something wrong here. I must assume that the IR emitter is an LED.
You say it is connected to +5V through a 100K resistor, which seems too high
a value. That leads me to think that the other end of the LED is connected to
a uC pin. Then the code pulls the LED lead LOW to turn it OFF. What?

I think I missed some of it,
but the trick to eleminate ambient light is a lot if IR transmitter light and an insensitive sensor.
Need to see a diagram.
Leo..

Here is a photo, it. The resistor is currently 100k, I am experimenting now with different values and will post again soon

Also, excuse the LED +/- orientation, I don’t know how to flip them in fritzing.

left LED is IR sensor, the right led is an emitter.

it was the pull down resistor! I tried 50k and 10k. The 10K worked perfectly

actually, the powder blocks very little of the light, any other suggestions to increase the analog value difference between no light blocked and a little light blocked?

Seems to me the problem is the lack of change seen in the change in medium, which long term will be exacerbated when the windows dust or scratch. Optical sensors in this sort of obscuration application are always going to be problematic.

So what to use? Is the metal powder magnetic? Could you use induction? How about change in weight of the hopper?

Is the powder reflective or refractive, you could use mie light scattering like dust sensors.

Which metal is it ? You may be able to detect it with a coil around the tube passing a current - the flowing metal particles will change the coil voltage . Not sure if will work , but worth investigating .

( see experiments of dropping a magnet down an aluminium tube)