Go Down

Topic: Using Adafruit VL53L0X on DUE I2C (Two Wire) bus (Read 123 times) previous topic - next topic

mkosler

Just wanted to share

I was successful in using the VL53L0X on the Arduino UNO. I needed to upgrade the controller because of the size of the program

I acquired an Arduino DUE and I could not get the VL53L0X to work reliably on pins 20 SDA & 21 SDL. The sample program would run for a little while and stop. I actually heard a high pitch squeal from the DUE  each time the program called for a measurement.  The VL53L0X has pull up resistors on the SDA and SCL signal lines and worked well with the UNO because the UNO does not have pull up resistors on the SDA and SCL signal lines. The DUE does have pull-up resistors on the SDA and SCL lines so when the DUE tried to communicate with the VL53L0X for a measurement, the combination of two pairs of pull-up  resistors had a negative effect on the I2C signal and the system would stop communicating.

The DUE has a second I2C buss on pins 70 SDA1 and 71 SCL1 that do not have pull-up resistors. To use the alternate I2C buss I had to make changes to three files.

In the Adafruit_VL53L0X.cpp file, I changed line 25 from "Wire.begin()" to "Wire1.begin()", and changed the comm speed in line 23 from 400kHz to 100 kHz. (I'm not convinced the change of speed made alot of difference, you can experiment with this)

In the VL53L0X_comms.cpp file, I changed 10 lines that contained instances of "Wire" to "Wire1".

In the Wire.cpp file, I added a line at the bottom "TwoWire Wire1 = TwoWire();"


After making these changes, cycling power on the DUE, recompiling and loading the DUE, the VL53L0X sample program worked reliably on the SDA1/SCL1 I2C buss.

Thanks to folks on other forums who gove me some clues that helped me solve this problem.

Hope this help others who are trying to use the alternate I2C buss for VL53L0X and other I2C (Two Wire) devices

 
 

mkosler

filename Correction

In the VL53L0X_i2c_comms.cpp file, I changed 10 lines that contained instances of "Wire" to "Wire1".

Go Up