Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    [Arduino Nicla Sense ME] How to read the acceleration values (BHI260AP) by Data Ready Interrupt

    [Arduino Nicla Sense ME] How to read the acceleration values (BHI260AP) by Data Ready Interrupt

    fnap17
    New Poster

    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!

    5 REPLIES 5

    BSTRobin
    Community Moderator
    Community Moderator

    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.

    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:

    fnap17_5-1648644753313.png

    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?

    fnap17_6-1648645575744.png

    Thanks

    SterlingMinsha
    New Poster

    Hello, BHI260AP does not support reading sensor data through data ready interrupt.

    Hi fnap17,

    1.You could get ODR by calling bhy2_get_virt_sensor_cfg();
    2.Yes, virtual sensor data was store into FIFO.

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist