-
ESP32 I2C Pins:
SDA β GP5SCL β GP4
| ESP32 | VL53L1X |
|---|---|
| GP5 | SDA |
| GP4 | SCL |
| 3.3V | VIN |
| GND | GND |
The single sensor is enabled during boot through XSHUT.
| ESP32 GPIO | Sensor | Connects to |
|---|---|---|
| GP6 | Sensor 0 | XSHUT pin |
ESP32 TWAI uses dedicated GPIOs for CAN TX/RX.
| ESP32 GPIO | Connects to |
|---|---|
| GP9 | CAN TX / TWAI TX (to transceiver) |
| GP10 | CAN RX / TWAI RX (from transceiver) |
One WS281x LED is connected to GP21 and uses FastLED at 50/255 brightness:
| Distance | LED behavior |
|---|---|
0 mm |
Solid red (invalid/timeout reading) |
1β50 mm |
Red blink at 50 Hz |
51β999 mm |
Red blink rate scales linearly from 50 Hz down to 0 Hz |
β₯1000 mm |
Off |
The sketch requires ESP32-S3 native USB CDC. In the Arduino IDE, select Tools β USB CDC On Boot β Enabled before compiling and uploading. Serial then outputs through the board's USB-C connector at 115200 baud.
The CAN device number is persisted in EEPROM and defaults to 50 when EEPROM is uninitialized. Send one of these newline-terminated commands through USB serial:
| Command | Result |
|---|---|
&CANID SET <0-63> |
Changes the running device number immediately. |
&CANID SAVE |
Persists the running device number and reboots the board. |
&CANID GET |
Reports the running, saved, and default device numbers. |
i2cScanner.ino is a standalone scanner for the same GP5 (SDA) and GP4 (SCL) bus. It reports detected IΒ²C addresses over USB serial at 115200 baud every two seconds.
-
One frame for Sensor 0.
-
Payload (8 bytes):
Byte 0β1: Distance (uint16_t, mm)
Byte 2: Ranging mode (0 = Short, 1 = Medium, 2 = Long)
Byte 3: ROI center (uint8_t)
Byte 4: ROI size X (width)
Byte 5: ROI size Y (height)
Byte 6β7: Measurement timing budget (uint16_t, Β΅s / 1e3 resolution)
Note: Timing budget is truncated to 16 bits (up to ~65ms).
-
One configuration frame for Sensor 0.
-
Payload (4 bytes):
Byte 0: Ranging mode (0 = Short, 1 = Medium, 2 = Long)
Byte 1: ROI center (uint8_t)
Byte 2: ROI size X (4β16, must be even)
Byte 3: ROI size Y (4β16, must be even)
Only one config frame should be sent per 200 ms to allow a safe I2C update delay.