Hi. I use in my project AS5048B sensor with I2C bus. I use the library Wire.
On the Arduino Mega everything works fine. When using Arduino DUE get the wrong data.
I read that I need to make changes to the library. I have used different methods, but did not get a good result.
If someone knows how to solve this problem, please help me.
#include <Wire.h>
void setup()
{
Serial.begin(9600);
Wire.begin();
}
void loop()
{
byte readArray[2];
uint16_t readValue = 0;
Wire.beginTransmission(0x40);
Wire.write(0xFE);
Wire.endTransmission(false);
Wire.requestFrom(0x40, 2);
for (byte i = 0; i < 2; i++)
{
readArray[i] = Wire.read();
}
readValue = (readArray[0] << 6) + (readArray[1] & 0x3F);
Serial.println(readValue);
}