Enable 2nd I2C port for Seeed nrf52840

Hello,

I have been using the Seeed nrf52840 BLE/BLE Sense for a few months and am trying to at this time enable a second i2c port.

The reason for this is I am using two of the same sensor with the same i2c address (that is not changeable). With this - I need to enable a new set of i2c pins (SDA,SCL) on the board.

How do I go about doing this? I am working in Arduino IDE.

Thanks!

Hello & Welcome,

pretty sure it’s the same way , need to create two instances of the wire interface
look here,

ESP32 Using Two I2C Bus Interfaces
To use the two I2C bus interfaces of the ESP32, you need to create two TwoWire instances.

TwoWire I2Cone = TwoWire(0);
TwoWire I2Ctwo = TwoWire(1)
Then, initialize I2C communication on your desired pins with a defined frequency.

void setup() {
  I2Cone.begin(SDA_1, SCL_1, freq1);
  I2Ctwo.begin(SDA_2, SCL_2, freq2); 
}
Then, you can use the methods from the Wire.h library to interact with the I2C bus interfaces.

A simpler alternative is using the predefined Wire() and Wire1() objects. Wire().begin() creates an I2C communication on the first I2C bus using the default pins and default frequency. For the Wire1.begin() you should pass your desired SDA and SCL pins as well as the frequency.

ESP32 Using Two I2C Bus Interfaces

To use the two I2C bus interfaces of the ESP32, you need to create two TwoWire instances.

TwoWire I2Cone = TwoWire(0);
TwoWire I2Ctwo = TwoWire(1)

for the nRF52840 pretty sure you can use any of the other pins ,Digital IO’s afaik.
HTH
GL :slight_smile: PJ

1 Like

Thanks for this.

It seems like the nrf and nrf mbed boards aren’t quite the same when to comes to this modification. Any extra insight would be appreciated on how we can achieve this with the nrf52840 seeed.

Thanks again