I’d like to use multiple ToF sensors (V6180 & Vl53L1) on RPI. It works independently on RPI, but when I tried to sense together it gives wrong values. It seems that pull-up resistors issues. So, here are what I did so far:
Remove pull ups for both sensors, e.g., cut pull up pattern based on instruction.
One pull up left, but the other are cutted.
However, the above trials didn’t work properly. Anyone can have a similar issue and suggest solutions?
You need one set of pullups on the bus for I2C to work, you might get away with a few but you need at least one. Using too many pullups will cause the I2C bus to fail.
The reason you’re running into issues is because you can’t have more than one device on the I2C bus with the same address at a time. Pretend you have 5 of the same sensor, we will call him Bob. If all 5 are connected to the bus and you say “Hey Bob, what reading are you receiving?” and all 5 sensors are going to respond all at the same time. With 5 people all talking at once, you’re not going to be able to understand what any of them are saying, it will just sound like gibberish.
Now you could put a second sensor in the same room as Bob too as long as that sensor has a different name. (I.E. different address!) Bob and Doug could both peacefully coexist together in the same room because when you ask Bob for a reading, Doug will stay silent and when you ask Doug for a reading Bob will stay silent.
Now, pretend your in a hallway with 5 doors and there’s a Bob behind every door. You could open the first door and say “Hey Bob, what reading are you receiving?” and that one Bob would respond, you say “Thanks!”, shut the door and you’d have your data. Then you could then move onto the next door and ask the next Bob what his reading was until you’ve visited every room.
But, how do you do that electronically?
What you’re looking for is a MUX. A MUX is like that hallway with those closed doors, you instruct the MUX to open the door to the sensor you want to speak too, ask it for it’s data and then you close the door and open the next. We carry a board called the [Qwiic MUX that will do just this.
Now we don’t have example code for using this with a Pi, but the commands are pretty simple, you just command the MUX to change channels and it switches to a different port. The Arduino examples should be enough for you to figure out how to write your Pi code to use the MUX.](SparkFun Qwiic Mux Breakout - 8 Channel (TCA9548A) - BOB-16784 - SparkFun Electronics)
Thank you for a quick and understandable response. I thought since those sensors use different addresses, mux is not needed. I’ll try to do with a mux solution you suggested. Thanks.
Thank you for the response. Just a quick question for it. Does mux need for multiple devices that are not using the same address, e.g., one is V6180 and another is Vl53l1x. Thank you.
TS-Chris:
You need one set of pullups on the bus for I2C to work, you might get away with a few but you need at least one. Using too many pullups will cause the I2C bus to fail.
The reason you’re running into issues is because you can’t have more than one device on the I2C bus with the same address at a time. Pretend you have 5 of the same sensor, we will call him Bob. If all 5 are connected to the bus and you say “Hey Bob, what reading are you receiving?” and all 5 sensors are going to respond all at the same time. With 5 people all talking at once, you’re not going to be able to understand what any of them are saying, it will just sound like gibberish.
Now you could put a second sensor in the same room as Bob too as long as that sensor has a different name. (I.E. different address!) Bob and Doug could both peacefully coexist together in the same room because when you ask Bob for a reading, Doug will stay silent and when you ask Doug for a reading Bob will stay silent.
Now, pretend your in a hallway with 5 doors and there’s a Bob behind every door. You could open the first door and say “Hey Bob, what reading are you receiving?” and that one Bob would respond, you say “Thanks!”, shut the door and you’d have your data. Then you could then move onto the next door and ask the next Bob what his reading was until you’ve visited every room.
But, how do you do that electronically?
What you’re looking for is a MUX. A MUX is like that hallway with those closed doors, you instruct the MUX to open the door to the sensor you want to speak too, ask it for it’s data and then you close the door and open the next. We carry a board called the [Qwiic MUX that will do just this.
Now we don’t have example code for using this with a Pi, but the commands are pretty simple, you just command the MUX to change channels and it switches to a different port. The Arduino examples should be enough for you to figure out how to write your Pi code to use the MUX.
[/quote]](SparkFun Qwiic Mux Breakout - 8 Channel (TCA9548A) - BOB-16784 - SparkFun Electronics)