Connect keyence laser sensors to Arduino

im trying to receive analog output from this keyence laser sensors and amp via arduino, but the current output is just giving me some random values not the real measurements

wiring diagram from the manual:

(link:Connection and wiring, Connection and wiring -9 | KEYENCE IL Series User Manual | Page 29 / 140)
i connected the analog pin to A0 on my arduino uno 3 board and analog shield pin to gnd, can anyone correct me if im wrong?

code:

const int analogPin = A0;  // Analog pin for distance measurement

void setup() {
  Serial.begin(9600);
}

void loop() {
  int sensorValue = analogRead(analogPin);  // Read the analog input
  Serial.println(sensorValue);
  float voltage = sensorValue * (5.0 / 1023.0);  // Convert to voltage
  
  
  float offset = 1.0;  
  float scaleFactor = 10.0;  
  
  float distance = (voltage - offset) * scaleFactor;  // Convert voltage to distance
  
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" mm");
  
  delay(500);
}

Do you have a link to the sensor manual.

Please post your code; please do not forget to use code tags as described in How to get the best out of this forum.

i updated the post, could you take a look again? thanks!

Which sensor do you exactly have. Your wiring diagram shows a number of options for the output; did you configure the unit to use the correct one (you probably should use 0-5V; page 3.2 of the full manual).

I have no experience with your sensor so I don't think that I can help further.

For those that want to help further, below the full manual downloaded from the site that OP gave.

Keyence.pdf (4.0 MB)

i have il-1000 amplifier connected to sensor head il-s025, tysm for your help:))

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