IR Flying Fish sensor going haywire

I have an IR (Infra-red) sensor. It seems to always detect an object, at ALL times, no matter how far an object is. I'm pretty sure it can't detect anything further than a few inches, and yet even when the nearest object is nearly a meter away, it's LED lights up to show that it has detected an object. I tried playing with its onboard screw (you can easily find it in the attached picture) to change its detection distance, but no avail. I always connect the 'OUT' pin to any PMW pin, and 'VCC' to +5V and 'GND' to ground (also find attached circuitry for more clarity). I've never used a resistor with it, although it always worked even then.

Does anybody have an idea on what's wrong? Possibly a short-circuit?

The sensor

How i connected the sensor

Although it's not an exact datasheet, it helped me connect the thing to the Arduino

I always connect the 'OUT' pin to any PMW pin,

Why a PWM (output) pin? The out of the sensor can connect to any digital INPUT pin.

groundFungus:
Why a PWM (output) pin? The out of the sensor can connect to any digital INPUT pin.

Yes, but I want to read from the sensor and write its value (HIGH, LOW) to the Arduino, print it to the Serial Port and turn on a LED

Please post your code. Does it make a difference if you shield the sensor from ambient light?

groundFungus:
Please post your code. Does it make a difference if you shield the sensor from ambient light?

int LED = 5; // Use the onboard Uno LED
int isObstaclePin = A0; // This is our input pin
int isObstacle = LOW; // HIGH MEANS NO OBSTACLE

void setup() {
  pinMode(LED, OUTPUT);
  pinMode(isObstaclePin, INPUT);
  Serial.begin(9600);
}

void loop() {
  isObstacle = analogRead(isObstaclePin);
  if (isObstacle == HIGH) {
    Serial.println("OBSTACLE!!, OBSTACLE!!");
    digitalWrite(LED, HIGH);
  } else {
    Serial.println("clear");
    digitalWrite(LED, LOW);
  }

}

Changing the lighting in any way does nothing. I don't think it will, seeing as all this does is send an infrared signal and then receives it, and lets me know if it detects an obstacle. I also doubt it's due to the code, but here it is.

If you're trying detect flying fish, you'll be on a boat on the water.

The movement of the boat and the ripples/waves of the water will make this nearly impossible.

mm radar might work. Maybe ultrasonics

Allan

Hi,
You are using "int isObstacle" as a variable 0 to 1023 from your A0.
NOT HIGH or LOW, that is a digital boolean variable.

Also pin5 is not the onboard LED, pin 13 is. :o

Your sensor output is connected to pin7, why are you looking at A0 in the first place?


Tom... :o
PS Did you get your last project working?

Hi,
Can I suggest you build this circuit.

And try this code;

/*
  IR Proximity Sensor interface code
  Turns on an LED on when obstacle is detected, else off.
  blog.circuits4you.com 2016
 */


const int ProxSensor=2;

void setup() {                
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT);     
  //Pin 2 is connected to the output of proximity sensor
  pinMode(ProxSensor,INPUT);
}

void loop() {
  if(digitalRead(ProxSensor)==HIGH)      //Check the sensor output
  {
    digitalWrite(13, HIGH);   // set the LED on
  }
  else
  {
    digitalWrite(13, LOW);    // set the LED off
  }
  delay(100);              // wait for a second
}

Then sit down and look at how it is structured and works.
This is the link to where a google search took me.

Tom... :slight_smile:

TomGeorge:
Hi,
Can I suggest you build this circuit.

And try this code;

/*

IR Proximity Sensor interface code
Turns on an LED on when obstacle is detected, else off.
blog.circuits4you.com 2016
*/

const int ProxSensor=2;

void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
//Pin 2 is connected to the output of proximity sensor
pinMode(ProxSensor,INPUT);
}

void loop() {
if(digitalRead(ProxSensor)==HIGH) //Check the sensor output
{
digitalWrite(13, HIGH); // set the LED on
}
else
{
digitalWrite(13, LOW); // set the LED off
}
delay(100); // wait for a second
}



Then sit down and look at how it is structured and works.
This is the link to where a google search took me.
http://blog.circuits4you.com/2016/04/arduino-ir-proximity-sensor-interfacing.html

