Main Site Documentation

Domino and SRF08


#1

I’m interfacing a Daventech SRF08 Sonar Range Finder via I2C on the Domino. It is directly wired to Di2 and Di3 using the I2CDevice object and I keep getting System.ArgumentException. Does this mean I’m getting no communication with the SRF08? Do I need a level converter since the SRF08 is 5 Volts? Does anyone have code for a SRF08? Thanks!


#2

“ArgumentException” means there was a bad argument passed to a method


#3

I’ve gone over my code and can’t figure out why I get the exception. Here is my code the exception occurs at the tI2CDevice.Execute.

public static void Main()
 {
     I2CDevice.Configuration con = new I2CDevice.Configuration(0xE0, 400);
     I2CDevice tI2CDevice = new I2CDevice(con);


     byte[] RegisterNum = new byte[1] { 0 };
     I2CDevice.I2CWriteTransaction write = I2CDevice.CreateWriteTransaction(RegisterNum);

     byte[] RegisterValue = new byte[1];
     I2CDevice.I2CReadTransaction read = I2CDevice.CreateReadTransaction(RegisterValue);

     I2CDevice.I2CTransaction[] xActions = new I2CDevice.I2CTransaction[] { write, read };

     tI2CDevice.Execute(xActions, 1000);

     Debug.Print(RegisterValue[0].ToString());
           
}

#4

Please code tag your code so it is readable.

should that be (0xe0>>1) for the address?


#5

Thanks Gus, changing the address to E0>>1 did the trick! I would’ve never figured that out. Is the right shift because I2C uses 7 bit addressing?


#6

Correct


#7

I updated the I2C page a while ago to help people understand I2C addresses. http://wiki.tinyclr.com/index.php?title=I2C_-_EEPROM