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