I2C communication between TFMini-s Micro LiDAR and Arduino MKR Wifi 1010

I’ve connected recently bought TFMini-s Micro LiDAR and connected it to my Arduino MKR Wifi 1010 and am having difficulties getting it to read data.

I’ve downloaded and tried the examples from the following libraries with no success:
TFMPI2C
TFMPlus
TFminiArduino
TFMini

The first library listed has two examples that I’ve tried. In the first example the code get’s stuck in a RecoverI2CBus loop. The second example is seems to be used to change the default address of the LiDAR, which I did as this code listed the connected I2C address as 0x60, so I changed the code in the first example to reflect this.

The TFMPlus example seems to lock up after Serial.println( "Soft reset: ");

I don’t believe the last two libraries are compatible with this LiDAR.

The LiDAR LED is on when USB is connected so it is getting power.

The Arduino board has a MPU-6050 accelerometer connected also which still functions over I2C so I’m assuming its no the SDA/SCL ports.

I have read in other Forums (Arduino/Stack Exchange) that I2C is not the factory communication protocol for this LiDAR, it’s actually UART. Looking at the examples from those first two libraries it looks as though this shouldn’t be an issue? Are these libraries not suitable for my Arduino Board?

Appreciate any assistance

1 Like

Hi Lyndsay,

Looks like you are correct - the default communication interface seems to be serial.

The first thing I would do is to make sure that the individual parts of your system are functioning properly.

  1. Do a loopback test on your Arduino to make sure your serial interface is working properly:
void setup() {
  Serial1.begin(115200); //start UART
  Serial.begin(9600); //start USB serial
  Serial1.print("test"); //print a string
  delay(10);
  String incomingByte = Serial1.readString();
  Serial.print(incomingByte);
}

void loop() {

}

Connect your TX pin to your RX pin (13 to 14 on your board), and run the above code, hopefully you should see “test” in your Serial Monitor

  1. If that goes ok, plug your Arduino into your LiDAR and try sending 5A 04 01 5F over Serial1 and see what it comes back with. If it comes back with something, your sensor is alive and we can proceed to finding a library

(should be something like this, however I don’t have your gear on the bench here:)

byte message[] = {0x5A, 0xBB, 0x04, 0x01, 0x5F};
Serial1.write(message, sizeof(message));

I pulled that message from the manual

Let us know how that goes, and we’ll get to the bottom of this!

-James

Hi James,

Thank you very much for the initial help. The initial ‘test’ worked jumpering the UART ports and I’ve attached the code and the reply from the LiDAR. Not sure what to expect as they reply though.

Cheers,

Lindsay