Some friend ask me to make a custom pcb for one of his project. He need a custom pcb to mount the a lidar sensor to a xiao dev board.
This is what I came up with.
FeaturesI am breaking the features that is required for this project
- Xiao ESP32-S3 microcontroller with Wi-Fi & BLE
- ToF laser distance sensor (Class 1 Laser)
- Integrated buzzer for audio feedback
- Battery powered with charging via USB
- 3D-printed enclosure for protection and mounting
Before designing the Custom PCB I tested the circuit using a regular perf board to check if the concept is working or not.
Then after everything is tested correctly I start designing the PCB.
For this I use EasyEDA to design the custom PCB
The PCB design integrates a buzzer (for proximity alerts or signal feedback) and cleanly routes the I2C connection from the Xiao ESP32 to the ToF sensor.
Wiring:
- I2C Bus:
SDA
,SCL
connected from Xiao to LIDAR - Buzzer: Connected to GPIO (P3 in schematic)
- Power: 3.3V and GND lines shared across all modules
A 3D-printed case holds the LIDAR securely and provides access to the Xiao's USB port and connectors. This ensures the sensor is robust for mounting on robots, drones, or tripods.
This is an example if its mounted on a car.
You can use MicroPython or Arduino IDE for this board. Below is a simple sketch to read distance and beep the buzzer when an object is close.
#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);
}
Applicationsaside from the intended function for this project, here are other application that can be used from this project:
- Indoor/outdoor mapping
- Collision avoidance
- Smart distance sensing for automation
- Robot vision systems
There are still room for improvement, and these are the things that I might I add in the future:
- Add Bluetooth support for wireless data transmission
- Connect to cloud or local server via Wi-Fi
- Add OLED screen to display distance
Comments