I would like to connect multiple sensor to a board; altho they are the same type, so they have the same address for I2C.
I was told that there are multiplexer that does the job, is that the only solution ? Who would I have to structure the hardware and software to obtain that all the sensor are read one after another?
I was looking for example shut found none that fits my case.
You don't say what the sensor is, but are you sure you can't change the address on one of them? I'm no expert but I know some devices (like EEPROM) have address lines.
Did you see this thread, particularly CrossRoad's suggestion in reply#3?
Things go OOS all the time, no biggy, they invariably CBIS 8) unless they're obsolete. It was in any case just an example, there may be other similar devices, or same device might be available somewhere else.
I am planning to use invesense all in one sensors; so either the old 6050 or the new 9150
They have a register that can be changed, which limit you to 2 max sensor per channel. Either you get more channels, or multiplex them I guess.
Reading the suggested thread; I believe it is similar to what I want to do; Thanks!
Any reference to how the code should look like, when using a multiplexer, and what kind of multiplexers can be used? First time attempting this, and many multiplexer seems to have issues with i2c (saw a couple on spark fun and adafruit).
Plenty of chips in stock at digikey - get a breakout board and wire up your own adapter
Can use an analog switch for SDA lines, use address lines to select 1 of x channels to be active - connect SCL to all devices. Make sure your devices can handle the extra series resistance of the switch, such as DG401, DG406, DG408
The quality of the answer you get is directly related to the quality of your question, which to date has not been good.
Please read the how to ask a question part of the "how to use this forum" sticky post.
I was looking for example shut found none that fits my case.
That is because you seem to be reluctant to say what "your case" actually is.
The 9150A has an external A0 input on pin 9.
You connect this to a separate Arduino output on all the chips you want to use. Normally have all these pins high. Then when you want to access one chip take it's pin 9 low and use the address for the chip with A0 as a zero. When you have finished accessing put that chip's pin 9 high again.
Not sure if I should multiplex only SDA; I learned about i2c last week, and few weeks ago about arduino.
Thanks Crossroad; I need probably a breakout board for these IC, found one that is analog on Sparkfun; not sure if that would work. I just need 6 input.
Grumpy_Mike: thanks for your reply.
Altho I do not understand what do you mean by "good question"....I do not know anything about most of the topics; I just started. If I need to learn everything that I should know, before asking a question; that would defy the purpose of a forum where to ask for help. I get your point, but you should also look at the fact that not everyone knows everything, nor is familiar with the world of micro controllers, sensor and hardware, so what they learn is what they find online, in relation to the time that they can invest.
Forgive me if I am not able to explain something, for a good question. I am trying to make device used to calculate movement on quadrupeds; so I need 6 sensor hooked up to an arduino to be able to collect data; and I need to multiplex these sensor, since they are all the same.
I was thinking that since I can put 2 sensor max for each sensor model, I could mix them up; so 3 different MPU x 2 = 6 sensor, which is what I need. That's why I was asking. The whole point is to learn; but if I don't know exactly what is possible and how can I do that; then it is hard to actually ask the question.
I am planning to use invesense all in one sensors; so either the old 6050 or the new 9150
Mike was referring to your question. You are asking for advice but not specifying for what .
Essentially you are saying "I need help with THIS or THAT ."
to which Mike is responding : " So WHICH is it ? THIS or THAT ?" (6050 or the new 9150)
If the I2C device is a low power 5volt device, can't you use one of the 5v digital outputs on the arduino as the power supply to the I2C device?
When you want to access one of them, set the appropriate output pin to HIGH to switch it on, read the device and then set the output pin to LOW to switch it off.
If the I2C device is a low power 5volt device, can't you use one of the 5v digital outputs on the arduino as the power supply to the I2C device?
When you want to access one of them, set the appropriate output pin to HIGH to switch it on, read the device and then set the output pin to LOW to switch it off.
The concept is ok but due to your lack of experience with electronics , the implementation is wrong.
The way switched power works is a transistor (or mosfet) is used as a Series-Pass configuration computer controlled ON/OFF switch. If a transistor is used , a base resistor is required. If a mosfet is used , the resistor is not needed. The uC sends a HIGH signal (like you described) which turns on the transistor or FET ,
Technically, a relay could accomplish the same thing but is generally avoided due to the very slow (by computer standards) response time of 10 to 20 mS.
The concept is ok but due to your lack of experience with electronics , the implementation is wrong.
The way switched power works is a transistor (or mosfet) is used as a Series-Pass configuration computer controlled ON/OFF switch. If a transistor is used , a base resistor is required. If a mosfet is used , the resistor is not needed. The uC sends a HIGH signal (like you described) which turns on the transistor or FET ,
If the arduino digital output can source 40ma at 5v, and the I2C device requires less than 40ma, why can't it be connected directly to the arduino pin? I understand the need for a transistor circuit for switching (relatively) high loads but why is needed if the load is within the range of the digital output pin?
This is not a good idea because you should never connect an active input to an unpowered chip. You can get latch up conditions.
Read the how to use the forum sticky to see what a good question is and how to aske it. You do not have to know the answer before you formalities a good question. I have given you the answer, there is no need for any multiplexing. However if you do use it you must nmultiplex both Pi s because a slave device can in theory hold the clock low to extend it.
I actually spent more time reading sticky and searching, than actually posting...which is a good indicator that these matters are not simple by any means. It is not like programming; where you just get the algorithm and build on that.
Here you start with a MC and sensors; and end up reading about serial protocols (I2C), address set via pin high or low; transistors and so on.
I get that I need to do my homework, but the amount of info is overwhelming...can't finish to tap on one topic that you think that you are done, and end up just scraping the tip of the iceberg. But I guess this is the gist for anyone that start with hardware and electronics; so there is no work around. There is no "learn electronics in 24 hours"
So, from what I understand; I connect all the clock pins of all the sensor to the clock on the arduino, and then trough transistors I switch each "data" pin (which goes to the analog pin on the arduino; 1 pin per sensor).
This may be feasible; once that I find how to actually make in practice this setup (which transistor, where it goes, where to place all this extra circuitry and calculations to be sure that I am not sucking away too much current from the Arduino).
Now, the consequent question is: How do I know if I need to switch to a specific sensor? they all move independently, recording a different data. Do I simply set a loop and each sensor return whatever it has, when is its turn? Or should I check on each pin if there is a voltage variation, so when the data pin goes high, it means that there is data ready to be collected?
And thanks again for your help; at least now I am not shooting totally in the dark
It is not like programming; where you just get the algorithm and build on that.
That's not necessarily true either: there may be more than one algorithm to achieve a particular outcome, and you might need to assess them to see which is appropriate. Or, there may be no algorithm extant, and you have to devise that before you can start coding.
That's not necessarily true either: there may be more than one algorithm to achieve a particular outcome, and you might need to assess them to see which is appropriate. Or, there may be no algorithm extant, and you have to devise that before you can start coding.
To a certain extent, yes.
I am not talking of how many ways are to do something; that depends from the complexity and the person. My point was that once you learn how to deal with double linked list, you need to work only on the implementation, without worry about the concept per se.
Like in my case; I thought that all that I need is to wire the sensor and tell the MC to get the data and process it via code; while in reality; there are many other things that I need to be aware of and learn, just to understand how the basic communication between the sensor and the Arduino works.
Design always comes first; but you can't just continue to learn without ever start to do something practical..this is applicable both in hardware and software. Mostly you learn better by mistakes, than just reading and theorize about it.