I2C with 5V Lidar, Levelshifter and Arduino Due not working properly


I am currently having some trouble concerning the I2C connection between my Garmin Lidar Lite v3 (Datasheet) and my Arduino Due.

I've already made a post in the German Forum, but unfortunately nobody was able to help me beyond my current configuration (for pictures see attachment):

The Lidar is connected to 5 V and GND with a parallel 680 uF capacitor as the datasheet suggests. The SCL and SDA pins of the Lidar are connected to the HV channel pins of a bidirectional levelshifter with integrated 10 kOhm pullup resistors on each side (HV and LV). To reduce these pullup resistors I have connected 2 kOhm resistors in parallel to each pin on each side of the levelshifter, so that the total pullup resistor value is 1,666 kOhm on each side. The levelshifter is obviously connected to 5 V and GND on the HV side and to 3.3 V and GND on the LV side. The LV channel pins are connected to the pins "SCL1" and "SDA1" of the Arduino Due.

I have mesaured the I2C Signal of the configuration above with an analog oscilloscope and it looks as follows:

400 kHz I2C Clock signal:

100 kHz I2C Clock signal:

I can't get the standard I2C Pins 20 and 21 to work somehow, maybe I damaged them earlier during my experiments. That's why I have also changed the file "LIDARLite.cpp" in the Lidar's library and added "#define Wire Wire1". I also added this to the example script of the Lidar.

Still, even though the signal looks good to me, I can't seem to get the connection to work. The Lidar script still only shows "nack" in the serial output.

I would be very grateful if you can help me. Please write your suggestions beginner friendly, because I started working with Arduinos less than a month ago.

Edit: I just noticed that the green cable to the Arduino wasn't connected to SCL1 on the first picture, that was obviously not the case yesterday when I measured the signal above :smiley:

Reseting the I2C bus after I2C initialization and every time the bus hangs might help. In the topics below, you will find an I2C bus Rest function and some hints to reduce EMI effects on the bus (usually the major issue to solve) and be careful with cable length:

The wire library is not properly designed for the DUE, but there are workarounds.

Thanks for the quick answer! I will look into your links now and try to figure something out.

I also forgot to mention that the Lidar works completely fine with my Arduino Uno, even without any additional pullups resistors.

I have tried to put a 10 Ohms resistor in series to the Arduino SCL1 and SDA1 Pins to reduce EMI, but it didn't seem to make a change. The rest of your answer is too complex for me tbh, I am not quite comfortable to change the Lidar Library in the way you presented in one of your links. I also tried the example script in one of your answers (and connected SDA with SDA1 and SCL with SCL1), which didnt work for me, because my pins on 20 and 21 are probably damaged.

Alltogether is seems like the Due isn't a good choice for my project, because the measured distance values have to be very consistent. I think I will proceed with another Arduino with an operating voltage of 5V as suggested in the german thread.

Thanks anyway :slight_smile: