Hendra Kusumah
Published © GPL3+

Xiao Lidar Module

A custom lidar module that is easy to embed with XIAO base dev board

IntermediateShowcase (no instructions)9 hours250
Xiao Lidar Module

Things used in this project

Hardware components

XIAO ESP32C3
Seeed Studio XIAO ESP32C3
×1
I2C lidar Module
×1

Software apps and online services

Arduino IDE
Arduino IDE
JLCPCB easyeda pcb design

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

pcb

Code

Test Code

Arduino
#include <Wire.h>

#define LIDAR_ADDRESS 0x62
#define BUZZER_PIN 3

void setup() {
  Wire.begin();
  pinMode(BUZZER_PIN, OUTPUT);
  Serial.begin(115200);
}

int readDistance() {
  Wire.beginTransmission(LIDAR_ADDRESS);
  Wire.write(0x00);
  Wire.write(0x04);
  Wire.endTransmission();

  delay(20);

  Wire.beginTransmission(LIDAR_ADDRESS);
  Wire.write(0x8f);
  Wire.endTransmission(false);

  Wire.requestFrom(LIDAR_ADDRESS, 2);
  int distance = Wire.read() << 8 | Wire.read();
  return distance;
}

void loop() {
  int dist = readDistance();
  Serial.println(dist);

  if (dist < 100) {
    digitalWrite(BUZZER_PIN, HIGH);
  } else {
    digitalWrite(BUZZER_PIN, LOW);
  }

  delay(100);
}

Credits

Hendra Kusumah
47 projects • 159 followers
Love hacking and making new things from IoT to robotics

Comments