Is there a readable example of talking to an I2C device?
pmeloy opened this issue · 2 comments
I've been digging through the wiki but it seems to be missing lots of pages so I turned to the code but there are no examples.
I got as far as finding a BMP080 directory but see only parts of a device and can't seem to find out how to actually use it from a project.
I did find I2CDevice and I2CDevice connections but it looks like those are for bit-banging I2C instead of using the hardware since I'm supposed to supply pin numbers.
Is there an example anywhere for declaring, instantiating, and using an I2C device?
Ah, I found the DS1307 test which shows how to do I2C work but of course it fails with an argumentoutofrange execption.
using System.Diagnostics;
using Raspberry.IO.GeneralPurpose;
using Raspberry.IO.InterIntegratedCircuit;
using Raspberry.IO.Components.Sensors.Pressure.Bmp085;
....
private static I2cDriver driver;
private static I2cDeviceConnection i2cConnection;
private static Bmp085I2cConnection bmp;
....
try
{
driver = new I2cDriver(ProcessorPin.Pin02, ProcessorPin.Pin03);
i2cConnection = driver.Connect(0x77);
bmp = new Bmp085I2cConnection(i2cConnection);
}
catch (Exception ex)
{
Debug.Print("Unable to open connection. {0}",ex.GetType().FullName);
Application.Exit();
}
Result: Unable to open connection. System.ArgumentOutOfRangeException
Got rid of my try block and let mono tell me what's wrong. Problem in I2CDriver so I'll use a different issue with a more descriptive title.