Table of Contents

LamaPLC: Waveshare TOF Laser Range Sensor with UART / I²C communication

Waveshare TOF (time of Flight) Laser Range Sensor

Core Product Comparison

Waveshare offers several versions to match different distances and environmental requirements:

ModelRangeAccuracyInterfaceBest For
Standard TOF0.01 – 5m±1.5cmUART / CANIndoor robots, obstacle avoidance
TOF (B)0.10 – 15m±2%UART / I2C Long-range indoor/outdoor use
TOF (C)0.05 – 25m±3cmUART / I2COutdoor navigation, material levels
TOF (D)0.05 – 50m±3cmUART / I2CExtreme long-distance detection
TOF Mini0.02 – 7.8m±4cmUART / I2CUltra-compact builds (1g weight)

Key Technical Features

SpecificationData
Typical measuring range0.05..25 m / 0.05..50 m
Measuring accuracy+-3 cm
Wavelength905 nm
Field of view1°..2°
Communication interfacedefault: UART (3.3V TTL)
I²C Addr: 0x08
BaudrateUART: 4.8 kbps .. 3000 kbps (921.6 kbps default)
I²C: up to 400 kbps
Power supply4.3 .. 5.2 V
Power consumption250 mW (UART active output, 5.0 V power supply, 50 mA current)
Operation temperature-10 °C .. 60 °C

If you'd like to support the development of the site with the price of a coffee — or a few — please do so here.

Here's a handy tip: you can quickly save this page as a PDF by clicking “export to PDF” in the menu on the right side of the screen.

2026/02/14 22:38

Wiring Diagram (UART)

The sensor operates at 3.3V TTL signal levels, but the module has voltage translation for 5V compatibility.

Waveshare PinArduino Uno/Nano PinDescription
VCC5V (or 3.3V)Power Supply
GNDGNDGround
TXD10Arduino RX (SoftwareSerial pin)
RXD11Arduino 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.h>
 
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;
}

This page has been accessed for: Today: 1, Until now: 62