I have written a simple script to get angle measurements from a magnetic sensor. The script works very well on Windows. However, when compiling the script on Linux (Ubuntu 20.04), the sensor repeats the first angle reading and does not change from this, despite the angle changing. There are no errors/warnings given by Windows or Linux. My script is the following and I would appreciate any help or advice to get this working on Linux. Thank you.
#include <SimpleFOC.h>
#define PI 3.1415926535897932384626433832795
// Magnetic sensor instance
MagneticSensorSPI AS5x4x = MagneticSensorSPI(8, 14, 0x3FFF);
void setup() {
// initialize magnetic sensor hardware
AS5x4x.init();
// use monitoring with serial
Serial.begin(9600);
Serial.println("Ready.");
_delay(1000);
}
void loop() {
Serial.println(AS5x4x.getAngle()); // display angle
}