I2C sensor to grove port on M5Stick GRAY (NOT C)
-
Hi, is it possible to connect an I2C sensor (VL53L1X) on the grove port of the stick (GRAY) and at the same time use the internal MPU9250(0x68) and IP5306(0x75)?
I'm trying with TwoWire and the I2c scanner..#include <Wire.h> #define SDA2 25 #define SCL2 13 TwoWire Wire1 = TwoWire(1); void setup() { Serial.println("M5 I2C Tester"); Wire.begin(); Wire1.begin(SDA2, SCL2, 400000); Serial.begin(115200); delay(3000); } void loop() { // scan for i2c devices 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"); }
but Arduino IDE doesn't compile with this output:
libraries/Wire/Wire.cpp.o:(.bss.Wire1+0x0): multiple definition of `Wire1' sketch/I2C_Serial_Tester2.ino.cpp.o:(.bss.Wire1+0x0): first defined here collect2: error: ld returned 1 exit status exit status 1 Error compiling for board M5Stack-Core-ESP32.
ideas?
tnks a lot..
-
@cepics said in I2C sensor to grove port on M5Stick GRAY (NOT C):
Wire.begin();
Wire1.begin(SDA2, SCL2, 400000);Wire.begin(); Wire1.begin(SDA2, SCL2, 400000);
Try deleting Wire.begin();
-
tnks for answering !!
but:#include <Wire.h> #define SDA2 25 #define SCL2 13 TwoWire Wire1 = TwoWire(1); void setup() { Serial.println("M5 I2C Tester"); //Wire.begin(); Wire1.begin(SDA2, SCL2, 400000); Serial.begin(115200); delay(3000); } void loop() { // scan for i2c devices 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"); }
and the output:
Arduino: 1.8.9 (Mac OS X), Board: "M5Stack-Core-ESP32, QIO, 80MHz, Default, 921600, None" libraries/Wire/Wire.cpp.o:(.bss.Wire1+0x0): multiple definition of `Wire1' sketch/sketch_aug29a.ino.cpp.o:(.bss.Wire1+0x0): first defined here collect2: error: ld returned 1 exit status exit status 1 Error compiling for board M5Stack-Core-ESP32. This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.