I even went so far as to use the sensorapi example in "Adafruit FXOS8700" which isn't even my code to print sensor information and it doesn't work. I verified that it wasn't that I have a bad connection or something by deploying my code from another computer of mine which is still using old versions of the libraries:
Working Config:
Feather nRF52840 Express: 1.1.0
Adafruit FXOS8700: 1.5.0
Adafruit AHRS: 2.2.4
Not Working Config:
Feather nRF52840 Express: 1.1.0
Adafruit FXOS8700: 2.2.0
Adafruit AHRS: 2.3.0
As you can see my "working config" is pretty dated so I would like to go with later versions. For brevity I am posting the sensorapi example code which doesnt work as my code initializes the sensor in the same way. Any idea what has changed? I am assuming something changed and the example code hasn't been updated to reflect it.
Code: Select all
#include <Adafruit_FXOS8700.h>
/* Assign a unique ID to this sensor at the same time */
Adafruit_FXOS8700 accelmag = Adafruit_FXOS8700(0x8700A, 0x8700B);
void displaySensorDetails(void) {
sensor_t accel, mag;
accelmag.getSensor(&accel, &mag);
Serial.println("------------------------------------");
Serial.println("ACCELEROMETER");
Serial.println("------------------------------------");
Serial.print("Sensor: ");
Serial.println(accel.name);
Serial.print("Driver Ver: ");
Serial.println(accel.version);
Serial.print("Unique ID: 0x");
Serial.println(accel.sensor_id, HEX);
Serial.print("Min Delay: ");
Serial.print(accel.min_delay);
Serial.println(" s");
Serial.print("Max Value: ");
Serial.print(accel.max_value, 4);
Serial.println(" m/s^2");
Serial.print("Min Value: ");
Serial.print(accel.min_value, 4);
Serial.println(" m/s^2");
Serial.print("Resolution: ");
Serial.print(accel.resolution, 8);
Serial.println(" m/s^2");
Serial.println("------------------------------------");
Serial.println("");
Serial.println("------------------------------------");
Serial.println("MAGNETOMETER");
Serial.println("------------------------------------");
Serial.print("Sensor: ");
Serial.println(mag.name);
Serial.print("Driver Ver: ");
Serial.println(mag.version);
Serial.print("Unique ID: 0x");
Serial.println(mag.sensor_id, HEX);
Serial.print("Min Delay: ");
Serial.print(accel.min_delay);
Serial.println(" s");
Serial.print("Max Value: ");
Serial.print(mag.max_value);
Serial.println(" uT");
Serial.print("Min Value: ");
Serial.print(mag.min_value);
Serial.println(" uT");
Serial.print("Resolution: ");
Serial.print(mag.resolution);
Serial.println(" uT");
Serial.println("------------------------------------");
Serial.println("");
delay(500);
}
void setup(void) {
Serial.begin(9600);
/* Wait for the Serial Monitor */
while (!Serial) {
delay(1);
}
Serial.println("FXOS8700 Test");
Serial.println("");
/* Initialise the sensor */
if (!accelmag.begin()) {
/* There was a problem detecting the FXOS8700 ... check your connections */
Serial.println("Ooops, no FXOS8700 detected ... Check your wiring!");
while (1)
Serial.println("Ooops, no FXOS8700 detected ... Check your wiring!");
;
}
/* Set accelerometer range (optional, default is 2G) */
// accelmag.setAccelRange(ACCEL_RANGE_8G);
/* Set the sensor mode (optional, default is hybrid mode) */
// accelmag.setSensorMode(ACCEL_ONLY_MODE);
/* Set the magnetometer's oversampling ratio (optional, default is 7) */
// accelmag.setMagOversamplingRatio(MAG_OSR_7);
/* Set the output data rate (optional, default is 100Hz) */
// accelmag.setOutputDataRate(ODR_400HZ);
/* Display some basic information on this sensor */
displaySensorDetails();
}
void loop(void) {
sensors_event_t aevent, mevent;
/* Get a new sensor event */
accelmag.getEvent(&aevent, &mevent);
/* Display the accel results (acceleration is measured in m/s^2) */
Serial.print("A ");
Serial.print("X: ");
Serial.print(aevent.acceleration.x, 4);
Serial.print(" ");
Serial.print("Y: ");
Serial.print(aevent.acceleration.y, 4);
Serial.print(" ");
Serial.print("Z: ");
Serial.print(aevent.acceleration.z, 4);
Serial.print(" ");
Serial.println("m/s^2");
/* Display the mag results (mag data is in uTesla) */
Serial.print("M ");
Serial.print("X: ");
Serial.print(mevent.magnetic.x, 1);
Serial.print(" ");
Serial.print("Y: ");
Serial.print(mevent.magnetic.y, 1);
Serial.print(" ");
Serial.print("Z: ");
Serial.print(mevent.magnetic.z, 1);
Serial.print(" ");
Serial.println("uT");
Serial.println("");
delay(500);
}
Feather nRF52840 Express: 1.1.0
Adafruit FXOS8700: 2.2.0
Adafruit AHRS: 2.2.4
The above sensorapi example code WORKS with this configuration. Any idea why going to latest AHRS code breaks it?
UPDATE 2: When initializing the sensor using accelmag.begin(ACCEL_RANGE_4G) it breaks with this configuration... but calling accelmag.begin() seems to work. There is a setAccelRange function which SEEMS like the way around this?
Code: Select all
/* Initialise the sensor */
if (!accelmag.begin()) {
/* There was a problem detecting the FXOS8700 ... check your connections */
Serial.println("Ooops, no FXOS8700 detected ... Check your wiring!");
while (1)
;
}
accelmag.setAccelRange(ACCEL_RANGE_4G);