due multiple i2c problem

Hi,

i make connections as you can see in attachment.

hmc5883l works when I connect it alone.
mma845x works when I connect it alone.

However, when i connect them together, they dont work. I see their adresses with i2Cscanner in first 1-2 loop. In addition to these, it shows random 1-2 adresses more. In later loops, it can’t find any adress. I have same problem when I use l3gd20h and bme280 sensors additionally. while sensors work alone, when I connect them together at the same time, first 1-2 times I get data, but later i2c devices cannot be found.

I have tried to use external power supply to feed and briged the gnd lines but result havent changed.

I dont have any problem when I use the same sensor and connection with uno and mega.

Hello ytkzn,

Arduino Due can perfectly handle two or more I2C devices at once. If you say that your I2C devices run OK with Due separately but together, then your problem is probably in your code. I mean, how you are putting together both pieces of code. Remember also that Due is different from UNO or Mega. It will be good if you post your code. Regards.

-p

Hello Palliser,

hmc5883l : Arduino-HMC5883L/HMC5883L_compass at master · jarzebski/Arduino-HMC5883L · GitHub

i2cScanner :
http://playground.arduino.cc/Main/I2cScanner

0x1C : mma845x
0x1E : hmc5883l
0x6B : l3gd20h

Output :

I2C Scanner
Scanning...
I2C device found at address 0x1C !
I2C device found at address 0x1E !
I2C device found at address 0x6B !
done

Scanning...
I2C device found at address 0x1C !
I2C device found at address 0x1E !
I2C device found at address 0x6B !
done

Scanning...
I2C device found at address 0x1C !
I2C device found at address 0x1E !
I2C device found at address 0x6B !
done

Scanning...
I2C device found at address 0x1C !
I2C device found at address 0x1E !
done

Scanning...
No I2C devices found

Scanning...
No I2C devices found

Scanning...
No I2C devices found

another try :

Scanning...
!
address 0x1C !
I2C device found at address 0x1E !
I2C device found at address 0x6B !
I2C device found at address 0x73 !

I2C Scanner
Scanning...
I2C device found at address 0x1C !
I2C device found at address 0x1E !
I2C device found at address 0x6B !
done

Scanning...
I2C device found at address 0x1C !
I2C device found at address 0x1E !
I2C device found at address 0x6B !
done

Scanning...
I2C device found at address 0x1C !
I2C device found at address 0x1E !
I2C device found at address 0x6B !
done

Scanning...
I2C device found at address 0x17 !
done

Scanning...
No I2C devices found

Scanning...
No I2C devices found

Unrelevant addresses returning. I tried it with another due's. Still same result

ytkzn:
Hello Palliser,

hmc5883l : Arduino-HMC5883L/HMC5883L_compass at master · jarzebski/Arduino-HMC5883L · GitHub

i2cScanner :
http://playground.arduino.cc/Main/I2cScanner

0x1C : mma845x
0x1E : hmc5883l
0x6B : l3gd20h

Output :

I2C Scanner
Scanning...
I2C device found at address 0x1C !
I2C device found at address 0x1E !
I2C device found at address 0x6B !
done

etc...

The I2C Scanner that you are using was conceived originally for AVR boards (like UNO, Mega, etc).
I know that there have been attempts to make it work with Due (ARM board) but not sure if it is verified with it using more than one I2C device.

My recommendation is to start with a base code that request data from both devices. As I told you before, Due can handle them. The fact that the I2C scanner is not working accordingly is not (imo) a key factor.

-p

I wire the bme280 as same as the breadbroad scheme. (attach : bme280_bb.png) then i upload the code in here: Adafruit_BME280_Library/bme280test.ino at master · adafruit/Adafruit_BME280_Library · GitHub it works seamlessly. After that, i add others sensors and upload the code in here: Adafruit_BME280_Library/bme280test.ino at master · adafruit/Adafruit_BME280_Library · GitHub im trying to read the bme280 but i cant get anything (attach : 4sensors_bb.png)

(I tried to feed the 3.3v with due and battery, neither of them works)
(The same scheme works with uno and mega)

Try connecting pin CS (pin2-CSB) of your bme280 to 3.3V.

-p

EDIT:
Some I2C devices has a maximum of 2 ID addresses, thus in case of bme280, given that it has only two ID addresses (0x76 & 0x77) you only can connect a max of 2 bme280 to your Arduino. In case you want connect more devices, you will have to use additional external devices like PCA9564.

-p

Thank you for answering me back. i use one bme280.

4 sensors

1 - bme280
2 - mma845x
3 - hmc5883l
4 - l3g4200d

I'd recommend to verify, one by one, each ID address of your four devices to make sure they all are different. Per your prior comments, you can do that. Then, start adding (running/communicate) one device at a time. As I told you since the very beginning, Arduino Due can handle several I2C slaves without problems (Indeed, one of the strongest capabilities of Due is to control drones). The tricky part is to understand the functionality of each I2C slave. Even with the same core, each brand has its own board layout. Some of them like bme280 can talk I2C and SPI depending on the pin CS that I mentioned in my last post. If you try to make all of them work at once, it shall be complicated. In reference to the sketch, define all their addresses at the beginning (if apply), initialize them in the setup (if apply) and invoke their subroutines in the loop. Good luck.

-p

I love the BME280 but I still scratch my head working with it sometimes. It has a lot of different addresses which are selected by the state of the SDA and SCL lines when it starts up. If you have another device that holds those lines low while the BME280 is starting, it may end up on a different address.

I was never able to get it to work on all the addresses specified in the datasheet. So I gave up and just followed the 'standard' address.