2

I'm using the code below, but I had no success.

I'm using this connection wire: The photo of the Arduino doesn't show the SCL and SDA pins, but please consider that it has 2 SCL pins and 2 SDA pins in the places where I marked them in the image.

Both sensors are working, however they are mirroring each other's measurements.

That link is from the datasheet: https://static.garmin.com/pumac/LIDAR_Lite_v3_Operation_Manual_and_Technical_Specifications.pdf

enter image description here

#include <Wire.h>
#include <LIDARLite.h>

#define LIDAR1_ADDRESS 0x62 // Endereço I2C do LIDAR Lite 1
#define LIDAR2_ADDRESS 0x63 // Endereço I2C do LIDAR Lite 2

LIDARLite lidar1; // Objeto para o LIDAR Lite 1
LIDARLite lidar2; // Objeto para o LIDAR Lite 2

void setup() {
  Wire.begin();        // Inicializa a biblioteca Wire (I2C)
  Serial.begin(115200);  // Inicializa a comunicação serial

  // Inicializa os objetos dos LIDARs
  lidar1.begin(LIDAR1_ADDRESS); // Inicialização do LIDAR Lite 1
  lidar2.begin(LIDAR2_ADDRESS); // Inicialização do LIDAR Lite 2
}

void loop() {
  int distance1 = lidar1.distance();
  int distance2 = lidar2.distance();

  // Exibe as medições dos LIDARs no Monitor Serial
  Serial.print("LIDAR 1: ");
  Serial.print(distance1);
  Serial.print(" cm | LIDAR 2: ");
  Serial.print(distance2);
  Serial.println(" cm");

  delay(500); // Intervalo entre as leituras
}
21
  • what does mirroring each other's measurements mean?
    – jsotola
    Aug 1 at 20:10
  • you connected one to I2C bus and the other to the SPI bus ... why don't you connect both sensors to the same bus?
    – jsotola
    Aug 1 at 20:20
  • had no success doesn't tell us much. What is actually happening? What is appearing in the serial monitor?
    – Nick Gammon
    Aug 2 at 8:56
  • I agree with @jsotola - if these are I2C devices, why connect one to the SPI port? I2C devices can be connected in parallel.
    – Nick Gammon
    Aug 2 at 8:57
  • @jsotola, I'm so sorry, I wasnt really clear. Let me try again, both sensors seem to be measuring , but when I place an obstacle in front of either of then, both show the same reading on the serial monitor. Aug 2 at 10:50

1 Answer 1

2

If these are the Garmin Lidar Lite V3, here is a link to their data sheet. On page 5 of the datasheet you'll find instructions for configuring their I2C addresses. If you haven't already done that, it's quite likely that both devices are replying at once to the same query.

If you have done that already, please update your question with that and any other relevant data - such as the manufacturer, if I got that wrong, add any configuration changes you've made.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.