Author Topic: Why do these modules refuse to work together?  (Read 14417 times)

0 Members and 2 Guests are viewing this topic.

Offline Rishles69@Topic starter

  • Contributor
  • Posts: 49
  • Country: in
Why do these modules refuse to work together?
« on: March 26, 2024, 03:32:32 pm »
so when i connected the modules (bmp180, mpu6050, hmc5883l, ssd1327 oled) one by one, the modules worked fine. But when i connected the modules together, the oled glitched. i connected Scl and Sda of the modules together (no power) the display doesn't turn on and the ide says display not initialised. i connected the mpu6050 and hmc5883l together with power, it works fine and when i connected the mpu6050, hmc5883l, ssd1327 oled , the display glitches! (without bmp180) whats happening here? is the scl and sda are glitching? (when i connected all of them together, i uploaded the code only for display and it glitches out!) what the hell is happening now?
 

Offline microbug

  • Frequent Contributor
  • **
  • Posts: 568
  • Country: gb
  • Electronics Enthusiast
Re: Why do these modules refuse to work together?
« Reply #1 on: March 26, 2024, 04:20:58 pm »
Each module probably has its own I2C pull-up resistors. With all the modules connected, the pull-up resistors are in parallel and the effective pull-up resistance is much lower (so more current goes through the switching transistors). When the pull-up resistance is too low, the OLED driver IC can't pull SDA or SCL low.

First, measure the pull-up resistance with all modules connected (the resistance between SDA and VCC, and the resistance between SCL and VCC). If it's less than 1kOhm, remove the pull-up resistors from one of your modules and try again. Keep going until the pull-up resistance is >1kOhm.
 

Offline selcuk

  • Regular Contributor
  • *
  • Posts: 249
  • Country: tr
Re: Why do these modules refuse to work together?
« Reply #2 on: March 26, 2024, 07:09:59 pm »
Since the drivers of the I2C bus only pull down, and the resistors pull up, the impedances of the logic levels are different. When you drive the clock line to ground strongly, it causes glitches on the data line via capacitive coupling while data is at high level through the resistor. You didn't mention but if you make I2C connections with cables, I recommend you to separate clock and data. For example, you may connect (twist) clock and ground together and data and vcc together. If you use a twisted pair cable and twist I2C clock and data together, that causes issues even with slow data rates.
 
The following users thanked this post: tooki

Offline Rishles69@Topic starter

  • Contributor
  • Posts: 49
  • Country: in
Re: Why do these modules refuse to work together?
« Reply #3 on: March 27, 2024, 04:08:03 am »
ok..., when i take a look on these modules i saw a 10k pull up resistors. But it can't be seen on the ssd1327 display (as you can see in the image). I searched up for the schematics and saw a 4pin generic version and it has a 10k pullup! (see image 2) so is it possible to add a 10k pullup on the scl and sda of the display?. Also im using 2x mcp23017 16bit gpio expander and should i add a 10k pullup for that also?
 

Offline LM21

  • Regular Contributor
  • *
  • Posts: 130
  • Country: fi
Re: Why do these modules refuse to work together?
« Reply #4 on: March 27, 2024, 05:27:24 am »
You need only one pull-up resistor.  No  need to to ADD a resistor.  If the problem is what others here suspect,  your total resistance is too low. Adding resistors makes it worse.

How long is the total length of your SDA or SCL wires. I2C bus has a limit there.
 

Offline Rishles69@Topic starter

  • Contributor
  • Posts: 49
  • Country: in
Re: Why do these modules refuse to work together?
« Reply #5 on: March 27, 2024, 05:40:07 am »
its like 5/4 cm each. so what should i want to do?
« Last Edit: March 27, 2024, 05:42:59 am by Rishles69@ »
 

Offline Rishles69@Topic starter

  • Contributor
  • Posts: 49
  • Country: in
Re: Why do these modules refuse to work together?
« Reply #6 on: March 27, 2024, 07:15:16 am »
should i follow this schematic?
 

Offline LM21

  • Regular Contributor
  • *
  • Posts: 130
  • Country: fi
Re: Why do these modules refuse to work together?
« Reply #7 on: March 27, 2024, 07:30:32 am »
If you  want to. But like others have said,  I2C bus must have  pull resistance, not too  high or too low. You can measure resistance with a DVM. Or you can search for all pull-up  resistors (components) and check them.
 

Offline Rishles69@Topic starter

  • Contributor
  • Posts: 49
  • Country: in
Re: Why do these modules refuse to work together?
« Reply #8 on: March 27, 2024, 12:09:45 pm »
ok so just need to connect 10k resistors on the input of the display? also im using mcp23017 ic for expanding gpio. do i need a 10k pullup for that too?
 

Offline nfmax

  • Super Contributor
  • ***
  • Posts: 1604
  • Country: gb
Re: Why do these modules refuse to work together?
« Reply #9 on: March 27, 2024, 02:07:27 pm »
Maybe two of the modules are set to the same I2C address? That would explain why they are OK singly but fail in 'interesting' ways when they are all on the same bus.
 

Offline Rishles69@Topic starter

  • Contributor
  • Posts: 49
  • Country: in
Re: Why do these modules refuse to work together?
« Reply #10 on: March 27, 2024, 04:04:37 pm »
But I only uploaded the program for display and not for rest of the modules while connected every modules in i2c bus. Still the static is seen
 

Offline Rishles69@Topic starter

  • Contributor
  • Posts: 49
  • Country: in
Re: Why do these modules refuse to work together?
« Reply #11 on: March 27, 2024, 04:05:33 pm »
Adding resistor as pull up didn't help either :palm:
 

Offline Rishles69@Topic starter

  • Contributor
  • Posts: 49
  • Country: in
Re: Why do these modules refuse to work together?
« Reply #12 on: March 27, 2024, 05:41:31 pm »
 Maybe I'll use display as spi mode through mcp23017 expander but it's very difficult to program
« Last Edit: March 27, 2024, 05:48:45 pm by Rishles69@ »
 

Offline Rishles69@Topic starter

  • Contributor
  • Posts: 49
  • Country: in
Re: Why do these modules refuse to work together?
« Reply #13 on: March 28, 2024, 06:38:03 am »
These are the connected modules and addresses

Bmp180 pressure sensor > 0x77 (this address is fixed and can't be changed. On my first build, I didn't used this sensor and gave the screen glitch with only mpu6050 and hmc5883l)

Mpu6050 > 0x68 and 0x69 (this address are not related with oled and gave the glitch)

Hmc5883l  magnetometer > 0x1E (after many searching this address is also fixed too and not related w/oled)

Ssd1327 oled > 0x3c and 0x3d (the display only worked in 0x3d and if I set it to 0x3c it doesn't turn on even only the module is connected)

So I want to say that when I first tried single modules it works fine. In my first attempt, I connected both gyro sensors and not bmp180, the screen glitches  :wtf: the address aren't same tho?. And in my second attempt I connected only hmc5883l and oled same thing happened. Also when I connected the mpu6050 same thing happened. Why and how. The display doesn't even recognize when set to 0x3c. This makes me mad too much as I spend 7000rs on it. The display works fine
 

Offline Rishles69@Topic starter

  • Contributor
  • Posts: 49
  • Country: in
Re: Why do these modules refuse to work together?
« Reply #14 on: April 02, 2024, 07:44:13 am »
Now i fixed the problem.  :-+ i first turned my oled module to spi and since there is lees number of pins available, i used an esp32 wroom. So problem solved.
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 12696
  • Country: ch
Re: Why do these modules refuse to work together?
« Reply #15 on: April 02, 2024, 07:15:26 pm »
Since the drivers of the I2C bus only pull down, and the resistors pull up, the impedances of the logic levels are different. When you drive the clock line to ground strongly, it causes glitches on the data line via capacitive coupling while data is at high level through the resistor. You didn't mention but if you make I2C connections with cables, I recommend you to separate clock and data. For example, you may connect (twist) clock and ground together and data and vcc together. If you use a twisted pair cable and twist I2C clock and data together, that causes issues even with slow data rates.
Great info.

FYI, the official i2C specification from Philips/NXP has recommended signal line configurations for PCB traces and cable. I can dig it up if anyone is interested.
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 12696
  • Country: ch
Re: Why do these modules refuse to work together?
« Reply #16 on: April 02, 2024, 07:24:04 pm »
Now i fixed the problem.  :-+ i first turned my oled module to spi and since there is lees number of pins available, i used an esp32 wroom. So problem solved.
That’s certainly a functional workaround. But it’d be great for you to figure out why it didn’t work on a single i2C bus. The official i2C specification document has recommendations on bus design that might provide insight. I can dig it up for you if desired.

Another workaround is to use a second i2C bus. ESP32 supports a second hardware i2C bus, and on any MCU, it’s also possible to bit-bang extra i2C buses if you need more than the MCU provides.
 

Offline selcuk

  • Regular Contributor
  • *
  • Posts: 249
  • Country: tr
Re: Why do these modules refuse to work together?
« Reply #17 on: April 02, 2024, 08:51:14 pm »
I think you are referring to the attached document. Section 16.3 Wiring pattern of the bus lines.

https://www.i2c-bus.org/fileadmin/ftp/i2c_bus_specification_1995.pdf
 
The following users thanked this post: tooki

Offline tooki

  • Super Contributor
  • ***
  • Posts: 12696
  • Country: ch
Re: Why do these modules refuse to work together?
« Reply #18 on: April 03, 2024, 05:24:06 pm »
I think you are referring to the attached document. Section 16.3 Wiring pattern of the bus lines.

https://www.i2c-bus.org/fileadmin/ftp/i2c_bus_specification_1995.pdf
Yep, that's precisely the section I was thinking of! :D
 

Offline xvr

  • Frequent Contributor
  • **
  • Posts: 427
  • Country: ie
    • LinkedIn
Re: Why do these modules refuse to work together?
« Reply #19 on: April 03, 2024, 05:30:37 pm »
Adding resistor as pull up didn't help either :palm:
You should not add, but remove extra pull-up resistors. Each [or almost] module you mentioned (bmp180, mpu6050, hmc5883l, ssd1327 oled) already include pull-up resistors. I2C bus do not expect such number of pullups (all of them running in parallel). You should find them inside modules and remove all, except one.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf