I am having an issue with AS5600 (SEEED GROOVE) reading in I2C and PWM modes. In both connections, the angle and velocity values do not change.
My code in I2C mode:
#include <SimpleFOC.h>
#include <Wire.h>
// or quick config
MagneticSensorI2C as5600 = MagneticSensorI2C(AS5600_I2C);
void setup() {
// monitoring port
Serial.begin(115200);
as5600.init();
_delay(1000);
Serial.println("AS5600 ready");
_delay(1000);
}
void loop() {
// IMPORTANT - call as frequently as possible
// update the sensor values
as5600.update();
// display the angle and the angular velocity to the terminal
Serial.print(as5600.getAngle());
Serial.print("\t");
Serial.println(as5600.getVelocity());
}
and I2C read mode output:
12.56 0.00
12.56 0.00
12.56 0.00
12.56 0.00
12.56 0.00
12.56 0.00
PWM mode code:
#include <SimpleFOC.h>
MagneticSensorPWM sensor = MagneticSensorPWM(A_HALL1, 4, 904);
void doPWM(){sensor.handlePWM();}
void setup() {
// monitoring port
Serial.begin(115200);
//initialize magnetic sensor hardware
sensor.init();
// comment out to use sensor in blocking (non-interrupt) way
sensor.enableInterrupt(doPWM);
Serial.println("Sensor ready");
_delay(1000);
}
void loop() {
// IMPORTANT - call as frequently as possible
// update the sensor values
sensor.update();
// display the angle and the angular velocity to the terminal
Serial.print(sensor.getAngle());
Serial.print("\t");
Serial.println(sensor.getVelocity());
}
and PWM mode output:
-0.01 0.00
-0.01 0.00
-0.01 0.00
-0.01 0.00
-0.01 0.00
-0.01 0.00
-0.01 0.00
-0.01 0.00
-0.01 0.00
On the Arduino Mega board, this magnetic sensor works well. However, when I even try to connect to it over another sample (from SEEED repo) through B-G431B-ESC1, the sample is blocked on the detection (first I2C call).
I am using the sensor in 3.3V mode with 5V->3.3V drop-down (5V from B-G431B-ESC1). Checked the voltage on the input of the sensor, and it comes to around 3.3V.
On the Arduino board, I have used 3.3V output from the board.
Do not know where the issue might be, but I saw that people in this community have a problem with this particular sensor. Any help or hints is appreciated