====== LamaPLC: Waveshare TOF Laser Range Sensor with UART / I²C communication ====== {{ :sensor:waveshare_tof_1.png?120|}} * [[com:basic_uart|UART]] / [[com:basic_i2c|I²C]] / [[com:basic_can|CAN]] / IO Communication Support, 25m / 50m Measuring Range * This is a TOF-based (//time of flight//) laser ranging sensor with embedded MCU and ranging algorithm, which is capable of offering up to 25m / 50m measuring range, and ±3cm accuracy. * It supports UART or I²C communication bus, features longer measuring distance and higher light interference tolerance capability due to its ultra-narrow FOV, suitable for either indoor or outdoor conditions. Its ambient light tolerance is up to 100K lux. * This sensor can be widely used in applications like standard distance measuring, robot obstacle avoidance/route planning/ceiling detection, and more... * long range low cost ranging module, high stability, high accuracy, high sensitivity ranging; UART / I2C / IO communication support UART mode: supports active query output I²C mode: up to 8x cascades I/O mode: unable to output distance parameter {{ :sensor:waveshare_tof_2.png |Waveshare TOF (time of Flight) Laser Range Sensor}} **Core Product Comparison** Waveshare offers several versions to match different distances and environmental requirements: ^Model^Range^Accuracy^Interface^Best For| |Standard TOF|0.01 – 5m|±1.5cm|UART / CAN|Indoor robots, obstacle avoidance| |TOF (B)|0.10 – 15m|±2%|UART / I2C Long-range indoor/outdoor use| |TOF (C)|0.05 – 25m|±3cm|UART / I2C|Outdoor navigation, material levels| |TOF (D)|0.05 – 50m|±3cm|UART / I2C|Extreme long-distance detection| |TOF Mini|0.02 – 7.8m|±4cm|UART / I2C|Ultra-compact builds (1g weight)| **Key Technical Features** * **Cascading Support:** Up to 8 sensors on UART and 7 on CAN can be connected in series to a single bus, each assigned a unique ID. * **High Ambient Light Resistance:** Most "B," "C," and "Mini" models resist up to 100K LUX, making them functional in direct sunlight. * **Configurable FOV:** The standard model offers an adjustable Field of View (15° to 27°), while long-range models feature a narrow FOV (1° to 2°) to minimize interference. * **Integrated Processing:** Includes an embedded MCU and ranging algorithm, providing filtered distance data rather than raw phase shifts. * **Software Tools:** Waveshare provides a PC Assistant Software for real-time waveform monitoring, configuration, and data recording. ^Specification^Data| ^Typical measuring range|0.05..25 m / 0.05..50 m| ^Measuring accuracy|+-3 cm| ^Wavelength|905 nm| ^Field of view|1°..2°| ^Communication interface|default: UART (3.3V TTL) \\ I²C Addr: 0x08| ^Baudrate|UART: 4.8 kbps .. 3000 kbps (921.6 kbps default) \\ I²C: up to 400 kbps| ^Power supply|4.3 .. 5.2 V| ^Power consumption|250 mW (UART active output, 5.0 V power supply, 50 mA current)| ^Operation temperature|-10 °C .. 60 °C| {{page>:tarhal}} ==== Wiring Diagram (UART) ==== The sensor operates at 3.3V TTL signal levels, but the module has voltage translation for 5V compatibility. ^Waveshare Pin^Arduino Uno/Nano Pin^Description| ^VCC|5V (or 3.3V)|Power Supply| ^GND|GND|Ground| ^TX|D10|Arduino RX (SoftwareSerial pin)| ^RX|D11|Arduino TX (SoftwareSerial pin)| ==== Arduino Example Code (UART Communication) ==== This example utilizes the SoftwareSerial library to actively read distance data from the sensor, which outputs at the default baud rate of 115200. #include SoftwareSerial TOFSerial(10, 11); // RX, TX pins for the sensor unsigned char TOF_data[32] = {0}; // Buffer to store the data frame unsigned char TOF_length = 16; unsigned long TOF_distance = 0; unsigned char TOF_check = 0; void setup() { Serial.begin(9600); // Initialize hardware serial for monitoring TOFSerial.begin(115200); // Initialize software serial for the sensor Serial.println("Waveshare TOF Sensor Test"); } void loop() { if (TOFSerial.available() > 0) { // Read the incoming bytes from the sensor if (readTOFData()) { Serial.print("Distance: "); Serial.print(TOF_distance); Serial.println(" mm"); } } } // Function to read and parse the data frame based on Waveshare protocol bool readTOFData() { if (TOFSerial.available() >= TOF_length) { for (int i = 0; i < TOF_length; i++) { TOF_data[i] = TOFSerial.read(); } // Verify the checksum TOF_check = 0; for (int k = 0; k < TOF_length - 1; k++) { TOF_check += TOF_data[k]; } if (TOF_check == TOF_data[TOF_length - 1] && TOF_data[0] == 0x57) { // Check header 0x57 // Data is valid. Distance is a 3-byte value (little-endian) TOF_distance = (TOF_data[8]) | (TOF_data[9] << 8) | (TOF_data[10] << 16); return true; } } return false; } {{tag>distance_measurement laser range sensor TOF Waveshare }} This page has been accessed for: Today: {{counter|today}}, Until now: {{counter|total}}