Using SoftI2CMaster.h Library to create 2 soft i2c ports

I have been trying to figure this out on my own, but I just can't seem to find the info on the net. I have two MLX90614 sensors each hooked to a pair of digital pins on my Arduino Mega. I am very successful at talking to each one individually, but haven't figured out how to get the code to talk to one, and then the other within the same program.

Excerpt from the library file
/* In order to use the library, you need to define SDA_PIN, SCL_PIN,

  • SDA_PORT and SCL_PORT before including this file. Have a look at
  • for finding out
  • which values to use. For example, if you use digital pin 3 for
  • SDA and digital pin 13 for SCL you have to use the following
  • definitions:
  • #define SDA_PIN 3
  • #define SDA_PORT PORTB
  • #define SCL_PIN 5
  • #define SCL_PORT PORTB

It seems it wants a global definition to the pins to use for the I2C port. And from what I can understand that makes it fixed with those pins throughout the sketch. I am hoping to have two separate soft I2C ports. I was hoping to have a function that would be passed the port pins to use, and return with a temperature reading from my MLX90614. I really don't want to add anymore hardware to switch between I2C devices.

Is there another softI2C library that allows this? Or is my understanding of this library missing something? I saw talk of it, but could never find it. I'm hoping someone can point me in the right direction.



Looks like I found it.

Found on Adafruit Website

Now to get it working with my code.

The SoftwareWire is in the Library Manager in the Arduino IDE.
The code has not yet been tested with many chips.

Once the SoftwareWire object has been declared in the sketch, it should be a drop-in replacement for the real Arduino Wire library.

Thanks Kopel!
I will give that one a try. Looks like a further development of what I was looking at. And very specifically able to do what I wanted. And it was right there in front of me. Ahhhhh! I do appreciate the help.