compatibility issue between Touch and i2c Grove sensor



  • Hello everyone,

    I have a M5Stack Core2 and trying to communicate with an external sensor (BME680) on the Port.A Grove, i2c.
    I work with the Arduino IDE.
    Unfortunately for this Version (Core2) there aren't example for the Grove or i2c.
    After some problem to use it I found that I had to change the library of sensor to use wire1. Now the i2c sensor works correctly.
    The new problem is that I cannot more use the touch sensor of the display..
    If I use just use a code for the touch works fine, but the moment I add a sensor on i2c wire1, then the touch isn’t working anymore..
    I saw and read something on the forum about issue of compatibility (like they are using the same IO..) or change to be applied to the source files.. but yet didn’t find a way to use the two function together.
    Can someone maybe tell me if there’s a way to fix it, or they have realized it with this HW bug??

    Tnx



  • Hello @jimbo_s

    you'll need to have two I2C instances, Wire1 for internal stuff (AXP, Touch, RTC, etc.) on pins GPIO21 and GPIO22 and Wire for your sensor on pins GPIO32, GPIO33.

    The M5Core2 library already set Wire1 up for the internal stuff:

    Wire1.begin(21, 22);
    

    so your sensor should use Wire. You can enable that on the correct pins by calling:

    M5.begin(true, true, true, true);
    

    the last true sets Wire up:

    Wire.begin(32, 33);
    

    You probably need to change the library for the sensor to use Wire instead of Wire1. How that is done depends on the library. Some allow to pass in the I2C instance to be used and some need to have every instance of Wire1 replaced manually to Wire.

    The key here is to not mess with Wire1 else you loose all I2C communication within M5Core2.

    Cheers
    Felix



  • Hi Felix,

    thank you very much for the simple and quick answer.
    made the changes like in your suggestion and now the two functions work correctly together.
    It was clear that the M5Core already use the wire1 internally, good that at least wire is still available.

    Regards



  • Hello @jimbo_s

    you're welcome. I am glad you got it working to your liking.

    Happy Stacking!
    Felix