Waveshare ToF (UART) not displaying any data

Since this topic TOF Laser Sensor won't connect and output data has been closed and won't allow any more comments, so I have been facing same issue and wasn't able to figure out how to solve it?

  1. I am using an Arduino Mega 2560

I am fairly new to using the Waveshare ToF sensor. I went through their documentation and followed similar connections but no success.

  1. I started off with the implementation of demo code, which is mentioned in waveshare documentation but no data is being displayed over Serial monitor or the TOFAssistant software which constantly displays 'recognize failed'. (I believe a UART adapter might help in this scenario but I don't have any as of now)

Questions:

  1. I still don't understand the problems that are there and how to resolve it?
  2. How should I display the data over the Serial Monitor without using the ToFAssistant software?
  3. If not UART, how should I proceed with I2C?

Help Needed!

how have you connected the sensor to the Mega?
upload the test ptogram you used?

Hi @horace
I have connected the sensor to the Mega and also uploaded the test program (demo code from waveshare)

Sensor Pin | Mega PIn
TXD | 11
RXD | 10
GND | GND
VCC | 5V

are you using SoftwareSerial or AltSoftSerial?
why have you selected pins 10 and 11
recommend using hardware serial, e.g. Serial1 TX pin18 and Rx pin 19
give a link to the demo program?

I am using SoftwareSerial. Also, have set the baud rate to 115200.
I have selected 10 and 11 following the waveshare doc.

Here is the link: TOF-Laser-Range-Sensor. If you scroll down you'll find the demo code .zip there.

SoftwareSerial has problems operating over 38400baud also transmitting and receiving at the same time
recommend you the Mega Hardware Serial port Serial1

e.g. delete or comment out the following two lines

#include <SoftwareSerial.h>
SoftwareSerial Serial1(11,10); //Serial1 connected to TOF Serial:10<-->RX, 11<-->TX

and connect TOF to Serial1 TX pin18 and Rx pin 19

That won't work. Use hardware serial instead.

TOF_ranging_test.ino (2.7 KB)

I have attached the updated code here but I still don't see anything over the Serial Monitor making sure that the baud rate is 115200.
@jremington Could you please share the modified code, if you had any success running it?

Did you change the wiring to match the Serial1 pins? Are the grounds connected?

Please post a complete wiring diagram (hand drawn is preferred).

This is what I have followed right now making sure that the connections are not loose.

According to the drawing, you have swapped the RX/TX connections.

I changed the connections (swapped it), but still had no success.

Maybe the TOF module is defective. Contact Waveshare, or the seller.

Look at documentation,
default baud rate:

I am currently following the code that Waveshare has mentioned in their documentation, with the only update of using hardware serial over software serial.

This is one of the reddit posts that I followed: UART - TOF and was receving some output but then again couldn't understand on how should I proceed next?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.