Go Down

Topic: Multiple I2C Devices not working (Read 1 time) previous topic - next topic

ddesousa


Hi there,

I am currently using a MPU6050 accelerometer using the I2CDevlib library and a ssd1306 using the U8g2 library.

During initialisation, the screen does not work after the MPU initialises and I was wondering if the two devices do not work together well.

I am thinking that its something to do with the libraries clashing and not working well together.

Thanks

pylon

Quote
During initialisation, the screen does not work after the MPU initialises and I was wondering if the two devices do not work together well.

I am thinking that its something to do with the libraries clashing and not working well together.
As you didn't provide links to the hardware you're using (I guess you don't use the chips directly but on some breakout board, these boards contain other components) as well as no wiring diagram of your setup we first assume that it's a hardware issue. Did you try the same hardware setup with just one of the two libraries? Did that work?

Did you modify the I2CDevlib? What type of Arduino are you using? Does your setup include additional hardware?

Post the necessary information.

ddesousa

Sorry for not explaining completely.

I am using the SSD1306 (https://www.amazon.ca/Yellow-Moudle-Display-Arduino-Raspberry/dp/B01N78FUH7/ref=sr_1_2?ie=UTF8&qid=1508949420&sr=8-2&keywords=oled+arduino) with the u8g2 library and the MPU6050 (https://www.dfrobot.com/product-880.html) with the I2C devlib library.
Both modules work seperatly with their respective libraries.

I only changed one thing in the I2CDevlib library which was the sampling frequency at which the FIFO buffer is filled with acceleromter data.

I am currently using an Arduino UNO (atmega328p)
-> additional hardware: Bluetooth, PPG sensor, battery charger .etc (no other i2c devices)

My modules are both connected to the same SDA, SCL, GND, VCC and the MPU6050 has an additional interrupt pin. Both devices have different addresses.

pylon

The MPU6050 module of dfrobot.com is commendable documented but the OLED lacks any relevant documentation. I guess the software isn't really the problem. Try uploading the software you use for the MPU6050 (alone) and attaching the OLED afterwards. I expect the MPU to stop working as soon as the OLED is attached. If the OLED board is built as I assume the use the 5V as Vcc and have pull-ups to 5V. So the I2C lines have a passive voltage of around 4.5V which may already damage the MPU6050.

It might work better if you connect the VCC pin of the OLED to 3V3 instead of 5V.

ddesousa

Thanks. I have both the OLED and MPU at 3.3 V which is what level they were at when I first worked on the project and tested them standalone.

Could it be something to do with the libraries recognising other devices as their own?

pylon

Quote
Could it be something to do with the libraries recognising other devices as their own?
I don't think so.

Have you tried using just the MPU6050 sketch while the OLED is connected? If that doesn't work it's most probably a hardware issue.

Please provide a wiring diagram of your complete setup (may be hand drawn).

ddesousa

#6
Oct 27, 2017, 01:08 am Last Edit: Oct 27, 2017, 01:26 am by ddesousa
I tried that. MPU works on its own even when connected to the display.

Images attatched

https://drive.google.com/open?id=0B4wDQfhpE4oMRG1nN0lNYmxDNFk

They are too big to upload

zhomeslice

#7
Oct 27, 2017, 02:13 am Last Edit: Oct 27, 2017, 02:15 am by zhomeslice
Hi there,

I am currently using a MPU6050 accelerometer using the I2CDevlib library and a ssd1306 using the U8g2 library.

During initialisation, the screen does not work after the MPU initialises and I was wondering if the two devices do not work together well.

I am thinking that its something to do with the libraries clashing and not working well together.

Thanks
The possibility of an electrical issue is also present because of the requirement for pullup resistors The MPU6050 has pullup resistors attached to the breakout board 3.3 supply. I'm not familiar with the ssd1306 on board connections. but try this i2c scanner I found. It should respond with all addresses it discovers on your i2c buss
Z
HC

pylon

Quote
I tried that. MPU works on its own even when connected to the display.
I have the impression that I answered your question already in an other thread. Did you post the same question several times?

Koepel

#9
Oct 28, 2017, 04:59 pm Last Edit: Oct 28, 2017, 05:00 pm by Koepel
Use a 3.3V Arduino board or use level shifters for the sensor and the display.

The OLED display disturbs the I2C bus. Can you try other pins and software I2C (I think the U8g2 has that option). Then you need two level shifters. One for the sensor and one for the display.

If that is working, you can try to connect the OLED display to the real I2C bus (using the same level shifter as the sensor), and see if it still disturbs the I2C bus.

zhomeslice

#10
Oct 28, 2017, 06:34 pm Last Edit: Oct 28, 2017, 06:34 pm by zhomeslice
The MPU6050 breakout board VCC requires 5V they have a 3.3v regulator onboard. you may consider bypassing the regulator if you are attempting to supply the MPU6050 with 3.3v also since you are connecting multiple I2c devices that both your display and the MPU 6050 have pullup resistors on each. depending on the values of the resistors your devices may not be able to drop to a low enough voltage to properly provide a low state on the i2c buss.


HC

wvmarle

The additional pull up resistors (R4, R5) are not necessary when using breakout boards.

If you connect them all, and run the I2C scanner, do all the expected addresses show up? This is a simple test to make sure your bus works and the devices respond. If you don't see anything there, it's a bus problem. If they report properly, it MAY be a software library problem even though that's highly unlikely, as I2C is designed to deal with multiple devices and it's impossible for two libraries to try to transmit at the exact same time.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

miszabo

Same problem was at me. Arduino pro mini 3.3V/8MHz + 128x64 oled + htu21d or bmp280.
If I used oled standalone there was proper image. If I put either sensor the image will be weird.
Solution:
You have to use oled reset pin, controlled by either arduino gpio pin. Of coures you have to set in program this gpio at display initialisation method.

Go Up