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.
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’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.