Second i2c interface Arduino Nano 33 IoT

I'm attempting to revive (as-of-now closed) the topic located here: Second I2C Interface

I followed the instructions in that topic, as well as an example on Adafruit's website: Creating a new Wire | Using ATSAMD21 SERCOM for more SPI, I2C and Serial ports | Adafruit Learning System

I can get the code to compile, but at runtime it does not seem to find my i2c devices, specifically on the Arduino Nano 33 IoT. I understand the pin mappings are different, etc, and have done my best to accommodate this.

Has anyone been successful with this?

Why am I doing this??? Yes, I know that i2c should allow me to put all my devices on one bus, but we've been running into some weird, intermittent, hard-to-predict communication issues with having all our sensors on one bus. While it does not appear to be related to device addresses, I hypothesize that some communication noise could be due to certain sensors we are talking to requiring a logic converter for 3.3v to 5v conversion, while others on the same circuit do not require this conversion, and that somehow this extra converter being in the bus might do weird things. Although I am not an electrical engineer and don't understand this stuff fully. Being able to at least test each set of sensors on a separate bus could be useful.

Yes. I followed the instructions from the post you linked. Here is a step by step what I did.

I added the following include:

#include "wiring_private.h"

Created a new instance of TwoWire. I used an SSD1306 OLED connected to pin 6 and 5.

#define I2C_2_SDA_PIN  6
#define I2C_2_SCL_PIN  5

TwoWire secondWire( &sercom0, I2C_2_SDA_PIN, I2C_2_SCL_PIN );

In setup() configured the pins before the display.begin() is called.

pinPeripheral( I2C_2_SDA_PIN, PIO_SERCOM_ALT );   //Assign SDA function to pin 6
pinPeripheral( I2C_2_SCL_PIN, PIO_SERCOM_ALT );   //Assign SCL function to pin 5

The library allows to pass a TwoWire instance.

Adafruit_SSD1306 display( SCREEN_WIDTH, SCREEN_HEIGHT, &secondWire, OLED_RESET );

Done, everything else stayed the same. Display works as expected. I have a BME280 connected to the first I2C.

1 Like

Thank you. <3

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.