🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    I2C sensor to grove port on M5Stick GRAY (NOT C)

    M5 Stick/StickC
    2
    3
    4.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      cepics
      last edited by

      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..

      ajb2k3A 1 Reply Last reply Reply Quote 0
      • ajb2k3A
        ajb2k3 @cepics
        last edited by

        @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();

        UIFlow, so easy an adult can learn it!
        If I don't know it, be patient!
        I've ether not learned it or am too drunk to remember it!
        Author of the WIP UIFlow Handbook!
        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

        1 Reply Last reply Reply Quote 0
        • C
          cepics
          last edited by

          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.
          
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post