Pages: [1]   Go Down
Author Topic: Is it possible to connect two Mag3110 sensors to one Arduino?  (Read 372 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I’m trying to connect two Mag3110’s Magnetometers to the same I2c Bus on an Arduino. Is there any way to change the slave address of 0x0E on one of the chips so that I can address both of them on the same bus? If not, is there any other way to connect and address both? Thanks.
Logged

Belgium
Offline Offline
Sr. Member
****
Karma: 1
Posts: 281
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Google I2C multiplexer.
Logged


New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3701
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is no restriction that requires that you only have a single pin running an I2C bus. Of course, it's an annoyance when you were expecting to read all your i2C devices from a single pin, but in this case, your easiest solution may well be to put each sensor on its own private bus/pin.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your reply. I thought I2C requires to use Analog pins 4 and 5 on the Arduino? So are you saying it's possible to use another analog pin for the SDA line at the same time (to communicate with 2 sensors for example that have the same id)? Do you know how the basic code would change to handle that? I thought the code is all set up to only work on pins 4 and 5.
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3701
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oops - I was thinking of the onewire  library. Looks like I2C is, as you say on fixed pins.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13739
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

please post a link to the datasheet of the sensor.

If the sensors have the same address hard coded you have a problem.
A solution that worksometimes is to switch on/off the power of the I2C device (either directly or through some transistor).

digitalWrite(SENSOR1_PIN, HIGH); 
I2C.read(sensor);
digitalWrite(SENSOR1_PIN, LOW);

and to use sensor 2
digitalWrite(SENSOR2_PIN, HIGH); 
I2C.read(sensor);
digitalWrite(SENSOR2_PIN, LOW);

Note some sensors need time to "wake up", to tweaking might be needed.
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Faraday Member
**
Karma: 62
Posts: 3030
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I looked up the datasheet of the sensor.   There appears to be no method to select alternative I2C addresses for it.

At the bottom of the first page,  it seems to suggest that the address  for one version of the device was different to the address for a different device,   it wasn't clear to me what two versions of the device (  or different devices ),   this was referring to.
Logged

Pages: [1]   Go Up
Jump to: