I2C connection not working when using two sensors

Hi there

So I'm currently having a problem with I2C connection. I use an Arduino uno and I have two sensors one is the BMI160 (Gravity__BMI160_6-Axis_Inertial_Motion_Sensor_SKU__SEN0250-DFRobot) the other one is the MAX30102 (Mixed-signal and digital signal processing ICs | Analog Devices). I used Arduinos I2C scaanner to find the adress which works totally fine when only one of them is connected. But once I connect both there are errors on every single I2C Adress the scanner talks to and no device is found. I already checked the pullups and they both have them on board(MAX30102=4.7k, BMI160=10k). Never the less I thought the parallel resistance is a bit small so I changed the 4.7k also to 10k and even to 20k on the Max30102. Also tried 5v and 3,3V. No luck. I would be very happy if someone could help me with this issue.

Thanks
Manuel

// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not known.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// 
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>


void setup()
{
  Wire.begin();

  Serial.begin(9600);
  Serial.println("\nI2C Scanner");
}


void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ ) 
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4) 
    {
      Serial.print("Unknow error at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}
Scanning...
Unknow error at address 0x01
Unknow error at address 0x02
Unknow error at address 0x03
Unknow error at address 0x04
Unknow error at address 0x05
Unknow error at address 0x09
Unknow error at address 0x0A
Unknow error at address 0x0B
Unknow error at address 0x0C
Unknow error at address 0x0D
Unknow error at address 0x0E
Unknow error at address 0x0F
Unknow error at address 0x10
Unknow error at address 0x13
Unknow error at address 0x14
Unknow error at address 0x15
Unknow error at address 0x16
Unknow error at address 0x17
Unknow error at address 0x19
Unknow error at address 0x1A
Unknow error at address 0x1B
Unknow error at address 0x1C
Unknow error at address 0x1D
Unknow error at address 0x1F
Unknow error at address 0x20
Unknow error at address 0x21
Unknow error at address 0x22
Unknow error at address 0x23
Unknow error at address 0x24
Unknow error at address 0x25
Unknow error at address 0x26
Unknow error at address 0x27
Unknow error at address 0x28
Unknow error at address 0x29
Unknow error at address 0x2A
Unknow error at address 0x2B
Unknow error at address 0x2C
Unknow error at address 0x2D
Unknow error at address 0x2E
Unknow error at address 0x2F
Unknow error at address 0x30
Unknow error at address 0x31
Unknow error at address 0x32
Unknow error at address 0x33
Unknow error at address 0x34
Unknow error at address 0x35
Unknow error at address 0x37
Unknow error at address 0x39
Unknow error at address 0x3A
Unknow error at address 0x3B
Unknow error at address 0x3C
Unknow error at address 0x3D
Unknow error at address 0x3E
Unknow error at address 0x3F
Unknow error at address 0x40
Unknow error at address 0x41
Unknow error at address 0x42
Unknow error at address 0x43
Unknow error at address 0x44
Unknow error at address 0x45
Unknow error at address 0x46
Unknow error at address 0x47
Unknow error at address 0x48
Unknow error at address 0x49
Unknow error at address 0x4A
Unknow error at address 0x4B
Unknow error at address 0x4C
Unknow error at address 0x4D
Unknow error at address 0x4E
Unknow error at address 0x4F
Unknow error at address 0x50
Unknow error at address 0x51
Unknow error at address 0x52
Unknow error at address 0x53
Unknow error at address 0x54
Unknow error at address 0x55
Unknow error at address 0x56
Unknow error at address 0x57
Unknow error at address 0x58
Unknow error at address 0x59
Unknow error at address 0x5A
Unknow error at address 0x5B
Unknow error at address 0x5C
Unknow error at address 0x5D
Unknow error at address 0x5E
Unknow error at address 0x5F
Unknow error at address 0x60
Unknow error at address 0x61
Unknow error at address 0x62
Unknow error at address 0x63
Unknow error at address 0x64
Unknow error at address 0x65
Unknow error at address 0x66
Unknow error at address 0x67
Unknow error at address 0x68
Unknow error at address 0x69
Unknow error at address 0x6A
Unknow error at address 0x6B
Unknow error at address 0x6C
Unknow error at address 0x6D
Unknow error at address 0x6E
Unknow error at address 0x6F
Unknow error at address 0x70
Unknow error at address 0x71
Unknow error at address 0x72
Unknow error at address 0x73
Unknow error at address 0x74
Unknow error at address 0x75
Unknow error at address 0x76
Unknow error at address 0x77
Unknow error at address 0x78
Unknow error at address 0x79
Unknow error at address 0x7A
Unknow error at address 0x7B
Unknow error at address 0x7C
Unknow error at address 0x7D
Unknow error at address 0x7E
No I2C devices found

... Never the less I thought the parallel resistance is a bit small so I changed the 4.7k also to 10k and even to 20k on the Max30102.

Have you tried completely removing the resistors on one of the devices?

Don

No But I'll try tomorrow and let you know whats happening. Thanks for the quik response!

Have you tried completely removing the resistors on one of the devices?

just tried it and I still have the same problem sadly.

Please, post the pictures of the modules for the sensors: MAX30102MAX30102.jpg ? and BMI106. Note that MAX30102 has the address 0x57 (101111) and BMI160 has the address (default) 0x68 (1101000).

MAX30102.jpg

Hi

You can find the two images attached. Yeah but that's okay right? they should be different.

135795864_MaximSensors_MAXREFDES117ReferenceDesign.jpg

dfrobot-motion-sensor-dfrobot-gravity-i2c-bmi160-6-axis-inertial-motion-sensor-2578840354903_large.jpg

Okay I just realized something very strange! Once I disconnect the ground of both sensors the both addresses are printed as expected:

Scanning...
I2C device found at address 0x57 !
I2C device found at address 0x69 !
done

but then of course the sensor doesn't work anymore...

tomatotech:
Okay I just realized something very strange! Once I disconnect the ground of both sensors the both addresses are printed as expected:

Scanning...
I2C device found at address 0x57 !
I2C device found at address 0x69 !
done

but then of course the sensor doesn't work anymore...

My I suggest then that you post the complete wiring connections of your arduino and sensors.

With some luck someone here may be able shed some light on this mystery...

Attached you can find the build. the connections to sensors are just hooked up where the same thing is written so sda to sda and so on. d2 and d10 are int connections so you can just leave those aside.

The photos that you have attached are not *.jpg files but *.webp files. Can your correct that ? Use the "Modify" option.
We would like to see photos of the modules that you have, instead of pictures that we have already seen in the links that you gave.
If you are using a Chrome (or Chrome-based) browser, then you don't have a problem with the webp files, but others have.

BMI160
Gravity__BMI160_6-Axis_Inertial_Motion_Sensor_SKU__SEN0250-DFRobot.
The BMI160 module has level shifters and a voltage regulator. It will work with 5V Arduino boards and with 3.3V Arduino boards.
When using it with a 5V Arduino board, you should power it with 5V, or else the level shifters don't work.

MAXREFDES117
That is a board from Maxim with the MAX30102 and extra interface chips so it can connect with a 5V Arduino board.

There is even a video: - YouTube.
They advice to use the Arduino Uno 3.3V pin to power the board. I don't believe that. Then the level shifters will not work. In the video they use the VIN pin of the Arduino Uno to power it, so they have no clue what they are doing anyway.
I suggest to power it with 5V.

sherzaad:
With some luck someone here may be able shed some light on this mystery...

To know the facts at the ground level, full schematics of the two modules (that the OP is using) are required.

They can be found.

DFrobot has a link on the bottom of that page to: Gravity BMI160 6-axis IMU Schematic.pdf.

The MAXREFDES117 schematic it here: https://chipsnwafers.electronicsforu.com/2019/11/22/reference-design-for-heart-monitor-in-smart-wearables/maxrefdes117-schematic-full/.
I assume that is with reverse engineering.

Both schematics confirm that both should be powered with 5V to make the level shifters work.

At the best level of my understanding, the connection could be as follows (Fig-1):


Figure-1:

However, I have a note on the address of BMI160. The default address is 0x69 when the SD0-pin is left open. But, we don't know which library the OP is using; the Library might contain the device address as 0x68 and if so, the SD0-pin must be connected at GND-pin (Fig-2) for the sensor to work.
bmi160Pin.png
Figure-2:

Test Codes:

void setup()
{
   Serial.begin(9600);
   Wire.beginTransmission(0x57);
   byte busStatus1 = Wire.endTransmission();
   if(busStatus1 !=0 )
   {
       Serial.print("Heart-rate sensor is not found...!");
       goto NL;
   }
   Serial.println("Heart-rate sensor is found.");
   //-------------------------------------------------
   NL: Wire.beginTransmission(0x69);
   byte busStatus1 = Wire.endTransmission();
   if(busStatus2 !=0 )
   {
       Serial.print("Pressure sensor is not found...!");
       while(1);   //wait for ever
   }
   Serial.println("Pressure sensor is found.");
   //-------------------------------------------------
}

void loop()
{

}

bmi160Pin.png

Hi Guys

Sorry for my late response. Thanks for all the answers.
So forst of all I tried them at 3.3V and 5V. I exactly connected it as GolamMostafa postet so you can see how I hooked up the sensors there. The Adress is 0x69 because I tested it seperately. I will try the code by GolamMostafa now and put back on the pullups so the parallel pullup is around 3.3k and then connect both at 5V lets see what happens.

BR
Manuel

Please, provide a link/attach to the Library that you are using for BMI160 sensor. This is to check that the content of the Library if it has any hard coded address for the sensor.

I only use the wire.h library in the scanner

Hi again

Problem solved. the flat ribbon cable they provided with the BMI160 caused a high capacity which caused the problem. I now seperatet the cables and it works fine. Thanks for your help.

Cheers,
Manuel