03-30-2022 11:22 AM
Hi, I'm working with "Arduino Nicla Sense ME" and want to known...how to read the acceleration values (BHI260AP) by Data Ready Interrupt?
Is it possible to read the acceleration values through the Data Ready Interrupt functionality?
Therefore not based on the following condition:
#include "Arduino_BHY2.h"
SensorXYZ accel(SENSOR_ID_ACC); // Accelerometer corrected
void setup(){
Serial.begin(115200);
BHY2.begin();
accel.begin(1000, 0); // sample-rate = 1000Hz, latency = 0ms (similar to Data-Ready Interrupt functionality)
}
void loop(){
static auto printTime = micros();
// Update function should be continuously polled
BHY2.update();
if (micros() - printTime >= 1000) { // new data every 1ms (1000Hz)???
printTime = micros();
Serial.println(String("acceleration: ") + accel.toString());
}
}
Instead...trying to use the function get_interrupt_status() from <BoschSensortech.h> library:
#include "Arduino_BHY2.h"
SensorXYZ accel(SENSOR_ID_ACC); // Accelerometer corrected
void setup(){
Serial.begin(115200);
BHY2.begin();
accel.begin(1000, 0); // sample-rate = 1000Hz, latency = 0ms (similar to Data-Ready Interrupt functionality)
}
void loop(){
static auto printTime = micros();
// Update function should be continuously polled
BHY2.update();
if (get_interrupt_status()) { // new data every 1ms (1000Hz)???
printTime = micros();
Serial.println(String("acceleration: ") + accel.toString());
}
}
And as output...the acquisition frequency does not seem to be the one configured.
Thanks to everyone!
Solved! Go to Solution.
05-31-2023 09:53 PM
Hi! Im quite new user with Arduino and its programming and now I have exactly the same problem with the Nicla Sense and want to read accelerometer values with Data Ready Interrupt function.
I saw answer from BSTRobin: "You could get ODR by calling bhy2_get_virt_sensor_cfg();"
But how should the bhy2_get_virt_sensor_cfg(); be added into the code below ? Should there be something more specific with it?
#include "Arduino_BHY2.h" SensorXYZ accel(SENSOR_ID_ACC); // Accelerometer corrected void setup(){ Serial.begin(115200); BHY2.begin(); accel.begin(1000, 0); // sample-rate = 1000Hz, latency = 0ms (similar to Data-Ready Interrupt functionality) } void loop(){ static auto printTime = micros(); // Update function should be continuously polled BHY2.update(); if (get_interrupt_status()) { // new data every 1ms (1000Hz)??? printTime = micros(); Serial.println(String("acceleration: ") + accel.toString()); } }
I really appreciate your help 🙂