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

    Toffeh
    Occasional Visitor

    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 🙂 

    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