Electronic – I2C sometimes works sometimes doesn’t

i2c

I am trying to troubleshoot communication between Arduino (master) and 3 slave sensors (VL53L0X):

Overview

Below is VL53L0X sensor module I am using. I checked and confirmed that the placement of resistors and capacitors are as recommended by each components' datasheet. XSHUT is a pin on VL53L0X that shuts the sensor down when it is low (active low). When the sensor first boots up, its I2C address is set to its default value, so XSHUT is used to change this address by booting VL53L0X one by one and modifying the address of only one sensor at a time.

enter image description here

Below is schematic of the circuit on the breadboard. I am using 4K7 pullup resistors for I2C. (Sorry I am still learning and I used PowerPoint because schematics software is still difficult for me)

enter image description here

I can reliably communicate with only 1 sensor attached. It worked with 2 sensors attached today (but I was not able to do so yesterday). I ultimately want to connect 3 sensors. When I connect the third sensor as shown above, it stops working and I cannot communicate with any sensor.

Below is oscilloscope measurement with only 2 sensors attached and the 3rd sensor completely disconnected (this worked today). Channel 3 is XSHUT and channel 4 is 5V.

2 sensors

Zoomed in:

2 sensors zoom in

Below is oscilloscope measurement with the 3rd sensor attached with its XSHUT pin connected to ground and SCL/SDA/5V connected as shown in breadboard schematic above:

3 sensors

Zoomed in:

3 sensors zoomed in

It looks like it is working for a while and then suddenly fails in the middle. Once it fails, I have to reset the microcontroller. The point at which it fails varies every time. None of the sensors are broken because they work when connected individually. 5V and XSHUT line look stable. I tried increasing and decreasing the resistance of the pull-ups but did not really help. The oscilloscope also seems to affect the communication (seems to work better when probing) so something about my setup is very fragile (susceptible to small external influence). Could someone point me to where I should look? Thank you.

Best Answer

You have a breadboard in the middle of a whole bunch of things operating at fairly high speed.

This is just asking for things not to work.

Breadboards have wiggly contacts, inviting glitches in your signals and power supplies.

Breadboards have capacitance between all the pins, inviting crosstalk between lines and causing slower rise times on the edges of your signals.

Try the following:

  1. Use a lower data rate. Your modules support up to 400kbit, but you don't have to run them at full speed.

  2. Use shorter wires, and make sure they make good contact with your breadboard.

  3. Consider soldering the connections instead of using a breadboard. Soldering isn't that difficult to learn.