IR sensor trouble

Hey, I am trying to get my IR sensor to detect that there is an obstacle in front of it. However, nothing I seem to do actually works. This is a brand new sensor (just opened).

The aim of my project is more complex; however, I cannot get this simple circuit to do what it should.

Expected results:
if there is an obstacle, print "Obstacle".
If there is no obstacle, print "clear."

At the moment my sensor is always detecting that there is something infront of it even when there isn't. The exact sensor I am using is: IR-08H bought from JayCar: https://www.jaycar.com.au/arduino-compatible-ir-obstacle-avoidance-sensor-module/p/XC4524?pos=6&queryId=872308ab2768a593a5afa9d42f4cb7c7&sort=relevance&searchText=ir%20sensor

I wil attach a picture of my circuit and code.


Code:

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

type or paste code here

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

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

Hi, @alexanderswin
Welcome to the forum.

The information will show you how to post your code in a scrolling screen.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Hi,
Is that potentiometer soldered in by all three legs?

Is the clear LED bent over so it is parallel with the PCB, so that its IR is able to refect of an object, positioned infront, back into the darker IR receiver.

Tom.. :smiley: :+1: :coffee: :australia:

Hey Tom,

Yes, it is soldered in by all three legs, additionally, the LED is bent over. I am really stuck with this.

Hi,
Do you have a DMM, Digital MultiMeter?

Check the voltage across the two wires going into the clear IR LED.

Tom.. :smiley: :+1: :coffee: :australia:

Hi,
This might help, the pots may need adjusting, especially the frequency.
https://osoyoo.com/2017/07/24/obstacle-avoidance-sensor/

Also place a small piece if cardboard between the two elements in case the IR LED is radiating directly to the IR detector.

Tom.. :smiley: :+1: :coffee: :australia:

You have the sensor wired improperly :scream:


Miswired ?

Let’s see a good close up image of your sensor ?


Is this yours ?


If this is your then you are okay.


Correct: ?

Based on the datasheet (have you downloaded and read it?), you need to set the trimmers up until it works as you expect:

The module has two potentiometers one to control frequency and the other to control the intensity. Use these to optimise the sensitivity of the module.

If you have a too high sensitivity value, you'll always get the OUT pin to LOW. The module seems to have an onboard LED trigger: is it always ON (or OFF), despite of an obstacle presence?

Try adjusting the sensitivity trimmer, starting from one end up to the other one, and see if it changes to HIGH ("clear") and, hopefully, the onboard LED module (not the Arduino one) changing the state.
If changes, keep that trimmer position and try putting something in front and moving it towards the sensor unless turns LOW again.
If nothing works, there might be something else, starting from a bad wiring, up to a defective module (the picture you posted here shows a bad trimmer installing/soldering, and this usually means a very cheap manufacturing...). And the board has also a pin jumper, not described...

EDIT: I found THIS page for a very similar module, but with a lot more information, description and how to use it, than that meager documentation on that Jaycar site... Have a look at it, and see if it somehow helps you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.