0
\$\begingroup\$

My Engineering Design and Development (EDD) class is working on a high altitude balloon (HAB) and my friend an I are in charge of data collection. It looks like we are going to use an Arduino (Uno or Due based on needed ports) and sensor breakout boards for logging data. As I was browsing our possibilities, and I wasn't quite sure if running multiple I2C devices on the Arduino was realistic.

For example, in viewing the tutorials for an accelerometer (3-axis) and a gyroscope (3-axis), I found that both require the use of the SDA and SCL ports on the Arduino. If I have read correctly, each device has a different I2C address, and you can use them in the same port, but I wasn't sure. If that is possible, how do you know what the address is or how to assign the address? Is there a maximum limit of I2C devices that an Arduino can handle? I have reviewed How to connect multiple i2c-interface devices into a single pin A4 (SDA) and A5 (SCL) on Arduino? but I'm not quite sure this answers my questions fully.

\$\endgroup\$
4
  • \$\begingroup\$ You should be able to use multiple I2C peripherals, at least if they have non-conflicting addresses. But given you are flying this, you'd probably save substantial mass by getting a quadcopter board (arduino-compatible or otherwise) with the accelerometer and gyro already on it - for at least a year now those functions have commonly been provided by a single QFN IC. \$\endgroup\$ Oct 2, 2014 at 20:55
  • \$\begingroup\$ @ChrisStratton This was purely an example. We are looking to many different options including barometric pressure, altitude, temperature, humidity, cosmic waves/radioactivity, etc. So the question still remains even if using the mentioned board. \$\endgroup\$
    – SuperAdmin
    Oct 2, 2014 at 20:59
  • \$\begingroup\$ What's the Vcc (logic supply rail voltage) of your Arduino? Some Arduinos have Vcc = +3.3V , some have +5V. \$\endgroup\$ Oct 2, 2014 at 21:06
  • \$\begingroup\$ @NickAlexeev The Arduino is capable of supporting both. Upon further research, the tutorial specifies the level shifting is only required for a 5v system, and I have edited the question accordingly. \$\endgroup\$
    – SuperAdmin
    Oct 2, 2014 at 21:12

2 Answers 2

3
\$\begingroup\$

The accelerometer address is 0x1D by default and can be changed to 0x1C with a bit of soldering(Found in the Address Select Jumper section of the guide you linked). The gyroscope address is 0x69 by default and can be changed to 0x68(Found in section 6.1.1 of the datasheet, and the I2C Address Jumper section of the guide you linked). The Arduino can theoretically support as many I2C devices as can be acquired without having two that share an address.

Note also that accelerometers and gyroscopes are often packaged together on a single chip, which may be easier to work with. I've used the MPU-9150 with good results.

\$\endgroup\$
2
  • \$\begingroup\$ Thank you. I was not aware that I2C addresses are relative to soldering, and they are listed in data sheets. The combined chip looks spectacular. \$\endgroup\$
    – SuperAdmin
    Oct 2, 2014 at 21:20
  • \$\begingroup\$ Specifically, the first 6 bits of the address are fixed by the manufacturer, with the seventh being selectable by the user by wiring one of the chip's pins to Vcc or Ground. The boards both have them pre-wired to Vcc, but you can change that with a bit of work if you want to put two of the same chip on a bus. \$\endgroup\$
    – Saidoro
    Oct 2, 2014 at 21:24
4
\$\begingroup\$

If I have read correctly, each device has a different I2C address, and you can use them in the same port, but I wasn't sure. If that is possible, how do you know what the address is or how to assign the address?

In an I2C peripheral, a slave address is hard-wired1 inside of the chip. In some peripherals, some bits of the slave address can be set by strapping address select pins. The latter allows assigning distinct addresses to several slave devices of the same type, and they can appear on the same I2C bus without causing an address collision. The definitive source of information on I2C address selection is the datasheet for the slave device.

Let's take MMA8452Q for example. The addresses are specified in the Table 1 of the datasheet (rev.9). In addition, Sparkfun talks about the address selection jumper in their Hookup guide.

1 If the slave device itself is a microcontroller, then the address is usually set in its firmware.

Is there a maximum limit of I2C devices that an Arduino can handle?

All 7-bit addresses should be greater than 0x07 and less than 0x78 (here's a nice chart of I2C addresses). An Arduino can talk to all of these addresses. Furthermore, the number of slave devices can be increased by having multiple I2C buses, and through bus switching.

Another limiting factor is total capacitance of I2C bus. A good conservative approach is to keep the capacitance below 400pF. More details here.

Finally

If you are planning to work with I2C, you should read the I2C bus specification. At least, skim through it.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.