Hi everyone, I have an architecture on which I would like to have your opinion. I have to work with some hall sensors, specifically the Adafruit_Mlx90393 with communicate in I2C and have two changeable bits for modifying the I2C address, basically on the sensors side I can change the address by soldering to Vcc or GND the two pins, in total I can therefore have 4 different addresses. In my application I need to communicate with 32 sensors, I thought to divide them into 4 groups of 8 sensors, so basically, the 8 sensors belonging to a group will have the same I2C address, in order to then read each of them I want to use a TCA9548A multiplexer for each group to get an array of the 8 reading coming from each group. So far I have experience with using a TCA9548A mux for reading multiple sensors with the same address however it is not clear to me how to deal with multiple TCA9548A muxes, I know that they have three pins to change their address so I guess that I will call each of the four muxes with a different address and then switching between the sensors belonging that group right?
Welcome to the forum!
Your question is general enough that we can answer it with generalities, but if you desire more information please refer to
for guidance.
Sounds right, so why not try it and report back to us? Though, unless you'll add even more later, I'd have put 4 on each sub-bus and used a single multiplexer; it would be full, but there should be less overall reading delay working with a single mux; that may not matter in your application, though.
Remember the pullups for each and every sub-bus. I've not used the 9548, but I expect you'd end up with nested loops to address each sub-bus, then cycle through the 4 devices on that bus, then change sub-bus, etc. etc.
hi thank for you reply, how can it work with a single multiplexer?
You said each sensor has a possibility of 4 addresses by jumpering. If each sub-bus of the 9548 had 4 devices on it, how many devices could you have? 4x8 = 32.
ok so you are saying that it is better to have 8 groups of 4 sensors? It would be better due to the fact that i have less delay?
Any time you need to change sub-bus, of course there's going to be a delay. Adding another layer of bus-swapping is obviously going to add delay, not to mention complexity at the software level.
I'm very confused that you don't see this.
If you will never contemplate expanding beyond 32 signals, I'd definitely re-organize, but quite frankly, this should all have been worked out on a breadboard by now. Are you still at that stage? Then do it. If you're locked into a hardware design, go with it.
What is your sensor update requirement? As fast as possible? Is there a design behind all this?
ok i skecthed the two scenarios, so the second option would be faster right? Ya I would like to read the sensors "as fast as possible", each sensor provide a reading every 20ms
Building a circuit with one TCA9548A will be much much simpler and cheaper than building one with four.
The circuit with Mux1 only is what I'm suggesting. That image appears first, not second.
Not sure what you're thinking, but it seems like you think you can somehow read more devices in parallel with 4 muxes. IRL, you are reading each one sequentially by selecting first the Mux setting, then querying each device on that mux, then setting the mux, then querying each device, etc. and so on. Otherwise, show us your code that does multiples in parallel simultaneously, because AFAIK, it is not possible to do so.
-edit- Wait a minute - do you have a processor with 4 hardware I2C busses? Is that what you're trying to do? What processor are we using?
-nevermind- more coffee required here. Confused me with 4 separate connections to the "micro".
You have 8 sub-busses from the 9548. Each of those busses can have 4 devices, as they have 2 address pins. Each of the sub-busses must be talked to serially, and each of the devices on those busses must be talked to serially to get the data from each of the 4 devices. So you need 1 mux, and 32 devices. You DO NOT hardwire A0,A1,A2, you drive them with three outputs from your 'micro'.
In a loop that iterates 8 times,
- select a sub bus by setting A0/A1/A2 appropriately
- extract the data from the four devices on that bus, which must have unique I2C addresses
- loop
No the first would be faster. You only need to switch mux channels 8 times as opposed to 32 times with the second option
ok now i understand why the option with just one mux is better. Thank you. However for answering you, I will use a ESP32 micro with just one I2C bus, as you said I will connect 4 sensors to each sub-ubs of the mux, each sensor with an unique address. I will repeat this 8 times switching the sb-ubs.
@anomi_77
Glad I could help
Have a nice day!
@anomi_77 I see you removed your two sketches, which makes the thread essentially useless for anyone trying to make sense of this. In future, please don't do that.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.