Bonjour,
I have 3 AS5600 and I tested all 3 on Arduino UNO and ESP32 board.
They are identified at I2C address 0x36 but never give any angle or what so ever.
Here is the code, a combination of 2 examples: Preformatted text
#include <Wire.h>
#include "AS5600.h"
AS5600L as5600; // use default Wire
void setup()
{
Wire.begin();
Serial.begin(115200);
while (!Serial); // Leonardo: wait for serial monitor
Serial.println("\nI2C Scanner");
Serial.println(__FILE__);
Serial.print("AS5600_LIB_VERSION: ");
Serial.println(AS5600_LIB_VERSION);
as5600.begin(19); // set direction pin.
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
int b = as5600.isConnected();
Serial.print("Connect: ");
Serial.println(b);
delay(1000);
}
void loop()
{
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for(address = 1; address < 127; address++ )
{
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.print("Unknown error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
{
Serial.println("done\n");
Serial.print(as5600.readAngle());
Serial.print("\t");
Serial.println(as5600.rawAngle());
Serial.print("STATUS:\t ");
Serial.println(as5600.readStatus(), HEX);
Serial.print("CONFIG:\t ");
Serial.println(as5600.getConfigure(), HEX);
Serial.print(" GAIN:\t ");
Serial.println(as5600.readAGC(), HEX);
Serial.print("MAGNET:\t ");
Serial.println(as5600.readMagnitude(), HEX);
Serial.print("DETECT:\t ");
Serial.println(as5600.detectMagnet(), HEX);
Serial.print("M HIGH:\t ");
Serial.println(as5600.magnetTooStrong(), HEX);
Serial.print("M LOW:\t ");
Serial.println(as5600.magnetTooWeak(), HEX);
Serial.println();
delay(3000);
}
}
And here is the output
AS5600_LIB_VERSION: 0.6.4
Connect: 0
Scanning...
I2C device found at address 0x36 !
done
0 0
STATUS: 0
CONFIG: 0
GAIN: 0
MAGNET: 0
DETECT: 0
M HIGH: 0
M LOW: 0
Scanning...
I2C device found at address 0x36 !
done
0 0
STATUS: 0
What is wrong ? the devices ? my code ?