TF03 Lidar and Arduino: Difference between revisions

From wikiluntti
(Created page with "== Introduction == Long Manual https://acroname.com/sites/default/files/assets/tf03_product_manual_v0.4_en.pdf TF (ToF; Time of Flight). https://www.sparkfun.com/products/19421 * Range ~100 m * Resolution ~0.01 m/ Accuracy 0.1 m. * Frame rate 1Hz - 1000 Hz * wavelength: 905 nm. Laser class 1 (IEC 60825) * Angle 0.5 deg; Spot size @100 m 28x28 cm2. * Current ˝200 mA. Power ~1W * Dimensions 44x43x32 mm3. * Weight 77g * IP67 * Mounting holes for M3 screws * Connector: M...")
 
Line 117: Line 117:


== Software Serial ==
== Software Serial ==
However, according https://arduino.stackexchange.com/questions/91215/how-to-read-and-parse-uart-data-from-human-presence-radar-sensor Software Serial should not be used:
* against using SoftwareSerial, especially at this high baud rates: it is a recipe for problems.
* Connect the sensor's TX to the Arduino RX, and you will be able to read the sensor data with Serial.read().
* Do not connect the sensor's RX, and you will be able to Serial.print() to the serial monitor without disturbing the sensor.
*
<syntaxhighlight lang="C">
void setup() {
  Serial.begin(115200);
}
void loop() {
  Serial.print("Available: ");
  Serial.println( Serial1.available() );
  incomingByte = Serial1.read();
  Serial.println( incomingByte, HEX);
  if (Serial1.available() > 0){  // returns the number of bytes waiting in the buffer
    incomingByte = Serial1.read();
    //Serial.println( incomingByte, DEC);
  }
}
</syntaxhighlight>

Revision as of 10:16, 13 February 2024

Introduction

Long Manual https://acroname.com/sites/default/files/assets/tf03_product_manual_v0.4_en.pdf

TF (ToF; Time of Flight). https://www.sparkfun.com/products/19421

  • Range ~100 m
  • Resolution ~0.01 m/ Accuracy 0.1 m.
  • Frame rate 1Hz - 1000 Hz
  • wavelength: 905 nm. Laser class 1 (IEC 60825)
  • Angle 0.5 deg; Spot size @100 m 28x28 cm2.
  • Current ˝200 mA. Power ~1W
  • Dimensions 44x43x32 mm3.
  • Weight 77g
  • IP67
  • Mounting holes for M3 screws
  • Connector: Molex 1.25 or Molex SD-51021-007 (1.25 W/B) 7 pin or mh1.25-7p. Pin to pin pitch is 1.25 mm. Identity electrical connectors: https://core-electronics.com.au/guides/Identify-Electrical-Connectors/#Molex

See more


Need to measure angle. Use an accelerometer

Note the laser safety. Check whether the power supply is working properly, and whether the voltage level is kept within the range of the rated input voltage. If the power supply is normal, the TF03 lens will display a faint red light.


Pin definition
No Color Standard: Pin Standard: Function RS485: PIN RS485: Function
1 Red Vcc Power Vcc Power
2 White CAN_L CAN_L RS485-B/RS232-RX Receive
3 Green CAN_H CAN_H RS485-B/RS232-TX Transport
4
5 Blue UART_RX Receive UART_RX Receive
6 Brown UART_TX Transport UART_TX Transport
7 Black GND Ground GND Ground

The standard version of TF03 supports both, UART and CAN communication interface. The default interface is UART. The CAN mode can be set by sending command, but two interfaces cannot output simultaneously.

The default TX/RX pins on an Arduino board are the D0(RX) and D1(TX) pins.


TF03 serial data format
Data bit Definition Description
Byte0 Frame Header 0x59
Byte1 Frame Header 0x59
Byte2 DIST_L DIST low 8-bits
Byte3 DIST_H DIST high 8-bits
Byte4 Reserved
Byte5 Reserved
Byte6 Reserved
Byte7 Reserved
Byte8 Checksum Checksum = Byte0 + Byte2 + ... 0 Byte7

Lidar & Arduino

Connections

  • Arduino: D0 (RX), TF03: 6 (Brown, UART TX)
  • Arduino: D1 (TX), TF03: 5 (Blue, UART RX)

The serial port version of TF03 adopts UART-LVTTL interface, and the output level is LVTTL level (0-3.3V).


Lidar Voltage: 5 - 24 V (https://cdn.sparkfun.com/assets/2/c/5/6/0/Benewake_10152020_TF03_100-1954064.pdf); Current 150 mA @ 5V, 80 mA @ 12V, 50 mA @ 24 V. Power consumption: 1 W.

Communication protocol UART

  • Baud rate 115200
  • Data bit 8
  • Stop bit 1
  • Checksum bit None
void setup(){
  Serial.begin(9600);
  Serial1.begin(11200);
}
void loop(){
  while (Serial1.available() > 0) {
    char receivedChar = Serial1.read();
    Serial.println(receivedChar);  
    }
  }}

See also https://lastminuteengineers.com/tfmini-s-lidar-sensor-arduino-tutorial/

Reading Digital Pins

TX/RX pins

Software Serial

However, according https://arduino.stackexchange.com/questions/91215/how-to-read-and-parse-uart-data-from-human-presence-radar-sensor Software Serial should not be used:

  • against using SoftwareSerial, especially at this high baud rates: it is a recipe for problems.
  • Connect the sensor's TX to the Arduino RX, and you will be able to read the sensor data with Serial.read().
  • Do not connect the sensor's RX, and you will be able to Serial.print() to the serial monitor without disturbing the sensor.
void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.print("Available: ");
  Serial.println( Serial1.available() );
  incomingByte = Serial1.read(); 
  Serial.println( incomingByte, HEX);

  if (Serial1.available() > 0){  // returns the number of bytes waiting in the buffer
    incomingByte = Serial1.read(); 
    //Serial.println( incomingByte, DEC);
  }
}