Gravity: BMX160+BMP388 10 DOF Sensor Wiki - DFRobot

Introduction

The BMX160 9-axis absolute orientation sensor from Bosch Sensortec is an ideal solution for applications that face strict constraints of board space, power consumption and appearance, especially for wearable device like smart watches or augmented reality glasses. This BMX160 sensor is the smallest 9-axis sensor in the industry. It comprises an accelerometer, gyroscope and geomagnetic sensor in a single package, and features less than 1.5mA power consumption. Combined with BSX sensor data fusion software library of Bosch Sensortec, the sensor performance can be further improved.

BMP388 is a high performance barometric pressure sensor with compact body, high resolution, and the smallest size in same series. The BMP388 delivers outstanding altitude stabilization in drones, where accurate measurement of barometric pressure provides the essential altitude data for improving flight stability and landing accuracy.

This module is a combination of BMX160 and BMP388 from DFRobot, which is perfectly suitable for using in drone applications to measure height, attitude and orientation.

Features

Specification

Dimension

Board Overview

Silkscreen Description
+/VCC Positive
-/GND Negative
C/SCL IIC clock line
D/SDA IIC data line
3V3 3.3V power
ADDR(BMP388) BMP388 IIC address select
ADDR(BMX160) BMX160 IIC address select
CSB2 BMX160 protocol select pin
INIT2 BMX160 external interrupt 2
INIT3 BMX160 external interrupt 1
CSB1 BMP388 Protocol select pin
INIT1 BMP388 external pin

API Function

class DFRobot_BMX160 {
/*
 * @function Gyroscope enum range, unit: G
 */
typedef enum{
 eGyroRange_2000DPS, /*Gyroscope sensitivity at 2000dps*/
 eGyroRange_1000DPS, /*Gyroscope sensitivity at 1000dps*/
 eGyroRange_500DPS,  /*Gyroscope sensitivity at 500dps*/
 eGyroRange_250DPS,  /*Gyroscope sensitivity at 250dps*/
 eGyroRange_125DPS   /*Gyroscope sensitivity at 125dps*/
}eGyroRange_t;

/*
 * @function Accelerometer enum range, unit, m/s^2
 */
typedef enum{
 eAccelRange_2G,  /* Macro for mg per LSB at +/- 2g sensitivity (1 LSB = 0.000061035mg) */
 eAccelRange_4G,  /* Macro for mg per LSB at +/- 4g sensitivity (1 LSB = 0.000122070mg) */
 eAccelRange_8G,  /* Macro for mg per LSB at +/- 8g sensitivity (1 LSB = 0.000244141mg) */
 eAccelRange_16G  /* Macro for mg per LSB at +/- 16g sensitivity (1 LSB = 0.000488281mg) */
}eAccelRange_t;

/*
 * @function reset sensor
 * @Return true if it succeeds
 */
bool softReset();

/*
 * @function init sensor
 * @Return true if it succeeds
 */
bool begin();

/*
 * @function set gyroscope range, unit: G
 * @Parameter One variable from eGyroRange_t
 */
void setGyroRange(eGyroRange_t bits);

/*
 * @function set accelerometer range, unit: m/s^2
 * @Parameter One variable from eAccelRange_t 
 */
void setAccelRange(eAccelRange_t bits);

/*
 * @function Get data of accelerometer, gyroscope, geomagnetic sensor
 * @Parameter Store the address of all data
 */
void getAllData(struct bmx160SensorData *magn, struct bmx160SensorData *gyro, struct bmx160SensorData *accel);

/*
 * @function Turn off geomagnetic sensor, gyroscope enters low power mode(there are data output from accelerometer)
 */
void setLowPower();

/*
 * @function Turn on geomagnetic sensor, gyroscope enters normal mode
 */
void wakeUp();

Tutorial

The 10 DOF sensor integrates BMX160 and BMP388. Visit the IIc address of BMX160 (default: 0x68) and BMP388 (0x76) via I2C interface to get the related position data and environment information.

Requirements

Connection Diagram

Connection

BMX160 Usage Tutorial

Program Function: read data of accelerometer, gyroscope and geomagnetic sensor of BMX160 via I2C interface, and print the readings through serial port.

/*!
  * file readAllData.ino
  *
  * Through the example, you can get the sensor data by using getSensorData:
  * get all data of magnetometer, gyroscope, accelerometer.
  * 
  * With the rotation of the sensor, data changes are visible.
  *
  * Copyright   [DFRobot](https://www.dfrobot.com), 2016
  * Copyright   GNU Lesser General Public License
  *
  * version  V0.1
  * date  2019-6-25
  */

#include <DFRobot_BMX160.h>

DFRobot_BMX160 bmx160;
void setup(){
  Serial.begin(115200);
  delay(100);

  //init the hardware bmx160  
  if (bmx160.begin() != true){
    Serial.println("init false");
    while(1);
  }
  //bmx160.setLowPower();   //disable the gyroscope and accelerometer sensor
  //bmx160.wakeUp();        //enable the gyroscope and accelerometer sensor
  //bmx160.softReset();     //reset the sensor

  /** @typedef enum{eGyroRange_2000DPS,
   *                eGyroRange_1000DPS,
   *                eGyroRange_500DPS,
   *                eGyroRange_250DPS,
   *                eGyroRange_125DPS
   *                }eGyroRange_t;
   **/
  //bmx160.setGyroRange(eGyroRange_500DPS);

  /** @typedef enum{eAccelRange_2G,
   *                eAccelRange_4G,
   *                eAccelRange_8G,
   *                eAccelRange_16G
   *                }eAccelRange_t;
   */
  //bmx160.setAccelRange(eAccelRange_4G);
  delay(100);
}

void loop(){
  sBmx160SensorData_t Omagn, Ogyro, Oaccel;

  /* Get a new sensor event */
  bmx160.getAllData(&Omagn, &Ogyro, &Oaccel);

  /* Display the magnetometer results (magn is magnetometer in uTesla) */
  Serial.print("M ");
  Serial.print("X: "); Serial.print(Omagn.x); Serial.print("  ");
  Serial.print("Y: "); Serial.print(Omagn.y); Serial.print("  ");
  Serial.print("Z: "); Serial.print(Omagn.z); Serial.print("  ");
  Serial.println("uT");

  /* Display the gyroscope results (gyroscope data is in g) */
  Serial.print("G ");
  Serial.print("X: "); Serial.print(Ogyro.x); Serial.print("  ");
  Serial.print("Y: "); Serial.print(Ogyro.y); Serial.print("  ");
  Serial.print("Z: "); Serial.print(Ogyro.z); Serial.print("  ");
  Serial.println("g");

  /* Display the accelerometer results (accelerometer data is in m/s^2) */
  Serial.print("A ");
  Serial.print("X: "); Serial.print(Oaccel.x    ); Serial.print("  ");
  Serial.print("Y: "); Serial.print(Oaccel.y    ); Serial.print("  ");
  Serial.print("Z: "); Serial.print(Oaccel.z    ); Serial.print("  ");
  Serial.println("m/s^2");

  Serial.println("");

  delay(500);
}

Serial Print

BMP388 Usage Tutorial

For detailed usage of BMP388, refer to BMP388 wiki.

The default BMP388 SDO pin is Low, IIC address: BMP3_I2C_ADDR_PRIM

FAQ

For any questions, advice or cool ideas to share, please visit the DFRobot Forum

More Documents

DFshopping_car1.png Get Gravity: BMX160+BMP388 10 DOF Sensor from DFRobot Store or DFRobot Distributor.

Turn to the Top