I2c CreateWriteTransaction

I am accessing an HIH-6130 Digital Temperature/Humidity sensor using I2C. There are two separate transactions required: a write to begin the conversion and a read to get the results. Using the example code I was able to get it working but the example sends a data byte during the write transaction and the HIH-6130 doesn’t need one. Fortunately it doesn’t mind if one is sent but I would just as soon not send it if possible. I couldn’t figure out a way to eliminate the data byte w/o getting an error of some kind. Can it be done?

Example code for write transaction


          // create write buffer (we need one byte)
          byte[] RegisterNum = new byte[1] { 2 };
          xActions[0] = I2CDevice.CreateWriteTransaction(RegisterNum);

I haven’t tried it myself, but what happens if you pass null byte array when you create write transaction. Other than that I would not worry about it, since it is working. You can also take a look at how software I2C is implemented and modify it to work with zero byte write transactions.

Passing null byte array doesn’t work. I guess I’m stuck with extra output byte. Not worth changing library code. Thanks anyway. Not sure how to close this out.

@ sa319 - Perhaps you can try the Write() method in the SoftwareI2CBus.I2CDevice class and see if perhaps you get a different outcome?

I see that class is in the GHI.Premium.Hardware assembly. I forgot to mention I think that I’m using a Fez Panda II so I’m not sure if that library is applicable. It doesn’t seem to be listed in the references available to me.

There is SoftwareI2C implementation in the Gadgeteer source code. You can change it to work on Panda II.

@ sa319 - Once you get the SoftwareI2C working, you can look at the VideoOutConfigVGA800x600() method in this codeshare for a usage example: https://www.ghielectronics.com/community/codeshare/entry/772

There’s a whole bunch of writes followed by a read at the very end. I’m fairly certain that the premium and Gadgeteer versions of SoftwareI2C are the same.