Tom... :)

I tried it, and it didn't work. Do you have an idea on what might be the problem with the sensor itslef?

NickSpeed:
I tried it, and it didn't work. Do you have an idea on what might be the problem with the sensor itslef?

Not unless you give more detail than 'it didnt work'

I said earlier :

movement of the boat and the ripples/waves of the water will make this nearly impossible.

mm radar might work. Maybe ultrasonics

I add that the angle subtued by the fish at any distance will be so small that the reflected light from it will be minute compared to the background clutter and the ambient light.

It ain't gonna work unless you dangle the fish a few inches in front of the IR stuff with your hand.

Is the fish then flying? Hmmm....

Allan.

So the infrared obstacle sensor should have two LEDs. Are both of these always lit? Even when the pot (screw) is turned all the way counter-clockwise)

Also I am pretty sure allanhurst is correct.

It is just a cheap ($.50) digital sensor.

No way of reporting a distance.

Or distinguishing flying fish.

1 Like

agrp87132:
Also I am pretty sure allanhurst is correct.

It is just a cheap ($.50) digital sensor.

No way of reporting a distance.

Or distinguishing flying fish.

I have 6 of these to use as obstacle detectors, and they work fine for that.
For adjustable range they are pretty useless.
Tom... :slight_smile:
PS, have your sensor looking upward with no obstacles and adjust the pot until the LED just goes out.
The other LED should remain ON as it is the power indicator LED.
Then when you put your finger in range the LED should go ON.

Even a long range IR remote only has a range of a few tens of metres - and that for tx to rx with a peak power of several watts. The inverse square law applies here.

The need for a reflected system gets into the radar equation : path loss is proportional to the range to the 4th power . That's why radar transmitters need to produce a LOT of power.

You can't use a passive system because the fish is at the same temperature as the surrounding water.

It ain't gonna work.

You could, of course, fit your flying fish with a transponder. - that could make it feasible.

Hmmm.....

Allan

NickSpeed:
I tried it, and it didn't work. Do you have an idea on what might be the problem with the sensor itslef?

In the picture you posted the solder joints on the LED & IR sensor look suspect. They're probably OK but,... If you have a soldering iron you may want to touch them up. If you have a digital camera you can see if the LED is operating. Point the camera at the sensor and the LED should shine brightly. If you have a voltmeter handy you could measure the voltage across the sensor terminals and look for a fluctuation when the sensor sees/doesn't see IR light.

Hi,
Can you post a picture of your project, so we cans see your component layout?

Thanks.. Tom... :slight_smile:

vinceherman:
Not unless you give more detail than 'it didnt work'

I mean that the original issue persists

agrp87132:
So the infrared obstacle sensor should have two LEDs. Are both of these always lit? Even when the pot (screw) is turned all the way counter-clockwise)

Yes

agrp87132:
Also I am pretty sure allanhurst is correct.

It is just a cheap ($.50) digital sensor.

No way of reporting a distance.

Or distinguishing flying fish.

I didn't understand what Allanhurst meant. I understand the sensor is cheap, but I have no idea when I can get a new one

NickSpeed:
I didn't understand what Allanhurst meant. I understand the sensor is cheap, but I have no idea when I can get a new one

Please also read post #13.
What @allanhurst and I mean is, the sensors ARE NOT designed for absolute DISTANCE measurement, they are OBSTACLE detection sensors.
The output changes when an object appears in front of them, you cannot get any variable range information from the sensor.
You may have a faulty unit, but a new one will not necessarily do what you need it to do.
Tom... :slight_smile:
PS. A picture of your project may help, so we can see your component layout.

Are you trying the sensor outdoors?

Because 50% of what the sun emits is IR radiation. Both LEDs lit because the collector photodiode senses that radiation.

The sensors work well under fluorescent lights or in the dark. If you have incandescent or heat lamps it will sense that IR as well and both LEDs will be lit.

If you turn the pot all the way ccw the emitting diode should be off. You can check this with most cell phone cameras, IR appears purple. If you turn pot all the way clockwise, you should see purple with cell phone camera, if you go ccw all the way, no purple. If both are purple, need a new sensor.

I am not sure what your project is???

distance is tough

you can try this

or this