it’s been days that i’m trying to generate a secondary i2c bus to drive my DRV2605 with non hardware default i2c bus on ESP32. What i need to do is :
1- to keep going with a first i2c bus driving a MPU9250 (so using pins 21 SDA1 and 22 SCL1, let’s name it Wire1
2- having a second i2c bus on pins 4 SDA2 and 17 SCL2. let’s name this Wire2
it looks like impossible using the library to have this
what i’m able to do is to move the original hardware i2c from 21-22 to 4-17 but this means that the original one it disappear and can’t be used
this does not work for a normal single core loop, nor using two different tasks using Core1 and Core2 (and this is what i’m going to do to run two instances of Wire and use simultaneously Wire1 and Wire2 and keep using MPU and DRV at the same time).
i’m stuck… :roll:
with a friend we understood that the library is using inside Wire.begin and it does not allow the call to change pins
The issue with your sample code is that the usage of Wire is hard coded in the DRV2605 library. You will have to make adjustments to the library to allow for Wire1 usage.
The MPU9250 allows for Wire1 to use : (based on an example)
As part of the creating that instance ‘myIPU’, it will perform a .begin() call. This will fail as there are NO default pins for Wire1 but the return code is neglected by the driver. In the sketch, as part of setup(), you have set Wire1.begin(SDA_2, SCL_2) BEFORE doing any call to myIMU (eg. myIMU.readByte()). I have tested this by adjusting my BM280 library and that worked.
Still this leads to another question… why would you use 2 different I2C channels. The I2C addresses are different so you could put both on the same channel.
at the end of the story, since the library does not allow to place the new pins, i had to leave wire1 for DRV and place the wire1 for IMU where i could place differet pins
my invite is to write a modification on the library to force different pins