GHI.IO.SoftwareI2CBus example?

Hi guys, i’m reading this article

about using I2C and i read that “The GHI libraries includes a software I2C implementation in the GHI.Hardware assembly (GHI.IO.SoftwareI2CBus).”

That class, browsed in the Object Browser of VS2013 appears to be more simple and much more intuitive to use instead of the original Microsoft.SPOT class, expecially when it’s need to have multiple transactions with various groups of different bytes, but I’ve not found a small example on how to use the class above.

Can anyone help me?

Thanks. Michele.

1 Like

@ tattik - You’ll want something like the below:

var bus = new SoftwareI2C(scl, sda);
var device = bus.CreateDevice(address);
var toWrite = new byte[] { 0x01 };
var toRead = new byte[2];
int writen, read;

if (!device.WriteRead(toWrite, toRead, out written, out read))

@ John -

Yes! This is exactly what I’m looking for!
Thanks, now I’m going to experiment with a MPU-6050 Gyro Accel I2C device that needs a lot of I2C transactions to read its internal registers.