Multiple I2C devices with a Flora

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
WKB
 
Posts: 2
Joined: Sun Apr 14, 2013 2:35 pm

Multiple I2C devices with a Flora

Post by WKB »

Hi -

I just received my Flora and have started to code in Arduino. In a previous project I used an analog gyroscopic accelerometer with an Uno. I purchased a Flora LSM303 to use with my Flora and I have now realised that I must write my code differently; which is totally cool because I2C makes things easier :D .

I was just reading the specification for IC2 and it seems that you can string sensors is a series. An exciting and potentially useful discovery, however, how do I know how to address/read the correct sensor if I have multiple of the same or if I have a mix of sensors how do I know which one will respond next.

The Wikipedia ( http://en.wikipedia.org/wiki/I%C2%B2C ) entry says the
"There are four potential modes of operation for a given bus device, although most devices only use a single role and its two modes:
master transmit — master node is sending data to a slave
master receive — master node is receiving data from a slave
slave transmit — slave node is sending data to the master
slave receive — slave node is receiving data from the master"

Does The Flora Arduino dialect support all of these feature or is this a library specific aspect for each IC2 device? I assume that the Flora is a "master transmit/master receive" device. Are all IC2 slaves? If I want to build a custom I2C sensor what are the essential components?

Appreciate any help in untangling the relationships.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple I2C devices with a Flora

Post by adafruit_support_bill »

All of our I2C sensors have dedicated libraries. These are in turn based on the "wire" library for the actual i2c communication.
All devices on the i2c bus must have a different address and they will respond only when addressed by the Master (the Flora).

Some devices have configurable addresses. Others, like the LSM303 are fixed. Since the LSM303 is actually two devices in one, it has two addresses: 0x32 for the accelerometer and 0x3c for the magnetometer.

WKB
 
Posts: 2
Joined: Sun Apr 14, 2013 2:35 pm

Re: Multiple I2C devices with a Flora

Post by WKB »

Hey Adafruit_support_bill or I assume just Bill -

Thank you for the answer which leads to the next question; a quick scan of github did not bring up a 'wire' library - I assume this is some kind of general reference to the 'wire' kind of library rather than an actual library. While I appreciate that these are relatively low level calls are the libraries available to review?

This also leads me two more general questions about library dependence.
1).Is there a document of general requirements for Arduino class devices ? I am aware of 'http://arduino.cc/', are they the open source owners?
2)If this document exists are there required dependencies; e.g. all devices of a certain type must use [functions, class, method, widget..] X for uniform code implementation? (Possible this is too strong an expression for the Arduino community? Are there possibly guidance notes on implementing hardware calls?)

I appreciate the help,

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple I2C devices with a Flora

Post by adafruit_support_bill »

The 'wire' library is one of the standard libararies in the Arduino IDE install.

There are no real rules for the structure of Arduino drivers. Most are distributed in library form and must follow the rules for Arduino Libraries. These are controlled by the Arduino team at Arduino.cc.
At Adafruit, most new sensor drivers are being written to conform to the Adafruit Unified Sensor conventions.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple I2C devices with a Flora

Post by adafruit_support_bill »

Am still trying to get the LSM303DLHC working!
Are you still having compile problems? If you post the error output we can try to figure it out.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”