I have a simple sketch that exercises most of the sensors on the Nano 33 BLE Sense configurable for both the Rev1 and Rev2 via a #define. Using a combination of routines mostly similar to those in the various Cheat Sheets, both work. However, the Rev2 runs at only 1/3 to 1/2 the speed of the Rev1 for the magnetometer and a combination of temperature / pressure / humidity. This has been confirmed by essentially commenting out all the other sensor routines and monitoring the loop speed very scientifically with a blinking LED.
Specifically this sketch: Nano_33_BLE_Sense_Sensor_Test12.ino .
I have partially gotten around it by (1) commenting out the
while (!IMU.magneticFieldAvailable()) {} statement (which appears to make no obvious difference in field values) and sampling the T/P/H once every N times through the loop.
The revised sketch is: Nano_33_BLE_Sense_Sensor_Test16.ino,
(though the version # may have changed by the time anyone reads this post, assuming anyone ever does!
I'm using the recommended libraries but perhaps one or more are outdated?
Since the rev1 and rev2 sensors and libraries are mostly different, with arbitrarily chosen default settings, why would you expect data acquisition to run "at the same speed"?
If speed matters for a specific application, post the details and your requirements, as the code and sensor settings could undoubtedly be optimized.
There were links to the relevant sketches in the original post. And this isn't something like a 10 percent difference, more like 2 or 3 to 1 for those sensors. And if anything one would expect Rev2 to be better than Rev1, but it's the exact opposite!
My apologies on etiquette. It makes sense to want the code here so it can't be changed behind your backs.
Here is a condensed sketch which demonstrates a 2:1 difference in speed between Rev1 and Rev2 using only the magnetic field measurements of the IMU. The quick summary is that the loop time is ~50 ms for the Rev1 and ~100 ms for the Rev2. If the
"while (!IMU.magneticFieldAvailable());" statement is removed, the loop times for both are 2-3 ms and the returned values aren't obviously corrupted.
#define Rev1 // Select Nano BLE 33 Sense Rev1 or Rev2 here
#define data1 1 // Send loop time in milliseconds to serial port if 1
#include <Arduino.h>
// Nano 33 BLE Sense Version for libraries
#ifdef Rev1
#include <Arduino_LSM9DS1.h> // Accelerometer, magnetometer and gyroscope
#endif
#ifdef Rev2
#include <Arduino_BMI270_BMM150.h> // Accelerometer, magnetometer and gyroscope
#endif
// Common library
#include <Arduino_LPS22HB.h> // Pressure
int count = 0;
int ms = 0; // Current time in ms
int previous_ms = 0; // Previous time in ms
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // Set the LED pin as output
if (data1 == 1) { // Initialize serial port and print banner
Serial.begin(9600);
while (!Serial);
Serial.println();
Serial.println();
Serial.println("Arduino Nano 33 BLE Sense Rev1-2 Speed Test.");
Serial.println();
}
if (!IMU.begin()) while (1); // Initialize IMU
}
void loop() {
float mx, my, mz;
char buffer[40];
// Loop time readout
if (data1 == 1) {
previous_ms = ms;
ms = millis();
Serial.print("Loop Time: ");
sprintf(buffer, "%3d", ms - previous_ms);
Serial.print(buffer);
Serial.print( " ms | ");
}
// Magnetic field
while (!IMU.magneticFieldAvailable());
IMU.readMagneticField(mx, my, mz);
if (data1 == 1) {
Serial.print("Field (Gauss) X: ");
sprintf(buffer, "%5.2f", mx / 100);
Serial.print(buffer);
Serial.print(" Y: ");
sprintf(buffer, "%5.2f", my / 100);
Serial.print(buffer);
Serial.print(" Z: ");
sprintf(buffer, "%5.2f", mz / 100);
Serial.print(buffer);
Serial.println("");
}
if ((count & 7) == 7) digitalWrite(LED_BUILTIN, !(digitalRead(LED_BUILTIN))); // Diagnostic 1/8th loop rate indicator
count ++;
}