Hello!
I'm trying to read the temperature from a MCP9808. The sensor is on a breakout board from Adafruit, so pull-up resistors are already built in. I have tried with 3.3 and 5V. The problem is that I get no error, but the read data is always 0.
My code:
Byte[] rx = new Byte[2]; // 0x18 is the default address of the sensor // I have tried 100 and 400kHz I2CDevice.Configuration config = new I2CDevice.Configuration(0x18, 400); I2CDevice sensor = new I2CDevice(config); I2CDevice.I2CTransaction[] settings = new I2CDevice.I2CTransaction[] { // 0x05 is the register for the temperature // I have also tried register 0x07 which should get the device ID I2CDevice.CreateWriteTransaction(new byte[] { 0x05 }) }; I2CDevice.I2CTransaction[] rd = new I2CDevice.I2CTransaction[] { I2CDevice.CreateReadTransaction(rx) }; sensor.Execute(settings, 1000); while (true) { sensor.Execute(rd, 1000); // always "00" Debug.Print(rx[0].ToString() + rx[1].ToString()); Thread.Sleep(2000); }
Can you give me a hint what I'm doing wrong?
I got the register numbers from the Arduino library: https://github.com/a...hive/master.zip
Thank you very much!