I2C issue with multiple slave devices

I’m trying to connect a couple of sensors to my particle photon and cannot seem to find both using i2c scanner code.

The sensors are an accelerometer (http://wiki.seeed.cc/Grove-3-Axis_Digital_Accelerometer-400g/) and a gyroscope (https://www.sparkfun.com/products/11977).

If they are connected one at a time, I can find them. If I plug them both in at the same time, only the accelerometer is found.

I’ve tried 4.7k, and 10k pull up resistors (pulling up to 3.3v) with no success.

I have also used a battery shield (https://www.sparkfun.com/products/13626) which has its own i2c address. If the gyroscope and battery shield are used, both devices are found. If the accelerometer and battery shield are used, both are found. If I have all three devices connected, only the accelerometer and battery shield are found.

I have tried this with a redbear duo and get the same results.

I have no issues finding both devices using an arduino nano.

I’m a beginner at this so any help on what I’m doing wrong would be greatly appreciated. If any other info required, let me know.

Heres the scanner code I’m using.

#include "application.h"

SYSTEM_MODE(SEMI_AUTOMATIC)

void setup(){
    WiFi.off();

    Wire.begin();
    Serial.begin(9600);
    while (!Serial);    
    Serial.println("\nI2C Scanner");

}

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

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

    nDevices = 0;

    for(address = 1; address < 127; address++){


        Wire.beginTransmission(address);
        error = Wire.endTransmission();

        if (error == 0){ // successful
            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("Unknown 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(1000);           // wait 1 second for next scan
}

Thanks,
Will

photo

What are the addresses you get when scanned individually?
You seem to have multiple sets of pull-up resistors there.
AFAICT the accelerometer has its own set on board and you have a set of 10k too.

Thanks for the response, the addresses are:
0x18 for the accelerometer
0x36 for the battery shield
0x69 for the gyroscope

I tried no pull-ups too - to no avail.

I forgot to mention I have also closed the clock source jumper on the back of the gyroscope.

It’s probably time to look at it with an oscilloscope if you can find or borrow one.

1 Like

I unfortunately couldn’t get my hands on an oscilloscope.

Instead I picked up the Sparkfun breakout of the H3LIS331DL accelerometer.

All is working as expected now :smile:

1 Like