TF02 Lidar is printing out garbage in on the raspberry pi. I am using a program called minicom that is a linux program and the setting for the baud rate is 115200 data bit is 8 stop bit is 1 yet when I run minicom I only see garbage characters get printed across the screen only on one line. I am using a EZSync FTDI chip USB to 5v TTL UART Serial Cable to connect the Lidar to the raspberry pi. I have the TXD and the RXD crossed between the Lidar and the cable. Please help. . …
Hi @eric_6935,
Welcome to the RobotShop community!
It seems like what you are getting is the binary data printed in ASCII form (i.e.: garbage characters).
Please have a look at section 9 of the datasheet for the TF02 (pages 8-10). You’ll notice that the sensor sends back frames that are typically 9 bytes longs. These frames have a header, distance info, signal strength ino, reliability, exposure time and even a checksum to ensure integrity/validity of the data.
While minicom is great to interact with devices that use verbose commands in ASCII, the TF02 works with a high-speed binary protocol. Minicom is the wrong tool to use with the TF02 aside from confirming your device is working and spitting out data.
If you are only trying to test out the device then please see the demo program available here.
As for using the TF02 on your Rpi, you’ll need to program a software to read the frames properly. This is obviously outside the scope of the help I can provide, but the code here should be a good example/starting point to understand what needs to be done.
Sincerely,
Hi @scharette,
Thank you so much for informing me of this. I have been trying to figure out what was going on and I was thinking my cable was wrong or the device itself was defective and mixing up the data. Yes I would love to see this data translated to something that is human readable. Something I can use to measure distance. The raw bytes are not enough for me to do so. The RB-Ben-01.ino file, can you tell me how I can run that on the raspberry pi. My end goal is to run a python script and view this most wanted and desired data but that is becoming very elusive to me. Thanks in advance for your help. . . .
Hey,
The .ino is for Arduino and therefore won’t run on the RPi directly. But, as mentioned above, is a good starting point to understand how to read binary data from a serial port.
You’ll have to create a script/code to read the binary data and display it in a human readable format. The datasheet is your best friend here. That protocol page had all the details about the data packets.
The typical process, has shown in the Arduino example is as follow:
- Ensure there is data available.
- Read said data (read 1 packet, effectively).
- Confirm it is good (using CRC). This step can be optional, but recommended for reliability.
- Extract the wanted data from the packet and display it.
As for how to do this exactly you’ll have to start learning serial port use in Python! There’s plenty of tutorials and examples online though, so it should be easy to find some resources, such as these:
- https://www.instructables.com/id/Benewake-LiDAR-TFmini-Complete-Guide/
- https://github.com/TFmini/TFmini-RaspberryPi (not directly related but can offer some insights)
I hope this helps!
Sincerely,