Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BMX160 Magnetometer

    Highlighted
    Member

    BMX160 Magnetometer

    Hi everyone, I have purchased the BMX160 shuttle board. Base on this API I've managed to receive some data with the time stamp. However, I have some questions:

    1. How can I ensure that I am receiving the correct values from the magnetometer? I am receiving a constant value of 2047 on the z-axis, is this normal?

    2. I am using the accel.sensortime to get the time stamp but I am not sure what is its returning type, is this microseconds? I am calling read_sensor_data() every one second.

    This is the function I am calling to receive data. 

    struct bmi160_dev sensor; //For Accel and Gyro
    struct bmm150_dev bmm150; //For Mag
    struct bmi160_sensor_data accel;
    struct bmi160_sensor_data gyro;
    static void read_sensor_data() {
      m_xfer_done = false;
      bmi160_get_sensor_data((BMI160_ACCEL_SEL | BMI160_GYRO_SEL | BMI160_TIME_SEL), &accel, &gyro, &sensor);
      bmi160_read_aux_data_auto_mode(mag_data, &sensor);
      bmm150_aux_mag_data(mag_data, &bmm150);
    
      NRF_LOG_INFO("Time:%d , AccelX:%d , AccelY:%d , AccelZ:%d",accel.sensortime, accel.x, accel.y, accel.z);
      NRF_LOG_INFO("GyroX:%d , GyroY:%d , GyroZ:%d", gyro.x, gyro.y, gyro.z);
      NRF_LOG_INFO("MagX:%d , MagY:%d , MagZ:%d", bmm150.data.x, bmm150.data.y, bmm150.data.z);
    }

    Screenshot_8.png

    4 REPLIES 4
    Highlighted
    Community Moderator

    Re: BMX160 Magnetometer

    Hi Niko,

    • How can I ensure that I am receiving the correct values from the magnetometer? I am receiving a constant value of 2047 on the z-axis, is this normal?

    ----No. it's abnormal.  It seems signed or unsigned define issue in your code or driver.

    • I am using the accel.sensortime to get the time stamp but I am not sure what is its returning type, is this microseconds? I am calling read_sensor_data() every one second.

    ----Sensortime is a 24-bit counter in register 0x18~0x1A. The sensortime increments with 39us. accuracy is same as the ODR.

     

    Highlighted
    Member

    Re: BMX160 Magnetometer

    Hi Shellywang

    Thank you for your answer

    ----No. it's abnormal.  It seems signed or unsigned define issue in your code or driver.

    Could you please explain me what you mean by signed or unsigned define issue? Sorry, I am new to this and still learning 🙂

    Highlighted
    Member

    Re: BMX160 Magnetometer

    Anyone?

    Highlighted
    Community Moderator

    Re: BMX160 Magnetometer

    Please use the data structure in our API and follow the X/Y/Z axis data processing function in API , be care for the positive/negative and overflow.

    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