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.
03-30-2022 11:59 AM
Hi fnap17,
BHI260AP didn't support reading sensor data via data ready interrupt. It is different hardware and software architecture for hub product.
As you see the code from Nicla Sense ME web site https://docs.arduino.cc/tutorials/nicla-sense-me/cheat-sheet, this is the way to read sensor data.
03-30-2022 03:09 PM
Ok this is clear!...but for example: how do I understand if ODR is actually set to 1kHz?
I imagine that there is the possibility to read an associated register...or there is the possibility to read timestamp sensor through function:
/**
* @brief Function to get the timestamp of the sensor in nanoseconds
* @param[out] timestamp_ns : Reference to the data buffer to store the timestamp in nanoseconds
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_hw_timestamp_ns(uint64_t *timestamp_ns, struct bhy2_dev *dev);
function of <bhy2.h> library.
Anyway, I read the datasheet bst-bhi260ap-ds000.pdf and in this section 6.2 Using Virtual sensors:
as default configuration the sample rate parameter is supported by the virtual sensor --> then this value will be selected as the actual sample rate. Right?
and in this section 7.3 BSX Sensor Fusion Lib:
I understand that: The virtual sensor stack computes the sensor data with a maximum Output Data Rate (ODR) of up to 800 Hz and stores them in the FIFOs. The host CPU can access the FIFO over the host interface.
But I'm not sure I understand this: what does it mean specifically?
Thanks
04-06-2022 05:00 PM
Hello, BHI260AP does not support reading sensor data through data ready interrupt.
04-15-2022 10:41 AM
Hi fnap17,
1.You could get ODR by calling bhy2_get_virt_sensor_cfg();
2.Yes, virtual sensor data was store into FIFO.