Panda, Visual Studio and I2C

userHead Vista_IT 2018-01-10 02:21:52 2482 Views3 Replies
Hi, I am new to the panda and Arduino sub system. I need to get data from a sensor on the I2C bus, The Sensor is SHT31-D temperature / humidity. I am using visual studio 17 and the adrunion.cs class file to interface to the Arduino I/O system.

Found a couple of short examples "Flash Led" this works fine. But cant get the I2C to work. I found an Arduino sketch on the manufacturers site and when loaded into the Arduino IDE this works great, giving me temperature and humidity values. But using the calls in VS I don't get any values back, there are no compile or run-time errors.

Code:
public partial class Form1 : Form
{
static Arduino adrunio;
static Int16[] rxd = new Int16[6];

public Form1()
{
InitializeComponent();
adrunio = new Arduino();
}

private void button1_Click(object sender, EventArgs e)
{
adrunio.wireRequest(0x44, 0x2C00, new Int16[] { 6 }, Arduino.I2C_MODE_WRITE);
adrunio.wireRequest(0x44, 0x2C00, rxd, Arduino.I2C_MODE_READ_ONCE);

int z = 88; // breakpoint to check the values in rxd
}
}

Has anyone got the I2c working via visual studio, any help would be fantastic and gratefully received.

Thanks
Ernie